2011-04-24 07:58:01 +00:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
#
|
|
|
|
# This script parses remote_protocol.x or qemu_protocol.x and produces lots of
|
|
|
|
# boilerplate code for both ends of the remote connection.
|
|
|
|
#
|
|
|
|
# The first non-option argument specifies the prefix to be searched for, and
|
|
|
|
# output to, the boilerplate code. The second non-option argument is the
|
|
|
|
# file you want to operate on. For instance, to generate the dispatch table
|
|
|
|
# for both remote_protocol.x and qemu_protocol.x, you would run the
|
|
|
|
# following:
|
|
|
|
#
|
|
|
|
# remote_generator.pl -c -t remote ../src/remote/remote_protocol.x
|
|
|
|
# remote_generator.pl -t qemu ../src/remote/qemu_protocol.x
|
|
|
|
#
|
|
|
|
# By Richard Jones <rjones@redhat.com>
|
2011-04-22 18:35:34 +00:00
|
|
|
# Extended by Matthias Bolte <matthias.bolte@googlemail.com>
|
2011-04-24 07:58:01 +00:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
use Getopt::Std;
|
|
|
|
|
|
|
|
# Command line options.
|
2011-04-23 10:53:57 +00:00
|
|
|
our ($opt_p, $opt_t, $opt_a, $opt_r, $opt_d, $opt_c, $opt_b, $opt_k);
|
|
|
|
getopts ('ptardcbk');
|
2011-04-24 07:58:01 +00:00
|
|
|
|
|
|
|
my $structprefix = $ARGV[0];
|
|
|
|
my $procprefix = uc $structprefix;
|
|
|
|
shift;
|
|
|
|
|
|
|
|
# Convert name_of_call to NameOfCall.
|
|
|
|
sub name_to_ProcName {
|
|
|
|
my $name = shift;
|
|
|
|
my @elems = split /_/, $name;
|
|
|
|
@elems = map ucfirst, @elems;
|
2011-04-22 13:36:52 +00:00
|
|
|
@elems = map { $_ =~ s/Nwfilter/NWFilter/; $_ =~ s/Xml/XML/;
|
2011-04-22 16:54:51 +00:00
|
|
|
$_ =~ s/Uri/URI/; $_ =~ s/Uuid/UUID/; $_ =~ s/Id/ID/;
|
2011-04-23 06:19:46 +00:00
|
|
|
$_ =~ s/Mac/MAC/; $_ =~ s/Cpu/CPU/; $_ =~ s/Os/OS/;
|
|
|
|
$_ } @elems;
|
2011-04-24 07:58:01 +00:00
|
|
|
join "", @elems
|
|
|
|
}
|
|
|
|
|
|
|
|
# Read the input file (usually remote_protocol.x) and form an
|
|
|
|
# opinion about the name, args and return type of each RPC.
|
|
|
|
my ($name, $ProcName, $id, %calls, @calls);
|
|
|
|
|
|
|
|
# only generate a close method if -c was passed
|
|
|
|
if ($opt_c) {
|
|
|
|
# REMOTE_PROC_CLOSE has no args or ret.
|
|
|
|
$calls{close} = {
|
|
|
|
name => "close",
|
|
|
|
ProcName => "Close",
|
|
|
|
UC_NAME => "CLOSE",
|
|
|
|
args => "void",
|
|
|
|
ret => "void",
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2011-04-22 18:35:34 +00:00
|
|
|
my $collect_args_members = 0;
|
2011-04-22 15:09:33 +00:00
|
|
|
my $collect_ret_members = 0;
|
2011-04-22 18:35:34 +00:00
|
|
|
my $last_name;
|
|
|
|
|
2011-04-24 07:58:01 +00:00
|
|
|
while (<>) {
|
2011-04-22 18:35:34 +00:00
|
|
|
if ($collect_args_members) {
|
|
|
|
if (/^};/) {
|
|
|
|
$collect_args_members = 0;
|
|
|
|
} elsif ($_ =~ m/^\s*(.*\S)\s*$/) {
|
|
|
|
push(@{$calls{$name}->{args_members}}, $1);
|
|
|
|
}
|
2011-04-22 15:09:33 +00:00
|
|
|
} elsif ($collect_ret_members) {
|
|
|
|
if (/^};/) {
|
|
|
|
$collect_ret_members = 0;
|
|
|
|
} elsif ($_ =~ m/^\s*(.*\S)\s*$/) {
|
|
|
|
push(@{$calls{$name}->{ret_members}}, $1);
|
|
|
|
}
|
2011-04-22 18:35:34 +00:00
|
|
|
} elsif (/^struct ${structprefix}_(.*)_args/) {
|
2011-04-24 07:58:01 +00:00
|
|
|
$name = $1;
|
|
|
|
$ProcName = name_to_ProcName ($name);
|
|
|
|
|
|
|
|
die "duplicate definition of ${structprefix}_${name}_args"
|
|
|
|
if exists $calls{$name};
|
|
|
|
|
|
|
|
$calls{$name} = {
|
|
|
|
name => $name,
|
|
|
|
ProcName => $ProcName,
|
|
|
|
UC_NAME => uc $name,
|
|
|
|
args => "${structprefix}_${name}_args",
|
2011-04-22 18:35:34 +00:00
|
|
|
args_members => [],
|
|
|
|
ret => "void"
|
2011-04-24 07:58:01 +00:00
|
|
|
};
|
|
|
|
|
2011-04-22 18:35:34 +00:00
|
|
|
$collect_args_members = 1;
|
2011-04-22 15:09:33 +00:00
|
|
|
$collect_ret_members = 0;
|
2011-04-22 18:35:34 +00:00
|
|
|
$last_name = $name;
|
2011-04-24 07:58:01 +00:00
|
|
|
} elsif (/^struct ${structprefix}_(.*)_ret/) {
|
|
|
|
$name = $1;
|
|
|
|
$ProcName = name_to_ProcName ($name);
|
|
|
|
|
|
|
|
if (exists $calls{$name}) {
|
|
|
|
$calls{$name}->{ret} = "${structprefix}_${name}_ret";
|
|
|
|
} else {
|
|
|
|
$calls{$name} = {
|
|
|
|
name => $name,
|
|
|
|
ProcName => $ProcName,
|
|
|
|
UC_NAME => uc $name,
|
|
|
|
args => "void",
|
2011-04-22 15:09:33 +00:00
|
|
|
ret => "${structprefix}_${name}_ret",
|
|
|
|
ret_members => []
|
2011-04-24 07:58:01 +00:00
|
|
|
}
|
|
|
|
}
|
2011-04-22 18:35:34 +00:00
|
|
|
|
|
|
|
$collect_args_members = 0;
|
2011-04-22 15:09:33 +00:00
|
|
|
$collect_ret_members = 1;
|
|
|
|
$last_name = $name;
|
2011-04-24 07:58:01 +00:00
|
|
|
} elsif (/^struct ${structprefix}_(.*)_msg/) {
|
|
|
|
$name = $1;
|
|
|
|
$ProcName = name_to_ProcName ($name);
|
|
|
|
|
|
|
|
$calls{$name} = {
|
|
|
|
name => $name,
|
|
|
|
ProcName => $ProcName,
|
|
|
|
UC_NAME => uc $name,
|
|
|
|
msg => "${structprefix}_${name}_msg"
|
2011-04-22 18:35:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$collect_args_members = 0;
|
2011-04-22 15:09:33 +00:00
|
|
|
$collect_ret_members = 0;
|
2011-04-24 07:58:01 +00:00
|
|
|
} elsif (/^\s*${procprefix}_PROC_(.*?)\s+=\s+(\d+),?$/) {
|
|
|
|
$name = lc $1;
|
|
|
|
$id = $2;
|
|
|
|
$ProcName = name_to_ProcName ($name);
|
|
|
|
|
|
|
|
$calls[$id] = $calls{$name};
|
2011-04-22 18:35:34 +00:00
|
|
|
|
|
|
|
$collect_args_members = 0;
|
2011-04-22 15:09:33 +00:00
|
|
|
$collect_ret_members = 0;
|
2011-04-22 18:35:34 +00:00
|
|
|
} else {
|
|
|
|
$collect_args_members = 0;
|
2011-04-22 15:09:33 +00:00
|
|
|
$collect_ret_members = 0;
|
2011-04-24 07:58:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# Output
|
|
|
|
|
|
|
|
print <<__EOF__;
|
|
|
|
/* Automatically generated by remote_generator.pl.
|
|
|
|
* Do not edit this file. Any changes you make will be lost.
|
|
|
|
*/
|
|
|
|
__EOF__
|
|
|
|
|
2011-04-23 10:53:57 +00:00
|
|
|
if (!$opt_b and !$opt_k) {
|
|
|
|
print "\n";
|
|
|
|
}
|
|
|
|
|
2011-04-24 07:58:01 +00:00
|
|
|
# Debugging.
|
|
|
|
if ($opt_d) {
|
|
|
|
my @keys = sort (keys %calls);
|
|
|
|
foreach (@keys) {
|
|
|
|
print "$_:\n";
|
|
|
|
print " name $calls{$_}->{name} ($calls{$_}->{ProcName})\n";
|
|
|
|
print " $calls{$_}->{args} -> $calls{$_}->{ret}\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Prototypes for dispatch functions ("remote_dispatch_prototypes.h").
|
|
|
|
elsif ($opt_p) {
|
|
|
|
my @keys = sort (keys %calls);
|
|
|
|
foreach (@keys) {
|
|
|
|
# Skip things which are REMOTE_MESSAGE
|
|
|
|
next if $calls{$_}->{msg};
|
|
|
|
|
|
|
|
print "static int ${structprefix}Dispatch$calls{$_}->{ProcName}(\n";
|
|
|
|
print " struct qemud_server *server,\n";
|
|
|
|
print " struct qemud_client *client,\n";
|
|
|
|
print " virConnectPtr conn,\n";
|
|
|
|
print " remote_message_header *hdr,\n";
|
|
|
|
print " remote_error *rerr,\n";
|
|
|
|
print " $calls{$_}->{args} *args,\n";
|
|
|
|
print " $calls{$_}->{ret} *ret);\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Union of all arg types
|
|
|
|
# ("remote_dispatch_args.h").
|
|
|
|
elsif ($opt_a) {
|
|
|
|
for ($id = 0 ; $id <= $#calls ; $id++) {
|
|
|
|
if (defined $calls[$id] &&
|
|
|
|
!$calls[$id]->{msg} &&
|
|
|
|
$calls[$id]->{args} ne "void") {
|
|
|
|
print " $calls[$id]->{args} val_$calls[$id]->{args};\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Union of all arg types
|
|
|
|
# ("remote_dispatch_ret.h").
|
|
|
|
elsif ($opt_r) {
|
|
|
|
for ($id = 0 ; $id <= $#calls ; $id++) {
|
|
|
|
if (defined $calls[$id] &&
|
|
|
|
!$calls[$id]->{msg} &&
|
|
|
|
$calls[$id]->{ret} ne "void") {
|
|
|
|
print " $calls[$id]->{ret} val_$calls[$id]->{ret};\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Inside the switch statement, prepare the 'fn', 'args_filter', etc
|
|
|
|
# ("remote_dispatch_table.h").
|
|
|
|
elsif ($opt_t) {
|
|
|
|
for ($id = 0 ; $id <= $#calls ; $id++) {
|
|
|
|
if (defined $calls[$id] && !$calls[$id]->{msg}) {
|
|
|
|
print "{ /* $calls[$id]->{ProcName} => $id */\n";
|
|
|
|
print " .fn = (dispatch_fn) ${structprefix}Dispatch$calls[$id]->{ProcName},\n";
|
|
|
|
if ($calls[$id]->{args} ne "void") {
|
|
|
|
print " .args_filter = (xdrproc_t) xdr_$calls[$id]->{args},\n";
|
|
|
|
} else {
|
|
|
|
print " .args_filter = (xdrproc_t) xdr_void,\n";
|
|
|
|
}
|
|
|
|
if ($calls[$id]->{ret} ne "void") {
|
|
|
|
print " .ret_filter = (xdrproc_t) xdr_$calls[$id]->{ret},\n";
|
|
|
|
} else {
|
|
|
|
print " .ret_filter = (xdrproc_t) xdr_void,\n";
|
|
|
|
}
|
|
|
|
print "},\n";
|
|
|
|
} else {
|
|
|
|
if ($calls[$id]->{msg}) {
|
|
|
|
print "{ /* Async event $calls[$id]->{ProcName} => $id */\n";
|
|
|
|
} else {
|
|
|
|
print "{ /* (unused) => $id */\n";
|
|
|
|
}
|
|
|
|
print " .fn = NULL,\n";
|
|
|
|
print " .args_filter = (xdrproc_t) xdr_void,\n";
|
|
|
|
print " .ret_filter = (xdrproc_t) xdr_void,\n";
|
|
|
|
print "},\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-04-22 18:35:34 +00:00
|
|
|
|
|
|
|
# Bodies for dispatch functions ("remote_dispatch_bodies.c").
|
|
|
|
elsif ($opt_b) {
|
|
|
|
# list of functions that currently are not generatable
|
|
|
|
my @ungeneratable;
|
|
|
|
|
|
|
|
if ($structprefix eq "remote") {
|
|
|
|
@ungeneratable = ("Close",
|
|
|
|
"DomainEventsDeregisterAny",
|
|
|
|
"DomainEventsRegisterAny",
|
|
|
|
"DomainMigratePrepareTunnel",
|
|
|
|
"DomainOpenConsole",
|
|
|
|
"DomainPinVcpu",
|
|
|
|
"DomainSetSchedulerParameters",
|
|
|
|
"DomainSetMemoryParameters",
|
|
|
|
"DomainSetBlkioParameters",
|
|
|
|
"Open",
|
|
|
|
"StorageVolUpload",
|
2011-04-22 15:09:33 +00:00
|
|
|
"StorageVolDownload",
|
|
|
|
|
|
|
|
"AuthList",
|
|
|
|
"AuthSaslInit",
|
|
|
|
"AuthSaslStart",
|
|
|
|
"AuthSaslStep",
|
|
|
|
"AuthPolkit",
|
|
|
|
|
|
|
|
"DomainBlockPeek",
|
|
|
|
"DomainCreateWithFlags",
|
|
|
|
"DomainEventsDeregister",
|
|
|
|
"DomainEventsRegister",
|
|
|
|
"DomainGetBlkioParameters",
|
|
|
|
"DomainGetMemoryParameters",
|
|
|
|
"DomainGetSchedulerParameters",
|
|
|
|
"DomainGetSchedulerType",
|
|
|
|
"DomainGetSecurityLabel",
|
|
|
|
"DomainGetVcpus",
|
|
|
|
"DomainMemoryPeek",
|
|
|
|
"DomainMemoryStats",
|
|
|
|
"DomainMigratePrepare",
|
|
|
|
"DomainMigratePrepare2",
|
|
|
|
"GetType",
|
|
|
|
"NodeDeviceGetParent",
|
|
|
|
"NodeGetSecurityModel",
|
2011-04-23 07:36:33 +00:00
|
|
|
"SecretGetValue");
|
2011-04-22 18:35:34 +00:00
|
|
|
} elsif ($structprefix eq "qemu") {
|
|
|
|
@ungeneratable = ("MonitorCommand");
|
|
|
|
}
|
|
|
|
|
|
|
|
my %ug = map { $_ => 1 } @ungeneratable;
|
|
|
|
my @keys = sort (keys %calls);
|
|
|
|
|
|
|
|
foreach (@keys) {
|
|
|
|
# skip things which are REMOTE_MESSAGE
|
|
|
|
next if $calls{$_}->{msg};
|
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
if (exists($ug{$calls{$_}->{ProcName}})) {
|
|
|
|
print "\n/* ${structprefix}Dispatch$calls{$_}->{ProcName} has " .
|
|
|
|
"to be implemented manually */\n";
|
2011-04-22 18:35:34 +00:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $has_node_device = 0;
|
|
|
|
my @vars_list = ();
|
2011-04-22 18:31:05 +00:00
|
|
|
my @optionals_list = ();
|
2011-04-22 18:35:34 +00:00
|
|
|
my @getters_list = ();
|
|
|
|
my @args_list = ();
|
2011-04-22 15:09:33 +00:00
|
|
|
my @ret_list = ();
|
2011-04-22 18:35:34 +00:00
|
|
|
my @free_list = ();
|
2011-04-23 06:35:03 +00:00
|
|
|
my @free_list_on_error = ("remoteDispatchError(rerr);");
|
2011-04-22 18:35:34 +00:00
|
|
|
|
2011-04-23 07:40:14 +00:00
|
|
|
# handle arguments to the function
|
2011-04-22 18:35:34 +00:00
|
|
|
if ($calls{$_}->{args} ne "void") {
|
|
|
|
# node device is special, as it's identified by name
|
2011-04-22 16:54:51 +00:00
|
|
|
if ($calls{$_}->{args} =~ m/^remote_node_device_/ and
|
|
|
|
!($calls{$_}->{args} =~ m/^remote_node_device_lookup_by_name_/) and
|
|
|
|
!($calls{$_}->{args} =~ m/^remote_node_device_create_xml_/)) {
|
2011-04-22 18:35:34 +00:00
|
|
|
$has_node_device = 1;
|
|
|
|
push(@vars_list, "virNodeDevicePtr dev = NULL");
|
|
|
|
push(@getters_list,
|
|
|
|
" if (!(dev = virNodeDeviceLookupByName(conn, args->name)))\n" .
|
|
|
|
" goto cleanup;\n");
|
|
|
|
push(@args_list, "dev");
|
|
|
|
push(@free_list,
|
|
|
|
" if (dev)\n" .
|
|
|
|
" virNodeDeviceFree(dev);");
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach my $args_member (@{$calls{$_}->{args_members}}) {
|
|
|
|
if ($args_member =~ m/^remote_nonnull_string name;/ and $has_node_device) {
|
|
|
|
# ignore the name arg for node devices
|
|
|
|
next
|
2011-04-22 22:19:14 +00:00
|
|
|
} elsif ($args_member =~ m/^remote_nonnull_(domain|network|storage_pool|storage_vol|interface|secret|nwfilter) (\S+);/) {
|
|
|
|
my $type_name = name_to_ProcName($1);
|
|
|
|
|
|
|
|
push(@vars_list, "vir${type_name}Ptr $2 = NULL");
|
2011-04-22 18:35:34 +00:00
|
|
|
push(@getters_list,
|
2011-04-22 22:19:14 +00:00
|
|
|
" if (!($2 = get_nonnull_$1(conn, args->$2)))\n" .
|
2011-04-22 18:35:34 +00:00
|
|
|
" goto cleanup;\n");
|
2011-04-22 22:19:14 +00:00
|
|
|
push(@args_list, "$2");
|
2011-04-22 18:35:34 +00:00
|
|
|
push(@free_list,
|
2011-04-22 22:19:14 +00:00
|
|
|
" if ($2)\n" .
|
|
|
|
" vir${type_name}Free($2);");
|
2011-04-22 18:35:34 +00:00
|
|
|
} elsif ($args_member =~ m/^remote_nonnull_domain_snapshot /) {
|
|
|
|
push(@vars_list, "virDomainPtr dom = NULL");
|
|
|
|
push(@vars_list, "virDomainSnapshotPtr snapshot = NULL");
|
|
|
|
push(@getters_list,
|
2011-04-22 13:40:31 +00:00
|
|
|
" if (!(dom = get_nonnull_domain(conn, args->snap.dom)))\n" .
|
2011-04-22 18:35:34 +00:00
|
|
|
" goto cleanup;\n" .
|
|
|
|
"\n" .
|
|
|
|
" if (!(snapshot = get_nonnull_domain_snapshot(dom, args->snap)))\n" .
|
|
|
|
" goto cleanup;\n");
|
|
|
|
push(@args_list, "snapshot");
|
|
|
|
push(@free_list,
|
|
|
|
" if (snapshot)\n" .
|
|
|
|
" virDomainSnapshotFree(snapshot);\n" .
|
|
|
|
" if (dom)\n" .
|
|
|
|
" virDomainFree(dom);");
|
|
|
|
} elsif ($args_member =~ m/(\S+)<\S+>;/) {
|
|
|
|
if (! @args_list) {
|
|
|
|
push(@args_list, "conn");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($calls{$_}->{ProcName} eq "SecretSetValue") {
|
|
|
|
push(@args_list, "(const unsigned char *)args->$1.$1_val");
|
2011-04-23 06:19:46 +00:00
|
|
|
} elsif ($calls{$_}->{ProcName} eq "CPUBaseline") {
|
|
|
|
push(@args_list, "(const char **)args->$1.$1_val");
|
2011-04-22 18:35:34 +00:00
|
|
|
} else {
|
|
|
|
push(@args_list, "args->$1.$1_val");
|
|
|
|
}
|
|
|
|
|
|
|
|
push(@args_list, "args->$1.$1_len");
|
2011-04-22 16:54:51 +00:00
|
|
|
} elsif ($args_member =~ m/(\S+) (\S+);/) {
|
2011-04-22 18:35:34 +00:00
|
|
|
if (! @args_list) {
|
|
|
|
push(@args_list, "conn");
|
|
|
|
}
|
|
|
|
|
2011-04-22 16:54:51 +00:00
|
|
|
if ($1 eq "remote_uuid") {
|
|
|
|
push(@args_list, "(unsigned char *) args->$2");
|
2011-04-22 18:31:05 +00:00
|
|
|
} elsif ($1 eq "remote_string") {
|
|
|
|
push(@vars_list, "char *$2");
|
|
|
|
push(@optionals_list, "$2");
|
|
|
|
push(@args_list, "$2");
|
2011-04-22 16:54:51 +00:00
|
|
|
} else {
|
|
|
|
push(@args_list, "args->$2");
|
|
|
|
}
|
2011-04-23 07:36:33 +00:00
|
|
|
} elsif ($args_member =~ m/^\/*/) {
|
|
|
|
# ignore comments
|
|
|
|
} else {
|
|
|
|
die "unhandled type for argument value: $args_member";
|
2011-04-22 18:35:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-23 07:40:14 +00:00
|
|
|
# handle return values of the function
|
2011-04-22 15:09:33 +00:00
|
|
|
my $single_ret_var = "undefined";
|
|
|
|
my $single_ret_by_ref = 0;
|
|
|
|
my $single_ret_check = " == undefined";
|
2011-04-22 20:48:25 +00:00
|
|
|
my $single_ret_as_list = 0;
|
|
|
|
my $single_ret_list_name = "undefined";
|
|
|
|
my $single_ret_list_max_var = "undefined";
|
|
|
|
my $single_ret_list_max_define = "undefined";
|
2011-04-23 07:36:33 +00:00
|
|
|
my $multi_ret = 0;
|
|
|
|
|
|
|
|
if ($calls{$_}->{ret} ne "void" and
|
|
|
|
scalar(@{$calls{$_}->{ret_members}}) > 1) {
|
|
|
|
$multi_ret = 1;
|
|
|
|
}
|
2011-04-22 15:09:33 +00:00
|
|
|
|
|
|
|
if ($calls{$_}->{ret} ne "void") {
|
|
|
|
foreach my $ret_member (@{$calls{$_}->{ret_members}}) {
|
2011-04-23 07:36:33 +00:00
|
|
|
if ($multi_ret) {
|
|
|
|
if ($ret_member =~ m/(char|short|int|hyper) (\S+)\[\S+\];/) {
|
|
|
|
push(@ret_list, "memcpy(ret->$2, tmp.$2, sizeof ret->$2);");
|
|
|
|
} elsif ($ret_member =~ m/char (\S+);/ or
|
|
|
|
$ret_member =~ m/short (\S+);/ or
|
|
|
|
$ret_member =~ m/int (\S+);/ or
|
|
|
|
$ret_member =~ m/hyper (\S+);/) {
|
|
|
|
push(@ret_list, "ret->$1 = tmp.$1;");
|
|
|
|
} else {
|
|
|
|
die "unhandled type for multi-return-value: $ret_member";
|
|
|
|
}
|
|
|
|
} elsif ($ret_member =~ m/remote_nonnull_string (\S+)<(\S+)>;/) {
|
2011-04-22 20:48:25 +00:00
|
|
|
push(@vars_list, "int len");
|
|
|
|
push(@ret_list, "ret->$1.$1_len = len;");
|
2011-04-23 06:35:03 +00:00
|
|
|
push(@free_list_on_error, "VIR_FREE(ret->$1.$1_val);");
|
2011-04-22 20:48:25 +00:00
|
|
|
$single_ret_var = "len";
|
|
|
|
$single_ret_by_ref = 0;
|
|
|
|
$single_ret_check = " < 0";
|
|
|
|
$single_ret_as_list = 1;
|
|
|
|
$single_ret_list_name = $1;
|
|
|
|
$single_ret_list_max_var = "max$1";
|
|
|
|
$single_ret_list_max_define = $2;
|
|
|
|
|
|
|
|
if ($calls{$_}->{ProcName} eq "NodeListDevices") {
|
|
|
|
my $conn = shift(@args_list);
|
|
|
|
my $cap = shift(@args_list);
|
|
|
|
unshift(@args_list, "ret->$1.$1_val");
|
|
|
|
unshift(@args_list, $cap);
|
|
|
|
unshift(@args_list, $conn);
|
|
|
|
} else {
|
|
|
|
my $conn = shift(@args_list);
|
|
|
|
unshift(@args_list, "ret->$1.$1_val");
|
|
|
|
unshift(@args_list, $conn);
|
|
|
|
}
|
2011-04-22 15:09:33 +00:00
|
|
|
} elsif ($ret_member =~ m/remote_nonnull_string (\S+);/) {
|
|
|
|
push(@vars_list, "char *$1");
|
|
|
|
push(@ret_list, "ret->$1 = $1;");
|
|
|
|
$single_ret_var = $1;
|
|
|
|
$single_ret_by_ref = 0;
|
|
|
|
$single_ret_check = " == NULL";
|
2011-04-22 22:19:14 +00:00
|
|
|
} elsif ($ret_member =~ m/remote_nonnull_(domain|network|storage_pool|storage_vol|interface|node_device|secret|nwfilter|domain_snapshot) (\S+);/) {
|
|
|
|
my $type_name = name_to_ProcName($1);
|
|
|
|
|
|
|
|
push(@vars_list, "vir${type_name}Ptr $2 = NULL");
|
|
|
|
push(@ret_list, "make_nonnull_$1(&ret->$2, $2);");
|
2011-04-22 16:54:51 +00:00
|
|
|
push(@free_list,
|
2011-04-22 22:19:14 +00:00
|
|
|
" if ($2)\n" .
|
|
|
|
" vir${type_name}Free($2);");
|
|
|
|
$single_ret_var = $2;
|
2011-04-22 16:54:51 +00:00
|
|
|
$single_ret_by_ref = 0;
|
|
|
|
$single_ret_check = " == NULL";
|
2011-04-22 20:48:25 +00:00
|
|
|
} elsif ($ret_member =~ m/int (\S+)<(\S+)>;/) {
|
|
|
|
push(@vars_list, "int len");
|
|
|
|
push(@ret_list, "ret->$1.$1_len = len;");
|
2011-04-23 06:35:03 +00:00
|
|
|
push(@free_list_on_error, "VIR_FREE(ret->$1.$1_val);");
|
2011-04-22 20:48:25 +00:00
|
|
|
$single_ret_var = "len";
|
|
|
|
$single_ret_by_ref = 0;
|
|
|
|
$single_ret_check = " < 0";
|
|
|
|
$single_ret_as_list = 1;
|
|
|
|
$single_ret_list_name = $1;
|
|
|
|
$single_ret_list_max_var = "max$1";
|
|
|
|
$single_ret_list_max_define = $2;
|
|
|
|
|
|
|
|
my $conn = shift(@args_list);
|
|
|
|
unshift(@args_list, "ret->$1.$1_val");
|
|
|
|
unshift(@args_list, $conn);
|
2011-04-22 15:09:33 +00:00
|
|
|
} elsif ($ret_member =~ m/int (\S+);/) {
|
|
|
|
push(@vars_list, "int $1");
|
|
|
|
push(@ret_list, "ret->$1 = $1;");
|
|
|
|
$single_ret_var = $1;
|
|
|
|
|
|
|
|
if ($calls{$_}->{ProcName} eq "DomainGetAutostart" or
|
|
|
|
$calls{$_}->{ProcName} eq "NetworkGetAutostart" or
|
|
|
|
$calls{$_}->{ProcName} eq "StoragePoolGetAutostart") {
|
|
|
|
$single_ret_by_ref = 1;
|
|
|
|
} else {
|
|
|
|
$single_ret_by_ref = 0;
|
2011-04-23 06:19:46 +00:00
|
|
|
|
|
|
|
if ($calls{$_}->{ProcName} eq "CPUCompare") {
|
|
|
|
$single_ret_check = " == VIR_CPU_COMPARE_ERROR";
|
|
|
|
} else {
|
|
|
|
$single_ret_check = " < 0";
|
|
|
|
}
|
2011-04-22 15:09:33 +00:00
|
|
|
}
|
2011-04-22 20:48:25 +00:00
|
|
|
} elsif ($ret_member =~ m/hyper (\S+)<(\S+)>;/) {
|
|
|
|
push(@vars_list, "int len");
|
|
|
|
push(@ret_list, "ret->$1.$1_len = len;");
|
2011-04-23 06:35:03 +00:00
|
|
|
push(@free_list_on_error, "VIR_FREE(ret->$1.$1_val);");
|
2011-04-22 20:48:25 +00:00
|
|
|
$single_ret_var = "len";
|
|
|
|
$single_ret_by_ref = 0;
|
|
|
|
$single_ret_as_list = 1;
|
|
|
|
$single_ret_list_name = $1;
|
|
|
|
$single_ret_list_max_define = $2;
|
|
|
|
|
|
|
|
my $conn = shift(@args_list);
|
|
|
|
|
|
|
|
if ($calls{$_}->{ProcName} eq "NodeGetCellsFreeMemory") {
|
|
|
|
$single_ret_check = " <= 0";
|
|
|
|
$single_ret_list_max_var = "maxCells";
|
|
|
|
unshift(@args_list, "(unsigned long long *)ret->$1.$1_val");
|
|
|
|
} else {
|
|
|
|
$single_ret_check = " < 0";
|
|
|
|
$single_ret_list_max_var = "max$1";
|
|
|
|
unshift(@args_list, "ret->$1.$1_val");
|
|
|
|
}
|
|
|
|
|
|
|
|
unshift(@args_list, $conn);
|
2011-04-22 15:09:33 +00:00
|
|
|
} elsif ($ret_member =~ m/hyper (\S+);/) {
|
|
|
|
push(@vars_list, "unsigned long $1");
|
|
|
|
push(@ret_list, "ret->$1 = $1;");
|
|
|
|
$single_ret_var = $1;
|
|
|
|
|
2011-04-22 16:54:51 +00:00
|
|
|
if ($calls{$_}->{ProcName} eq "DomainGetMaxMemory" or
|
|
|
|
$calls{$_}->{ProcName} eq "NodeGetFreeMemory") {
|
2011-04-22 15:09:33 +00:00
|
|
|
$single_ret_by_ref = 0;
|
|
|
|
$single_ret_check = " == 0";
|
|
|
|
} else {
|
|
|
|
$single_ret_by_ref = 1;
|
|
|
|
}
|
2011-04-23 07:36:33 +00:00
|
|
|
} else {
|
|
|
|
die "unhandled type for return value: $ret_member";
|
2011-04-22 15:09:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-23 07:40:14 +00:00
|
|
|
# select struct type for multi-return-value functions
|
2011-04-23 07:36:33 +00:00
|
|
|
if ($multi_ret) {
|
|
|
|
if (! @args_list) {
|
|
|
|
push(@args_list, "conn");
|
|
|
|
}
|
|
|
|
|
|
|
|
my $struct_name = $calls{$_}->{ProcName};
|
|
|
|
$struct_name =~ s/Get//;
|
|
|
|
|
|
|
|
if ($calls{$_}->{ProcName} eq "DomainGetBlockInfo") {
|
|
|
|
my $flags = pop(@args_list);
|
|
|
|
push(@args_list, "&tmp");
|
|
|
|
push(@args_list, $flags);
|
|
|
|
} elsif ($calls{$_}->{ProcName} eq "DomainBlockStats") {
|
|
|
|
$struct_name .= "Struct";
|
|
|
|
push(@args_list, "&tmp");
|
|
|
|
push(@args_list, "sizeof tmp");
|
|
|
|
} elsif ($calls{$_}->{ProcName} eq "DomainInterfaceStats") {
|
|
|
|
$struct_name .= "Struct";
|
|
|
|
push(@args_list, "&tmp");
|
|
|
|
push(@args_list, "sizeof tmp");
|
|
|
|
} else {
|
|
|
|
push(@args_list, "&tmp");
|
|
|
|
}
|
|
|
|
|
|
|
|
push(@vars_list, "vir$struct_name tmp");
|
|
|
|
}
|
|
|
|
|
2011-04-23 07:40:14 +00:00
|
|
|
# print functions signature
|
|
|
|
print "\n";
|
|
|
|
print "static int\n";
|
|
|
|
print "${structprefix}Dispatch$calls{$_}->{ProcName}(\n";
|
|
|
|
print " struct qemud_server *server ATTRIBUTE_UNUSED,\n";
|
|
|
|
print " struct qemud_client *client ATTRIBUTE_UNUSED,\n";
|
|
|
|
print " virConnectPtr conn,\n";
|
|
|
|
print " remote_message_header *hdr ATTRIBUTE_UNUSED,\n";
|
|
|
|
print " remote_error *rerr,\n";
|
|
|
|
print " $calls{$_}->{args} *args";
|
|
|
|
|
|
|
|
if ($calls{$_}->{args} eq "void") {
|
|
|
|
print " ATTRIBUTE_UNUSED"
|
|
|
|
}
|
|
|
|
|
|
|
|
print ",\n";
|
|
|
|
print " $calls{$_}->{ret} *ret";
|
|
|
|
|
|
|
|
if ($calls{$_}->{ret} eq "void") {
|
|
|
|
print " ATTRIBUTE_UNUSED"
|
|
|
|
}
|
|
|
|
|
|
|
|
print ")\n";
|
|
|
|
|
|
|
|
# print function body
|
|
|
|
print "{\n";
|
|
|
|
print " int rv = -1;\n";
|
|
|
|
|
2011-04-22 18:35:34 +00:00
|
|
|
foreach my $var (@vars_list) {
|
|
|
|
print " $var;\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
print "\n";
|
|
|
|
print " if (!conn) {\n";
|
|
|
|
print " virNetError(VIR_ERR_INTERNAL_ERROR, \"%s\", _(\"connection not open\"));\n";
|
|
|
|
print " goto cleanup;\n";
|
|
|
|
print " }\n";
|
|
|
|
print "\n";
|
|
|
|
|
2011-04-22 20:48:25 +00:00
|
|
|
if ($single_ret_as_list) {
|
|
|
|
print " if (args->$single_ret_list_max_var > $single_ret_list_max_define) {\n";
|
|
|
|
print " virNetError(VIR_ERR_INTERNAL_ERROR,\n";
|
|
|
|
print " \"%s\", _(\"max$single_ret_list_name > $single_ret_list_max_define\"));\n";
|
|
|
|
print " goto cleanup;\n";
|
|
|
|
print " }\n";
|
|
|
|
print "\n";
|
|
|
|
}
|
|
|
|
|
2011-04-22 18:35:34 +00:00
|
|
|
print join("\n", @getters_list);
|
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
if (@getters_list) {
|
|
|
|
print "\n";
|
|
|
|
}
|
2011-04-22 18:35:34 +00:00
|
|
|
|
2011-04-22 18:31:05 +00:00
|
|
|
foreach my $optional (@optionals_list) {
|
|
|
|
print " $optional = args->$optional ? *args->$optional : NULL;\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (@optionals_list) {
|
|
|
|
print "\n";
|
|
|
|
}
|
|
|
|
|
2011-04-22 18:35:34 +00:00
|
|
|
if ($calls{$_}->{ret} eq "void") {
|
|
|
|
print " if (vir$calls{$_}->{ProcName}(";
|
|
|
|
print join(', ', @args_list);
|
|
|
|
print ") < 0)\n";
|
|
|
|
print " goto cleanup;\n";
|
|
|
|
print "\n";
|
2011-04-23 07:36:33 +00:00
|
|
|
} elsif (!$multi_ret) {
|
2011-04-22 15:09:33 +00:00
|
|
|
my $prefix = "";
|
|
|
|
my $proc_name = $calls{$_}->{ProcName};
|
|
|
|
|
|
|
|
if (! @args_list) {
|
|
|
|
push(@args_list, "conn");
|
2011-04-22 16:54:51 +00:00
|
|
|
|
|
|
|
if ($calls{$_}->{ProcName} ne "NodeGetFreeMemory") {
|
|
|
|
$prefix = "Connect"
|
|
|
|
}
|
2011-04-22 15:09:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($calls{$_}->{ProcName} eq "GetSysinfo" or
|
2011-04-22 18:31:05 +00:00
|
|
|
$calls{$_}->{ProcName} eq "GetMaxVcpus" or
|
2011-04-22 15:09:33 +00:00
|
|
|
$calls{$_}->{ProcName} eq "DomainXMLFromNative" or
|
2011-04-22 18:31:05 +00:00
|
|
|
$calls{$_}->{ProcName} eq "DomainXMLToNative" or
|
2011-04-22 20:48:25 +00:00
|
|
|
$calls{$_}->{ProcName} eq "FindStoragePoolSources" or
|
|
|
|
$calls{$_}->{ProcName} =~ m/^List/) {
|
2011-04-22 15:09:33 +00:00
|
|
|
$prefix = "Connect"
|
|
|
|
} elsif ($calls{$_}->{ProcName} eq "SupportsFeature") {
|
|
|
|
$prefix = "Drv"
|
2011-04-22 22:19:14 +00:00
|
|
|
} elsif ($calls{$_}->{ProcName} =~ m/^(\S+)DumpXML$/) {
|
|
|
|
$proc_name = "${1}GetXMLDesc"
|
2011-04-23 06:19:46 +00:00
|
|
|
} elsif ($calls{$_}->{ProcName} eq "CPUBaseline") {
|
|
|
|
$proc_name = "ConnectBaselineCPU"
|
|
|
|
} elsif ($calls{$_}->{ProcName} eq "CPUCompare") {
|
|
|
|
$proc_name = "ConnectCompareCPU"
|
2011-04-22 15:09:33 +00:00
|
|
|
}
|
|
|
|
|
2011-04-22 20:48:25 +00:00
|
|
|
if ($single_ret_as_list) {
|
|
|
|
print " /* Allocate return buffer. */\n";
|
|
|
|
print " if (VIR_ALLOC_N(ret->$single_ret_list_name.${single_ret_list_name}_val," .
|
|
|
|
" args->$single_ret_list_max_var) < 0) {\n";
|
|
|
|
print " virReportOOMError();\n";
|
|
|
|
print " goto cleanup;\n";
|
|
|
|
print " }\n";
|
|
|
|
print "\n";
|
|
|
|
}
|
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
if ($single_ret_by_ref) {
|
|
|
|
print " if (vir$prefix$proc_name(";
|
|
|
|
print join(', ', @args_list);
|
|
|
|
print ", &$single_ret_var) < 0)\n";
|
|
|
|
} else {
|
|
|
|
print " if (($single_ret_var = vir$prefix$proc_name(";
|
|
|
|
print join(', ', @args_list);
|
|
|
|
print "))$single_ret_check)\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
print " goto cleanup;\n";
|
|
|
|
print "\n";
|
|
|
|
|
|
|
|
if (@ret_list) {
|
|
|
|
print " ";
|
|
|
|
}
|
|
|
|
|
2011-04-23 07:36:33 +00:00
|
|
|
print join("\n ", @ret_list);
|
|
|
|
print "\n";
|
|
|
|
} else {
|
|
|
|
print " if (vir$calls{$_}->{ProcName}(";
|
|
|
|
print join(', ', @args_list);
|
|
|
|
print ") < 0)\n";
|
|
|
|
|
|
|
|
print " goto cleanup;\n";
|
|
|
|
print "\n";
|
|
|
|
|
|
|
|
if (@ret_list) {
|
|
|
|
print " ";
|
|
|
|
}
|
|
|
|
|
|
|
|
print join("\n ", @ret_list);
|
2011-04-22 15:09:33 +00:00
|
|
|
print "\n";
|
2011-04-22 18:35:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
print " rv = 0;\n";
|
|
|
|
print "\n";
|
|
|
|
print "cleanup:\n";
|
2011-04-23 06:35:03 +00:00
|
|
|
print " if (rv < 0)";
|
|
|
|
|
|
|
|
if (scalar(@free_list_on_error) > 1) {
|
|
|
|
print " {";
|
|
|
|
}
|
|
|
|
|
|
|
|
print "\n ";
|
|
|
|
print join("\n ", @free_list_on_error);
|
|
|
|
print "\n";
|
|
|
|
|
|
|
|
if (scalar(@free_list_on_error) > 1) {
|
|
|
|
print " }\n";
|
|
|
|
}
|
2011-04-22 18:35:34 +00:00
|
|
|
|
|
|
|
print join("\n", @free_list);
|
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
if (@free_list) {
|
|
|
|
print "\n";
|
|
|
|
}
|
|
|
|
|
2011-04-22 18:35:34 +00:00
|
|
|
print " return rv;\n";
|
|
|
|
print "}\n";
|
|
|
|
}
|
|
|
|
}
|
2011-04-23 10:53:57 +00:00
|
|
|
|
|
|
|
# Bodies for client functions ("remote_client_bodies.c").
|
|
|
|
elsif ($opt_k) {
|
|
|
|
# list of functions that currently are not generatable
|
|
|
|
my @ungeneratable;
|
|
|
|
|
|
|
|
if ($structprefix eq "remote") {
|
|
|
|
@ungeneratable = ("Close",
|
|
|
|
"DomainEventsDeregisterAny",
|
|
|
|
"DomainEventsRegisterAny",
|
|
|
|
"DomainMigratePrepareTunnel",
|
|
|
|
"DomainOpenConsole",
|
|
|
|
"DomainPinVcpu",
|
|
|
|
"DomainSetSchedulerParameters",
|
|
|
|
"DomainSetMemoryParameters",
|
|
|
|
"DomainSetBlkioParameters",
|
|
|
|
"Open",
|
|
|
|
"StorageVolUpload",
|
|
|
|
"StorageVolDownload",
|
|
|
|
|
|
|
|
"AuthList",
|
|
|
|
"AuthSaslInit",
|
|
|
|
"AuthSaslStart",
|
|
|
|
"AuthSaslStep",
|
|
|
|
"AuthPolkit",
|
|
|
|
|
|
|
|
"CPUBaseline",
|
|
|
|
"CPUCompare",
|
|
|
|
"DomainBlockStats",
|
|
|
|
"DomainCreate",
|
|
|
|
"DomainCreateXML",
|
|
|
|
"DomainDefineXML",
|
|
|
|
"DomainDestroy",
|
|
|
|
"DomainDumpXML",
|
|
|
|
"DomainGetAutostart",
|
|
|
|
"DomainGetBlockInfo",
|
|
|
|
"DomainGetInfo",
|
|
|
|
"StoragePoolLookupByUUID",
|
|
|
|
"StoragePoolNumOfVolumes",
|
|
|
|
"NodeDeviceCreateXML",
|
|
|
|
"DomainGetJobInfo",
|
|
|
|
"DomainGetMaxMemory",
|
|
|
|
"DomainGetOSType",
|
|
|
|
"DomainGetVcpusFlags",
|
|
|
|
"HasCurrentSnapshot",
|
|
|
|
"DomainInterfaceStats",
|
|
|
|
"DomainIsActive",
|
|
|
|
"DomainIsPersistent",
|
|
|
|
"DomainIsUpdated",
|
|
|
|
"DomainLookupByID",
|
|
|
|
"DomainLookupByName",
|
|
|
|
"DomainLookupByUIID",
|
|
|
|
"DomainMigrateFinish",
|
|
|
|
"DomainGetMaxVcpus",
|
|
|
|
"DomainHasCurrentSnapshot",
|
|
|
|
"NWFilterDefineXML",
|
|
|
|
"NumOfStoragePools",
|
|
|
|
"NWFilterLookupByName",
|
|
|
|
"NWFilterLookupByUUID",
|
|
|
|
"SecretLookupByUUID",
|
|
|
|
"SecretLookupByUsage",
|
|
|
|
"StoragePoolCreateXML",
|
|
|
|
"StoragePoolIsActive",
|
|
|
|
"DomainHasManagedSaveImage",
|
|
|
|
"DomainLookupByUUID",
|
|
|
|
"DomainMigratePerform",
|
|
|
|
"DomainMigrateFinish2",
|
|
|
|
"DomainSnapshotCreateXML",
|
|
|
|
"DomainSnapshotDumpXML",
|
|
|
|
"DomainSnapshotNum",
|
|
|
|
"DomainSnapshotCurrent",
|
|
|
|
"DomainSnapshotListNames",
|
|
|
|
"GetCapabilities",
|
|
|
|
"GetHostname",
|
|
|
|
"GetLibVersion",
|
|
|
|
"GetMaxVcpus",
|
|
|
|
"DomainSnapshotLookupByName",
|
|
|
|
"DomainXMLFromNative",
|
|
|
|
"FindStoragePoolSources",
|
|
|
|
"GetSysinfo",
|
|
|
|
"GetVersion",
|
|
|
|
"GetLibVersion",
|
|
|
|
"InterfaceDefineXML",
|
|
|
|
"InterfaceGetXMLDesc",
|
|
|
|
"InterfaceLookupByName",
|
|
|
|
"IsSecure",
|
|
|
|
"ListDefinedDomains",
|
|
|
|
"ListDefinedInterfaces",
|
|
|
|
"ListNWFilters",
|
|
|
|
"NetworkCreateXML",
|
|
|
|
"SupportsFeature",
|
|
|
|
"StorageVolLookupByPath",
|
|
|
|
"StorageVolGetInfo",
|
|
|
|
"StorageVolCreateXML",
|
|
|
|
"StorageVolLookupByName",
|
|
|
|
"StorageVolLookupByKey",
|
|
|
|
"StoragePoolIsPersistent",
|
|
|
|
"StoragePoolGetInfo",
|
|
|
|
"StorageVolGetPath",
|
|
|
|
"StorageVolCreateXMLFrom",
|
|
|
|
"StoragePoolLookupByName",
|
|
|
|
"SecretGetXMLDesc",
|
|
|
|
"NWFilterGetXMLDesc",
|
|
|
|
"NumOfNWFilters",
|
|
|
|
"NumOfInterfaces",
|
|
|
|
"NumOfDomains",
|
|
|
|
"NumOfDefinedStoragePools",
|
|
|
|
"NodeListDevices",
|
|
|
|
"NodeGetCellsFreeMemory",
|
|
|
|
"NodeDeviceDumpXML",
|
|
|
|
"NetworkIsActive",
|
|
|
|
"ListDefinedNetworks",
|
|
|
|
"DomainXMLToNative",
|
|
|
|
"StorageVolDumpXML",
|
|
|
|
"StoragePoolListVolumes",
|
|
|
|
"StoragePoolDumpXML",
|
|
|
|
"SecretDefineXML",
|
|
|
|
"NumOfDefinedNetworks",
|
|
|
|
"InterfaceIsActive",
|
|
|
|
"ListDomains",
|
|
|
|
"ListStoragePools",
|
|
|
|
"NetworkDumpXML",
|
|
|
|
"NetworkGetAutostart",
|
|
|
|
"NetworkGetBridgeName",
|
|
|
|
"StoragePoolLookupByVolume",
|
|
|
|
"StoragePoolGetAutostart",
|
|
|
|
"SecretSetValue",
|
|
|
|
"NumOfDefinedInterfaces",
|
|
|
|
"StoragePoolDefineXML",
|
|
|
|
"NodeNumOfDevices",
|
|
|
|
"NodeGetInfo",
|
|
|
|
"GetURI",
|
|
|
|
"InterfaceLookupByMACString",
|
|
|
|
"ListInterfaces",
|
|
|
|
"NetworkDefineXML",
|
|
|
|
"NetworkLookupByName",
|
|
|
|
"ListDefinedStoragePools",
|
|
|
|
"NetworkIsPersistent",
|
|
|
|
"NodeDeviceDettach",
|
|
|
|
"NodeDeviceLookupByName",
|
|
|
|
"NodeGetFreeMemory",
|
|
|
|
"NumOfDefinedDomains",
|
|
|
|
"ListNetworks",
|
|
|
|
"NodeDeviceListCaps",
|
|
|
|
"NodeDeviceReset",
|
|
|
|
"NumOfNetworks",
|
|
|
|
"NetworkLookupByUUID",
|
|
|
|
"NodeDeviceNumOfCaps",
|
|
|
|
"NumOfSecrets",
|
|
|
|
"NodeDeviceReAttach",
|
|
|
|
"ListSecrets",
|
|
|
|
|
|
|
|
"DomainBlockPeek",
|
|
|
|
"DomainCreateWithFlags",
|
|
|
|
"DomainEventsDeregister",
|
|
|
|
"DomainEventsRegister",
|
|
|
|
"DomainGetBlkioParameters",
|
|
|
|
"DomainGetMemoryParameters",
|
|
|
|
"DomainGetSchedulerParameters",
|
|
|
|
"DomainGetSchedulerType",
|
|
|
|
"DomainGetSecurityLabel",
|
|
|
|
"DomainGetVcpus",
|
|
|
|
"DomainMemoryPeek",
|
|
|
|
"DomainMemoryStats",
|
|
|
|
"DomainMigratePrepare",
|
|
|
|
"DomainMigratePrepare2",
|
|
|
|
"GetType",
|
|
|
|
"NodeDeviceGetParent",
|
|
|
|
"NodeGetSecurityModel",
|
|
|
|
"SecretGetValue");
|
|
|
|
} elsif ($structprefix eq "qemu") {
|
|
|
|
@ungeneratable = ("MonitorCommand");
|
|
|
|
}
|
|
|
|
|
|
|
|
my %ug = map { $_ => 1 } @ungeneratable;
|
|
|
|
my @keys = sort (keys %calls);
|
|
|
|
|
|
|
|
foreach (@keys) {
|
|
|
|
my $call = $calls{$_};
|
|
|
|
|
|
|
|
# skip things which are REMOTE_MESSAGE
|
|
|
|
next if $call->{msg};
|
|
|
|
|
|
|
|
if (exists($ug{$call->{ProcName}})) {
|
|
|
|
print "\n/* ${structprefix}Dispatch$call->{ProcName} has to " .
|
|
|
|
"be implemented manually */\n";
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
my @args_list = ();
|
|
|
|
my @vars_list = ();
|
|
|
|
my @setters_list = ();
|
|
|
|
my $priv_src = "conn";
|
|
|
|
my $priv_name = "privateData";
|
|
|
|
my $args = "&args";
|
|
|
|
my $ret = "&ret";
|
|
|
|
|
|
|
|
if ($call->{args} eq "void") {
|
|
|
|
$args = "NULL";
|
|
|
|
} else {
|
|
|
|
push(@vars_list, "$call->{args} args");
|
|
|
|
|
|
|
|
my $is_first_arg = 1;
|
|
|
|
my $has_node_device = 0;
|
|
|
|
|
|
|
|
# node device is special
|
|
|
|
if ($call->{args} =~ m/^remote_node_device_/) {
|
|
|
|
$has_node_device = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach my $args_member (@{$call->{args_members}}) {
|
|
|
|
if ($args_member =~ m/^remote_nonnull_string name;/ and $has_node_device) {
|
|
|
|
$priv_src = "dev->conn";
|
|
|
|
$priv_name = "devMonPrivateData";
|
|
|
|
push(@args_list, "virNodeDevicePtr dev");
|
|
|
|
push(@setters_list, "args.name = dev->name;");
|
|
|
|
} elsif ($args_member =~ m/^remote_nonnull_(domain|network|storage_pool|storage_vol|interface|secret|nwfilter|domain_snapshot) (\S+);/) {
|
|
|
|
my $name = $1;
|
|
|
|
my $type_name = name_to_ProcName($name);
|
|
|
|
|
|
|
|
if ($is_first_arg) {
|
|
|
|
if ($name eq "domain_snapshot") {
|
|
|
|
$priv_src = "$2->domain->conn";
|
|
|
|
} else {
|
|
|
|
$priv_src = "$2->conn";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($name =~ m/^storage_/) {
|
|
|
|
$priv_name = "storagePrivateData";
|
|
|
|
} elsif (!($name =~ m/^domain/)) {
|
|
|
|
$priv_name = "${name}PrivateData";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
push(@args_list, "vir${type_name}Ptr $2");
|
|
|
|
push(@setters_list, "make_nonnull_$1(&args.$2, $2);");
|
|
|
|
} elsif ($args_member =~ m/^remote_nonnull_string (\S+);/) {
|
|
|
|
push(@args_list, "const char *$1");
|
|
|
|
push(@setters_list, "args.$1 = (char *)$1;");
|
|
|
|
} elsif ($args_member =~ m/(\S+)<\S+>;/) {
|
|
|
|
# ignored for now
|
|
|
|
} elsif ($args_member =~ m/^(.*) (\S+);/) {
|
|
|
|
my $type_name = $1;
|
|
|
|
my $arg_name = $2;
|
|
|
|
|
|
|
|
$type_name =~ s/hyper/long/;
|
|
|
|
$type_name =~ s/^unsigned$/unsigned int/;
|
|
|
|
$type_name =~ s/u_int/unsigned int/;
|
|
|
|
|
|
|
|
if ($type_name eq "int") {
|
|
|
|
# fix bad decisions in the xdr protocol
|
|
|
|
if ($arg_name eq "flags" and
|
|
|
|
$call->{ProcName} ne "DomainCoreDump") {
|
|
|
|
$type_name = "unsigned int";
|
|
|
|
} elsif ($arg_name eq "nvcpus" and
|
|
|
|
$call->{ProcName} eq "DomainSetVcpus") {
|
|
|
|
$type_name = "unsigned int";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($call->{ProcName} eq "DomainMigrateSetMaxDowntime" and
|
|
|
|
$arg_name eq "downtime") {
|
|
|
|
$type_name = "unsigned long long";
|
|
|
|
}
|
|
|
|
|
|
|
|
push(@args_list, "$type_name $arg_name");
|
|
|
|
push(@setters_list, "args.$arg_name = $arg_name;");
|
|
|
|
} elsif ($args_member =~ m/^\/*/) {
|
|
|
|
# ignore comments
|
|
|
|
} else {
|
|
|
|
die "unhandled type for argument value: $args_member";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($is_first_arg and $priv_src eq "conn") {
|
|
|
|
unshift(@args_list, "virConnectPtr conn");
|
|
|
|
}
|
|
|
|
|
|
|
|
$is_first_arg = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($call->{ret} eq "void") {
|
|
|
|
$ret = "NULL";
|
|
|
|
} else {
|
|
|
|
push(@vars_list, "$call->{ret} ret");
|
|
|
|
}
|
|
|
|
|
|
|
|
# print function
|
|
|
|
print "\n";
|
|
|
|
print "static int\n";
|
|
|
|
print "remote$call->{ProcName}(";
|
|
|
|
|
|
|
|
print join(", ", @args_list);
|
|
|
|
|
|
|
|
print ")\n";
|
|
|
|
print "{\n";
|
|
|
|
print " int rv = -1;\n";
|
|
|
|
print " struct private_data *priv = $priv_src->$priv_name;\n";
|
|
|
|
|
|
|
|
foreach my $var (@vars_list) {
|
|
|
|
print " $var;\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
print "\n";
|
|
|
|
print " remoteDriverLock(priv);\n";
|
|
|
|
print "\n";
|
|
|
|
|
|
|
|
if (@setters_list) {
|
|
|
|
print " ";
|
|
|
|
}
|
|
|
|
|
|
|
|
print join("\n ", @setters_list);
|
|
|
|
|
|
|
|
if (@setters_list) {
|
|
|
|
print "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
print "\n";
|
|
|
|
print " if (call($priv_src, priv, 0, ${procprefix}_PROC_$call->{UC_NAME},\n";
|
|
|
|
print " (xdrproc_t)xdr_$call->{args}, (char *)$args,\n";
|
|
|
|
print " (xdrproc_t)xdr_$call->{ret}, (char *)$ret) == -1)\n";
|
|
|
|
print " goto done;\n";
|
|
|
|
print "\n";
|
|
|
|
print " rv = 0;\n";
|
|
|
|
print "\n";
|
|
|
|
print "done:\n";
|
|
|
|
print " remoteDriverUnlock(priv);\n";
|
|
|
|
print " return rv;\n";
|
|
|
|
print "}\n";
|
|
|
|
}
|
|
|
|
}
|