From: "Daniel P. Berrange" <berrange@xxxxxxxxxx> There are many declared options in gendispatch.pl that were no longer used. Those which were used were obsecure '-b', '-k' and '-d'. Switch to use --mode={debug|client|server}. Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx> --- daemon/Makefile.am | 12 +++---- src/Makefile.am | 24 ++++++------- src/rpc/gendispatch.pl | 94 ++++++++++++++++++++++++-------------------------- 3 files changed, 63 insertions(+), 67 deletions(-) diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 3532bd5..64126e5 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -63,18 +63,18 @@ QEMU_PROTOCOL = $(top_srcdir)/src/remote/qemu_protocol.x $(srcdir)/remote_dispatch.h: $(srcdir)/../src/rpc/gendispatch.pl \ $(REMOTE_PROTOCOL) - $(AM_V_GEN)$(PERL) -w $(srcdir)/../src/rpc/gendispatch.pl -b remote REMOTE \ - $(REMOTE_PROTOCOL) > $@ + $(AM_V_GEN)$(PERL) -w $(srcdir)/../src/rpc/gendispatch.pl \ + --mode=server remote REMOTE $(REMOTE_PROTOCOL) > $@ $(srcdir)/lxc_dispatch.h: $(srcdir)/../src/rpc/gendispatch.pl \ $(LXC_PROTOCOL) - $(AM_V_GEN)$(PERL) -w $(srcdir)/../src/rpc/gendispatch.pl -b lxc LXC \ - $(LXC_PROTOCOL) > $@ + $(AM_V_GEN)$(PERL) -w $(srcdir)/../src/rpc/gendispatch.pl \ + --mode=server lxc LXC $(LXC_PROTOCOL) > $@ $(srcdir)/qemu_dispatch.h: $(srcdir)/../src/rpc/gendispatch.pl \ $(QEMU_PROTOCOL) - $(AM_V_GEN)$(PERL) -w $(srcdir)/../src/rpc/gendispatch.pl -b qemu QEMU \ - $(QEMU_PROTOCOL) > $@ + $(AM_V_GEN)$(PERL) -w $(srcdir)/../src/rpc/gendispatch.pl \ + --mode=server qemu QEMU $(QEMU_PROTOCOL) > $@ if WITH_LIBVIRTD diff --git a/src/Makefile.am b/src/Makefile.am index 3adddb4..6edbb11 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -198,8 +198,8 @@ LOCK_DAEMON_SOURCES = \ $(srcdir)/locking/lock_daemon_dispatch_stubs.h: $(LOCK_PROTOCOL) \ $(srcdir)/rpc/gendispatch.pl Makefile.am - $(AM_V_GEN)perl -w $(srcdir)/rpc/gendispatch.pl \ - -b virLockSpaceProtocol VIR_LOCK_SPACE_PROTOCOL \ + $(AM_V_GEN)perl -w $(srcdir)/rpc/gendispatch.pl --mode=server \ + virLockSpaceProtocol VIR_LOCK_SPACE_PROTOCOL \ $(LOCK_PROTOCOL) > $@ @@ -299,18 +299,18 @@ REMOTE_DRIVER_PROTOCOL = $(REMOTE_PROTOCOL) $(QEMU_PROTOCOL) $(LXC_PROTOCOL) $(srcdir)/remote/remote_client_bodies.h: $(srcdir)/rpc/gendispatch.pl \ $(REMOTE_PROTOCOL) Makefile.am - $(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl \ - -k remote REMOTE $(REMOTE_PROTOCOL) > $@ + $(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl --mode=client \ + remote REMOTE $(REMOTE_PROTOCOL) > $@ $(srcdir)/remote/lxc_client_bodies.h: $(srcdir)/rpc/gendispatch.pl \ $(LXC_PROTOCOL) Makefile.am - $(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl \ - -k lxc LXC $(LXC_PROTOCOL) > $@ + $(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl --mode=client \ + lxc LXC $(LXC_PROTOCOL) > $@ $(srcdir)/remote/qemu_client_bodies.h: $(srcdir)/rpc/gendispatch.pl \ $(QEMU_PROTOCOL) Makefile.am - $(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl \ - -k qemu QEMU $(QEMU_PROTOCOL) > $@ + $(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl --mode=client \ + qemu QEMU $(QEMU_PROTOCOL) > $@ REMOTE_DRIVER_SOURCES = \ gnutls_1_0_compat.h \ @@ -469,13 +469,13 @@ LXC_MONITOR_PROTOCOL = $(srcdir)/lxc/lxc_monitor_protocol.x $(srcdir)/lxc/lxc_monitor_dispatch.h: $(srcdir)/rpc/gendispatch.pl \ $(LXC_MONITOR_PROTOCOL) Makefile.am - $(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl \ - -k virLXCMonitor VIR_LXC_MONITOR $(LXC_MONITOR_PROTOCOL) > $@ + $(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl --mode=client \ + virLXCMonitor VIR_LXC_MONITOR $(LXC_MONITOR_PROTOCOL) > $@ $(srcdir)/lxc/lxc_controller_dispatch.h: $(srcdir)/rpc/gendispatch.pl \ $(REMOTE_PROTOCOL) Makefile.am - $(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl \ - -b virLXCMonitor VIR_LXC_MONITOR $(LXC_MONITOR_PROTOCOL) > $@ + $(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl --mode=server \ + virLXCMonitor VIR_LXC_MONITOR $(LXC_MONITOR_PROTOCOL) > $@ EXTRA_DIST += \ $(LXC_MONITOR_PROTOCOL) \ diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl index 65a0ac2..fdc345f 100755 --- a/src/rpc/gendispatch.pl +++ b/src/rpc/gendispatch.pl @@ -17,13 +17,15 @@ use strict; -use Getopt::Std; +use Getopt::Long; -# Command line options. -# -k - client bodies -# -b - server bodies -our ($opt_p, $opt_t, $opt_a, $opt_r, $opt_d, $opt_b, $opt_k); -getopts ('ptardbk'); +my $mode = "debug"; +my $res = GetOptions("mode=s" => \$mode); + +die "cannot parse command line options" unless $res; + +die "unknown mode '$mode', expecting 'client', 'server' or 'debug'" + unless $mode =~ /^(client|server|debug)$/; my $structprefix = shift or die "missing struct prefix argument"; my $procprefix = shift or die "missing procedure prefix argument"; @@ -105,7 +107,7 @@ while (<PROTOCOL>) { push(@{$calls{$name}->{ret_members}}, $1); } } elsif ($collect_opts) { - if (m,^\s*\*\s*\@(\w+)\s*:\s*(\w+)\s*$,) { + if (m,^\s*\*\s*\@(\w+)\s*:\s*((?:\w|:)+)\s*$,) { $opts{$1} = $2; } elsif (m,^\s*\*/\s*$,) { $collect_opts = 0; @@ -159,7 +161,7 @@ while (<PROTOCOL>) { } } - if ($flags ne "" and ($opt_b or $opt_k)) { + if ($flags ne "") { if (!($flags =~ m/^\s*\/\*\s*insert@(\d+)\s*\*\/\s*$/)) { die "invalid generator flags for $calls{$name}->{ret}"; } @@ -207,47 +209,45 @@ while (<PROTOCOL>) { } $calls{$name}->{constname} = $constname; - if ($opt_b or $opt_k) { - if (!exists $opts{generate}) { - die "'\@generate' annotation missing for $constname"; - } + if (!exists $opts{generate}) { + die "'\@generate' annotation missing for $constname"; + } - if ($opts{generate} !~ /^(both|server|client|none)$/) { - die "'\@generate' annotation value '$opts{generate}' invalid"; - } + if ($opts{generate} !~ /^(both|server|client|none)$/) { + die "'\@generate' annotation value '$opts{generate}' invalid"; + } - if ($opts{generate} eq "both") { - push(@autogen, $ProcName); - } elsif ($opt_b && ($opts{generate} eq "server")) { - push(@autogen, $ProcName); - } elsif (!$opt_b && ($opts{generate} eq "client")) { - push(@autogen, $ProcName); - } + if ($opts{generate} eq "both") { + push(@autogen, $ProcName); + } elsif ($mode eq "server" && ($opts{generate} eq "server")) { + push(@autogen, $ProcName); + } elsif ($mode eq "client" && ($opts{generate} eq "client")) { + push(@autogen, $ProcName); + } - if (exists $opts{readstream}) { - $calls{$name}->{streamflag} = "read"; - $calls{$name}->{streamoffset} = int($opts{readstream}); - } elsif (exists $opts{writestream}) { - $calls{$name}->{streamflag} = "write"; - $calls{$name}->{streamoffset} = int($opts{writestream}); - } else { - $calls{$name}->{streamflag} = "none"; - } + if (exists $opts{readstream}) { + $calls{$name}->{streamflag} = "read"; + $calls{$name}->{streamoffset} = int($opts{readstream}); + } elsif (exists $opts{writestream}) { + $calls{$name}->{streamflag} = "write"; + $calls{$name}->{streamoffset} = int($opts{writestream}); + } else { + $calls{$name}->{streamflag} = "none"; + } - # for now, we distinguish only two levels of prioroty: - # low (0) and high (1) - if (exists $opts{priority}) { - if ($opts{priority} eq "high") { - $calls{$name}->{priority} = 1; - } elsif ($opts{priority} eq "low") { - $calls{$name}->{priority} = 0; - } else { - die "\@priority annotation value '$opts{priority}' invalid for $constname" - } - } else { + # for now, we distinguish only two levels of prioroty: + # low (0) and high (1) + if (exists $opts{priority}) { + if ($opts{priority} eq "high") { + $calls{$name}->{priority} = 1; + } elsif ($opts{priority} eq "low") { $calls{$name}->{priority} = 0; + } else { + die "\@priority annotation value '$opts{priority}' invalid for $constname" } + } else { + $calls{$name}->{priority} = 0; } $calls[$id] = $calls{$name}; @@ -327,12 +327,8 @@ print <<__EOF__; */ __EOF__ -if (!$opt_b and !$opt_k) { - print "\n"; -} - # Debugging. -if ($opt_d) { +if ($mode eq "debug") { my @keys = sort (keys %calls); foreach (@keys) { print "$_:\n"; @@ -343,7 +339,7 @@ if ($opt_d) { } # Bodies for dispatch functions ("remote_dispatch_bodies.h"). -elsif ($opt_b) { +elsif ($mode eq "server") { my %generate = map { $_ => 1 } @autogen; my @keys = sort (keys %calls); @@ -1050,7 +1046,7 @@ elsif ($opt_b) { } # Bodies for client functions ("remote_client_bodies.h"). -elsif ($opt_k) { +elsif ($mode eq "client") { my %generate = map { $_ => 1 } @autogen; my @keys = sort (keys %calls); -- 1.8.1.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list