1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

Cleanup command line options in gendispatch.pl

There are many declared options in gendispatch.pl that were
no longer used. Those which were used were obscure '-b', '-k'
and '-d'. Switch to use --mode={debug|client|server}.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2013-04-18 11:29:56 +01:00
parent 23090823f1
commit 6da982be65
3 changed files with 62 additions and 66 deletions

View File

@ -63,18 +63,18 @@ QEMU_PROTOCOL = $(top_srcdir)/src/remote/qemu_protocol.x
$(srcdir)/remote_dispatch.h: $(srcdir)/../src/rpc/gendispatch.pl \ $(srcdir)/remote_dispatch.h: $(srcdir)/../src/rpc/gendispatch.pl \
$(REMOTE_PROTOCOL) $(REMOTE_PROTOCOL)
$(AM_V_GEN)$(PERL) -w $(srcdir)/../src/rpc/gendispatch.pl -b remote REMOTE \ $(AM_V_GEN)$(PERL) -w $(srcdir)/../src/rpc/gendispatch.pl \
$(REMOTE_PROTOCOL) > $@ --mode=server remote REMOTE $(REMOTE_PROTOCOL) > $@
$(srcdir)/lxc_dispatch.h: $(srcdir)/../src/rpc/gendispatch.pl \ $(srcdir)/lxc_dispatch.h: $(srcdir)/../src/rpc/gendispatch.pl \
$(LXC_PROTOCOL) $(LXC_PROTOCOL)
$(AM_V_GEN)$(PERL) -w $(srcdir)/../src/rpc/gendispatch.pl -b lxc LXC \ $(AM_V_GEN)$(PERL) -w $(srcdir)/../src/rpc/gendispatch.pl \
$(LXC_PROTOCOL) > $@ --mode=server lxc LXC $(LXC_PROTOCOL) > $@
$(srcdir)/qemu_dispatch.h: $(srcdir)/../src/rpc/gendispatch.pl \ $(srcdir)/qemu_dispatch.h: $(srcdir)/../src/rpc/gendispatch.pl \
$(QEMU_PROTOCOL) $(QEMU_PROTOCOL)
$(AM_V_GEN)$(PERL) -w $(srcdir)/../src/rpc/gendispatch.pl -b qemu QEMU \ $(AM_V_GEN)$(PERL) -w $(srcdir)/../src/rpc/gendispatch.pl \
$(QEMU_PROTOCOL) > $@ --mode=server qemu QEMU $(QEMU_PROTOCOL) > $@
if WITH_LIBVIRTD if WITH_LIBVIRTD

View File

@ -198,8 +198,8 @@ LOCK_DAEMON_SOURCES = \
$(srcdir)/locking/lock_daemon_dispatch_stubs.h: $(LOCK_PROTOCOL) \ $(srcdir)/locking/lock_daemon_dispatch_stubs.h: $(LOCK_PROTOCOL) \
$(srcdir)/rpc/gendispatch.pl Makefile.am $(srcdir)/rpc/gendispatch.pl Makefile.am
$(AM_V_GEN)perl -w $(srcdir)/rpc/gendispatch.pl \ $(AM_V_GEN)perl -w $(srcdir)/rpc/gendispatch.pl --mode=server \
-b virLockSpaceProtocol VIR_LOCK_SPACE_PROTOCOL \ virLockSpaceProtocol VIR_LOCK_SPACE_PROTOCOL \
$(LOCK_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 \ $(srcdir)/remote/remote_client_bodies.h: $(srcdir)/rpc/gendispatch.pl \
$(REMOTE_PROTOCOL) Makefile.am $(REMOTE_PROTOCOL) Makefile.am
$(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl \ $(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl --mode=client \
-k remote REMOTE $(REMOTE_PROTOCOL) > $@ remote REMOTE $(REMOTE_PROTOCOL) > $@
$(srcdir)/remote/lxc_client_bodies.h: $(srcdir)/rpc/gendispatch.pl \ $(srcdir)/remote/lxc_client_bodies.h: $(srcdir)/rpc/gendispatch.pl \
$(LXC_PROTOCOL) Makefile.am $(LXC_PROTOCOL) Makefile.am
$(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl \ $(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl --mode=client \
-k lxc LXC $(LXC_PROTOCOL) > $@ lxc LXC $(LXC_PROTOCOL) > $@
$(srcdir)/remote/qemu_client_bodies.h: $(srcdir)/rpc/gendispatch.pl \ $(srcdir)/remote/qemu_client_bodies.h: $(srcdir)/rpc/gendispatch.pl \
$(QEMU_PROTOCOL) Makefile.am $(QEMU_PROTOCOL) Makefile.am
$(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl \ $(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl --mode=client \
-k qemu QEMU $(QEMU_PROTOCOL) > $@ qemu QEMU $(QEMU_PROTOCOL) > $@
REMOTE_DRIVER_SOURCES = \ REMOTE_DRIVER_SOURCES = \
gnutls_1_0_compat.h \ 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 \ $(srcdir)/lxc/lxc_monitor_dispatch.h: $(srcdir)/rpc/gendispatch.pl \
$(LXC_MONITOR_PROTOCOL) Makefile.am $(LXC_MONITOR_PROTOCOL) Makefile.am
$(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl \ $(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl --mode=client \
-k virLXCMonitor VIR_LXC_MONITOR $(LXC_MONITOR_PROTOCOL) > $@ virLXCMonitor VIR_LXC_MONITOR $(LXC_MONITOR_PROTOCOL) > $@
$(srcdir)/lxc/lxc_controller_dispatch.h: $(srcdir)/rpc/gendispatch.pl \ $(srcdir)/lxc/lxc_controller_dispatch.h: $(srcdir)/rpc/gendispatch.pl \
$(REMOTE_PROTOCOL) Makefile.am $(REMOTE_PROTOCOL) Makefile.am
$(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl \ $(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl --mode=server \
-b virLXCMonitor VIR_LXC_MONITOR $(LXC_MONITOR_PROTOCOL) > $@ virLXCMonitor VIR_LXC_MONITOR $(LXC_MONITOR_PROTOCOL) > $@
EXTRA_DIST += \ EXTRA_DIST += \
$(LXC_MONITOR_PROTOCOL) \ $(LXC_MONITOR_PROTOCOL) \

View File

@ -17,13 +17,15 @@
use strict; use strict;
use Getopt::Std; use Getopt::Long;
# Command line options. my $mode = "debug";
# -k - client bodies my $res = GetOptions("mode=s" => \$mode);
# -b - server bodies
our ($opt_p, $opt_t, $opt_a, $opt_r, $opt_d, $opt_b, $opt_k); die "cannot parse command line options" unless $res;
getopts ('ptardbk');
die "unknown mode '$mode', expecting 'client', 'server' or 'debug'"
unless $mode =~ /^(client|server|debug)$/;
my $structprefix = shift or die "missing struct prefix argument"; my $structprefix = shift or die "missing struct prefix argument";
my $procprefix = shift or die "missing procedure prefix argument"; my $procprefix = shift or die "missing procedure prefix argument";
@ -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*$/)) { if (!($flags =~ m/^\s*\/\*\s*insert@(\d+)\s*\*\/\s*$/)) {
die "invalid generator flags for $calls{$name}->{ret}"; die "invalid generator flags for $calls{$name}->{ret}";
} }
@ -207,47 +209,45 @@ while (<PROTOCOL>) {
} }
$calls{$name}->{constname} = $constname; $calls{$name}->{constname} = $constname;
if ($opt_b or $opt_k) { if (!exists $opts{generate}) {
if (!exists $opts{generate}) { die "'\@generate' annotation missing for $constname";
die "'\@generate' annotation missing for $constname"; }
}
if ($opts{generate} !~ /^(both|server|client|none)$/) { if ($opts{generate} !~ /^(both|server|client|none)$/) {
die "'\@generate' annotation value '$opts{generate}' invalid"; die "'\@generate' annotation value '$opts{generate}' invalid";
} }
if ($opts{generate} eq "both") { if ($opts{generate} eq "both") {
push(@autogen, $ProcName); push(@autogen, $ProcName);
} elsif ($opt_b && ($opts{generate} eq "server")) { } elsif ($mode eq "server" && ($opts{generate} eq "server")) {
push(@autogen, $ProcName); push(@autogen, $ProcName);
} elsif (!$opt_b && ($opts{generate} eq "client")) { } elsif ($mode eq "client" && ($opts{generate} eq "client")) {
push(@autogen, $ProcName); push(@autogen, $ProcName);
} }
if (exists $opts{readstream}) { if (exists $opts{readstream}) {
$calls{$name}->{streamflag} = "read"; $calls{$name}->{streamflag} = "read";
$calls{$name}->{streamoffset} = int($opts{readstream}); $calls{$name}->{streamoffset} = int($opts{readstream});
} elsif (exists $opts{writestream}) { } elsif (exists $opts{writestream}) {
$calls{$name}->{streamflag} = "write"; $calls{$name}->{streamflag} = "write";
$calls{$name}->{streamoffset} = int($opts{writestream}); $calls{$name}->{streamoffset} = int($opts{writestream});
} else { } else {
$calls{$name}->{streamflag} = "none"; $calls{$name}->{streamflag} = "none";
} }
# for now, we distinguish only two levels of prioroty: # for now, we distinguish only two levels of priority:
# low (0) and high (1) # low (0) and high (1)
if (exists $opts{priority}) { if (exists $opts{priority}) {
if ($opts{priority} eq "high") { if ($opts{priority} eq "high") {
$calls{$name}->{priority} = 1; $calls{$name}->{priority} = 1;
} elsif ($opts{priority} eq "low") { } 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{$name}->{priority} = 0;
} else {
die "\@priority annotation value '$opts{priority}' invalid for $constname"
} }
} else {
$calls{$name}->{priority} = 0;
} }
$calls[$id] = $calls{$name}; $calls[$id] = $calls{$name};
@ -327,12 +327,8 @@ print <<__EOF__;
*/ */
__EOF__ __EOF__
if (!$opt_b and !$opt_k) {
print "\n";
}
# Debugging. # Debugging.
if ($opt_d) { if ($mode eq "debug") {
my @keys = sort (keys %calls); my @keys = sort (keys %calls);
foreach (@keys) { foreach (@keys) {
print "$_:\n"; print "$_:\n";
@ -343,7 +339,7 @@ if ($opt_d) {
} }
# Bodies for dispatch functions ("remote_dispatch_bodies.h"). # Bodies for dispatch functions ("remote_dispatch_bodies.h").
elsif ($opt_b) { elsif ($mode eq "server") {
my %generate = map { $_ => 1 } @autogen; my %generate = map { $_ => 1 } @autogen;
my @keys = sort (keys %calls); my @keys = sort (keys %calls);
@ -1050,7 +1046,7 @@ elsif ($opt_b) {
} }
# Bodies for client functions ("remote_client_bodies.h"). # Bodies for client functions ("remote_client_bodies.h").
elsif ($opt_k) { elsif ($mode eq "client") {
my %generate = map { $_ => 1 } @autogen; my %generate = map { $_ => 1 } @autogen;
my @keys = sort (keys %calls); my @keys = sort (keys %calls);