提交 b9f8610a 编写于 作者: R Richard W.M. Jones

Mon Jun 11 12:45:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>

	* qemud/remote.c, qemud/remote_generate_stubs.pl,
	  qemud/remote_dispatch_localvars.h,
	  qemud/remote_dispatch_proc_switch.h,
	  qemud/remote_dispatch_prototypes.h: Server side of
	  the remote patch, deals with call dispatch.
上级 b7c42619
Mon Jun 11 12:45:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
* qemud/remote.c, qemud/remote_generate_stubs.pl,
qemud/remote_dispatch_localvars.h,
qemud/remote_dispatch_proc_switch.h,
qemud/remote_dispatch_prototypes.h: Server side of
the remote patch, deals with call dispatch.
Mon Jun 11 12:41:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
* src/remote_internal.c, src/remote_internal.h,
......
此差异已折叠。
/* Automatically generated by remote_generate_stubs.pl.
* Do not edit this file. Any changes you make will be lost.
*/
remote_network_lookup_by_name_args lv_remote_network_lookup_by_name_args;
remote_network_lookup_by_name_ret lv_remote_network_lookup_by_name_ret;
remote_domain_lookup_by_uuid_args lv_remote_domain_lookup_by_uuid_args;
remote_domain_lookup_by_uuid_ret lv_remote_domain_lookup_by_uuid_ret;
remote_num_of_defined_domains_ret lv_remote_num_of_defined_domains_ret;
remote_domain_detach_device_args lv_remote_domain_detach_device_args;
remote_domain_save_args lv_remote_domain_save_args;
remote_domain_shutdown_args lv_remote_domain_shutdown_args;
remote_list_defined_domains_args lv_remote_list_defined_domains_args;
remote_list_defined_domains_ret lv_remote_list_defined_domains_ret;
remote_get_capabilities_ret lv_remote_get_capabilities_ret;
remote_domain_set_max_memory_args lv_remote_domain_set_max_memory_args;
remote_domain_undefine_args lv_remote_domain_undefine_args;
remote_domain_get_os_type_args lv_remote_domain_get_os_type_args;
remote_domain_get_os_type_ret lv_remote_domain_get_os_type_ret;
remote_domain_get_autostart_args lv_remote_domain_get_autostart_args;
remote_domain_get_autostart_ret lv_remote_domain_get_autostart_ret;
remote_domain_set_vcpus_args lv_remote_domain_set_vcpus_args;
remote_network_undefine_args lv_remote_network_undefine_args;
remote_domain_create_args lv_remote_domain_create_args;
remote_domain_suspend_args lv_remote_domain_suspend_args;
remote_get_version_ret lv_remote_get_version_ret;
remote_network_destroy_args lv_remote_network_destroy_args;
remote_network_set_autostart_args lv_remote_network_set_autostart_args;
remote_network_get_autostart_args lv_remote_network_get_autostart_args;
remote_network_get_autostart_ret lv_remote_network_get_autostart_ret;
remote_domain_pin_vcpu_args lv_remote_domain_pin_vcpu_args;
remote_list_defined_networks_args lv_remote_list_defined_networks_args;
remote_list_defined_networks_ret lv_remote_list_defined_networks_ret;
remote_network_create_xml_args lv_remote_network_create_xml_args;
remote_network_create_xml_ret lv_remote_network_create_xml_ret;
remote_domain_core_dump_args lv_remote_domain_core_dump_args;
remote_open_args lv_remote_open_args;
remote_list_domains_args lv_remote_list_domains_args;
remote_list_domains_ret lv_remote_list_domains_ret;
remote_network_define_xml_args lv_remote_network_define_xml_args;
remote_network_define_xml_ret lv_remote_network_define_xml_ret;
remote_domain_get_max_memory_args lv_remote_domain_get_max_memory_args;
remote_domain_get_max_memory_ret lv_remote_domain_get_max_memory_ret;
remote_get_type_ret lv_remote_get_type_ret;
remote_num_of_domains_ret lv_remote_num_of_domains_ret;
remote_list_networks_args lv_remote_list_networks_args;
remote_list_networks_ret lv_remote_list_networks_ret;
remote_network_dump_xml_args lv_remote_network_dump_xml_args;
remote_network_dump_xml_ret lv_remote_network_dump_xml_ret;
remote_domain_set_autostart_args lv_remote_domain_set_autostart_args;
remote_domain_reboot_args lv_remote_domain_reboot_args;
remote_domain_set_memory_args lv_remote_domain_set_memory_args;
remote_domain_create_linux_args lv_remote_domain_create_linux_args;
remote_domain_create_linux_ret lv_remote_domain_create_linux_ret;
remote_domain_attach_device_args lv_remote_domain_attach_device_args;
remote_domain_lookup_by_id_args lv_remote_domain_lookup_by_id_args;
remote_domain_lookup_by_id_ret lv_remote_domain_lookup_by_id_ret;
remote_num_of_networks_ret lv_remote_num_of_networks_ret;
remote_domain_restore_args lv_remote_domain_restore_args;
remote_domain_get_max_vcpus_args lv_remote_domain_get_max_vcpus_args;
remote_domain_get_max_vcpus_ret lv_remote_domain_get_max_vcpus_ret;
remote_domain_get_info_args lv_remote_domain_get_info_args;
remote_domain_get_info_ret lv_remote_domain_get_info_ret;
remote_network_create_args lv_remote_network_create_args;
remote_num_of_defined_networks_ret lv_remote_num_of_defined_networks_ret;
remote_domain_lookup_by_name_args lv_remote_domain_lookup_by_name_args;
remote_domain_lookup_by_name_ret lv_remote_domain_lookup_by_name_ret;
remote_network_lookup_by_uuid_args lv_remote_network_lookup_by_uuid_args;
remote_network_lookup_by_uuid_ret lv_remote_network_lookup_by_uuid_ret;
remote_domain_resume_args lv_remote_domain_resume_args;
remote_network_get_bridge_name_args lv_remote_network_get_bridge_name_args;
remote_network_get_bridge_name_ret lv_remote_network_get_bridge_name_ret;
remote_domain_destroy_args lv_remote_domain_destroy_args;
remote_domain_define_xml_args lv_remote_domain_define_xml_args;
remote_domain_define_xml_ret lv_remote_domain_define_xml_ret;
remote_domain_get_vcpus_args lv_remote_domain_get_vcpus_args;
remote_domain_get_vcpus_ret lv_remote_domain_get_vcpus_ret;
remote_domain_dump_xml_args lv_remote_domain_dump_xml_args;
remote_domain_dump_xml_ret lv_remote_domain_dump_xml_ret;
remote_get_max_vcpus_args lv_remote_get_max_vcpus_args;
remote_get_max_vcpus_ret lv_remote_get_max_vcpus_ret;
remote_node_get_info_ret lv_remote_node_get_info_ret;
此差异已折叠。
/* Automatically generated by remote_generate_stubs.pl.
* Do not edit this file. Any changes you make will be lost.
*/
static int remoteDispatchClose (struct qemud_client *client, remote_message_header *req, void *args, void *ret);
static int remoteDispatchDomainAttachDevice (struct qemud_client *client, remote_message_header *req, remote_domain_attach_device_args *args, void *ret);
static int remoteDispatchDomainCoreDump (struct qemud_client *client, remote_message_header *req, remote_domain_core_dump_args *args, void *ret);
static int remoteDispatchDomainCreate (struct qemud_client *client, remote_message_header *req, remote_domain_create_args *args, void *ret);
static int remoteDispatchDomainCreateLinux (struct qemud_client *client, remote_message_header *req, remote_domain_create_linux_args *args, remote_domain_create_linux_ret *ret);
static int remoteDispatchDomainDefineXml (struct qemud_client *client, remote_message_header *req, remote_domain_define_xml_args *args, remote_domain_define_xml_ret *ret);
static int remoteDispatchDomainDestroy (struct qemud_client *client, remote_message_header *req, remote_domain_destroy_args *args, void *ret);
static int remoteDispatchDomainDetachDevice (struct qemud_client *client, remote_message_header *req, remote_domain_detach_device_args *args, void *ret);
static int remoteDispatchDomainDumpXml (struct qemud_client *client, remote_message_header *req, remote_domain_dump_xml_args *args, remote_domain_dump_xml_ret *ret);
static int remoteDispatchDomainGetAutostart (struct qemud_client *client, remote_message_header *req, remote_domain_get_autostart_args *args, remote_domain_get_autostart_ret *ret);
static int remoteDispatchDomainGetInfo (struct qemud_client *client, remote_message_header *req, remote_domain_get_info_args *args, remote_domain_get_info_ret *ret);
static int remoteDispatchDomainGetMaxMemory (struct qemud_client *client, remote_message_header *req, remote_domain_get_max_memory_args *args, remote_domain_get_max_memory_ret *ret);
static int remoteDispatchDomainGetMaxVcpus (struct qemud_client *client, remote_message_header *req, remote_domain_get_max_vcpus_args *args, remote_domain_get_max_vcpus_ret *ret);
static int remoteDispatchDomainGetOsType (struct qemud_client *client, remote_message_header *req, remote_domain_get_os_type_args *args, remote_domain_get_os_type_ret *ret);
static int remoteDispatchDomainGetVcpus (struct qemud_client *client, remote_message_header *req, remote_domain_get_vcpus_args *args, remote_domain_get_vcpus_ret *ret);
static int remoteDispatchDomainLookupById (struct qemud_client *client, remote_message_header *req, remote_domain_lookup_by_id_args *args, remote_domain_lookup_by_id_ret *ret);
static int remoteDispatchDomainLookupByName (struct qemud_client *client, remote_message_header *req, remote_domain_lookup_by_name_args *args, remote_domain_lookup_by_name_ret *ret);
static int remoteDispatchDomainLookupByUuid (struct qemud_client *client, remote_message_header *req, remote_domain_lookup_by_uuid_args *args, remote_domain_lookup_by_uuid_ret *ret);
static int remoteDispatchDomainPinVcpu (struct qemud_client *client, remote_message_header *req, remote_domain_pin_vcpu_args *args, void *ret);
static int remoteDispatchDomainReboot (struct qemud_client *client, remote_message_header *req, remote_domain_reboot_args *args, void *ret);
static int remoteDispatchDomainRestore (struct qemud_client *client, remote_message_header *req, remote_domain_restore_args *args, void *ret);
static int remoteDispatchDomainResume (struct qemud_client *client, remote_message_header *req, remote_domain_resume_args *args, void *ret);
static int remoteDispatchDomainSave (struct qemud_client *client, remote_message_header *req, remote_domain_save_args *args, void *ret);
static int remoteDispatchDomainSetAutostart (struct qemud_client *client, remote_message_header *req, remote_domain_set_autostart_args *args, void *ret);
static int remoteDispatchDomainSetMaxMemory (struct qemud_client *client, remote_message_header *req, remote_domain_set_max_memory_args *args, void *ret);
static int remoteDispatchDomainSetMemory (struct qemud_client *client, remote_message_header *req, remote_domain_set_memory_args *args, void *ret);
static int remoteDispatchDomainSetVcpus (struct qemud_client *client, remote_message_header *req, remote_domain_set_vcpus_args *args, void *ret);
static int remoteDispatchDomainShutdown (struct qemud_client *client, remote_message_header *req, remote_domain_shutdown_args *args, void *ret);
static int remoteDispatchDomainSuspend (struct qemud_client *client, remote_message_header *req, remote_domain_suspend_args *args, void *ret);
static int remoteDispatchDomainUndefine (struct qemud_client *client, remote_message_header *req, remote_domain_undefine_args *args, void *ret);
static int remoteDispatchGetCapabilities (struct qemud_client *client, remote_message_header *req, void *args, remote_get_capabilities_ret *ret);
static int remoteDispatchGetMaxVcpus (struct qemud_client *client, remote_message_header *req, remote_get_max_vcpus_args *args, remote_get_max_vcpus_ret *ret);
static int remoteDispatchGetType (struct qemud_client *client, remote_message_header *req, void *args, remote_get_type_ret *ret);
static int remoteDispatchGetVersion (struct qemud_client *client, remote_message_header *req, void *args, remote_get_version_ret *ret);
static int remoteDispatchListDefinedDomains (struct qemud_client *client, remote_message_header *req, remote_list_defined_domains_args *args, remote_list_defined_domains_ret *ret);
static int remoteDispatchListDefinedNetworks (struct qemud_client *client, remote_message_header *req, remote_list_defined_networks_args *args, remote_list_defined_networks_ret *ret);
static int remoteDispatchListDomains (struct qemud_client *client, remote_message_header *req, remote_list_domains_args *args, remote_list_domains_ret *ret);
static int remoteDispatchListNetworks (struct qemud_client *client, remote_message_header *req, remote_list_networks_args *args, remote_list_networks_ret *ret);
static int remoteDispatchNetworkCreate (struct qemud_client *client, remote_message_header *req, remote_network_create_args *args, void *ret);
static int remoteDispatchNetworkCreateXml (struct qemud_client *client, remote_message_header *req, remote_network_create_xml_args *args, remote_network_create_xml_ret *ret);
static int remoteDispatchNetworkDefineXml (struct qemud_client *client, remote_message_header *req, remote_network_define_xml_args *args, remote_network_define_xml_ret *ret);
static int remoteDispatchNetworkDestroy (struct qemud_client *client, remote_message_header *req, remote_network_destroy_args *args, void *ret);
static int remoteDispatchNetworkDumpXml (struct qemud_client *client, remote_message_header *req, remote_network_dump_xml_args *args, remote_network_dump_xml_ret *ret);
static int remoteDispatchNetworkGetAutostart (struct qemud_client *client, remote_message_header *req, remote_network_get_autostart_args *args, remote_network_get_autostart_ret *ret);
static int remoteDispatchNetworkGetBridgeName (struct qemud_client *client, remote_message_header *req, remote_network_get_bridge_name_args *args, remote_network_get_bridge_name_ret *ret);
static int remoteDispatchNetworkLookupByName (struct qemud_client *client, remote_message_header *req, remote_network_lookup_by_name_args *args, remote_network_lookup_by_name_ret *ret);
static int remoteDispatchNetworkLookupByUuid (struct qemud_client *client, remote_message_header *req, remote_network_lookup_by_uuid_args *args, remote_network_lookup_by_uuid_ret *ret);
static int remoteDispatchNetworkSetAutostart (struct qemud_client *client, remote_message_header *req, remote_network_set_autostart_args *args, void *ret);
static int remoteDispatchNetworkUndefine (struct qemud_client *client, remote_message_header *req, remote_network_undefine_args *args, void *ret);
static int remoteDispatchNodeGetInfo (struct qemud_client *client, remote_message_header *req, void *args, remote_node_get_info_ret *ret);
static int remoteDispatchNumOfDefinedDomains (struct qemud_client *client, remote_message_header *req, void *args, remote_num_of_defined_domains_ret *ret);
static int remoteDispatchNumOfDefinedNetworks (struct qemud_client *client, remote_message_header *req, void *args, remote_num_of_defined_networks_ret *ret);
static int remoteDispatchNumOfDomains (struct qemud_client *client, remote_message_header *req, void *args, remote_num_of_domains_ret *ret);
static int remoteDispatchNumOfNetworks (struct qemud_client *client, remote_message_header *req, void *args, remote_num_of_networks_ret *ret);
static int remoteDispatchOpen (struct qemud_client *client, remote_message_header *req, remote_open_args *args, void *ret);
#!/usr/bin/perl -w
#
# This script parses remote_protocol.x and produces lots of boilerplate
# code for both ends of the remote connection.
#
# By Richard Jones <rjones@redhat.com>
#
# $Id$
use strict;
use Getopt::Std;
# Command line options.
our ($opt_c, $opt_d, $opt_i, $opt_s, $opt_v, $opt_w);
getopts ('cdisvw');
# Convert name_of_call to NameOfCall.
sub name_to_ProcName {
my $name = shift;
my @elems = split /_/, $name;
@elems = map ucfirst, @elems;
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, %calls);
while (<>) {
if (/^struct remote_(.*)_args/) {
$name = $1;
$ProcName = name_to_ProcName ($name);
die "duplicate definition of remote_${name}_args"
if exists $calls{$name};
$calls{$name} = {
name => $name,
ProcName => $ProcName,
UC_NAME => uc $name,
args => "remote_${name}_args",
ret => "void",
};
} elsif (/^struct remote_(.*)_ret/) {
$name = $1;
$ProcName = name_to_ProcName ($name);
if (exists $calls{$name}) {
$calls{$name}->{ret} = "remote_${name}_ret";
} else {
$calls{$name} = {
name => $name,
ProcName => $ProcName,
UC_NAME => uc $name,
args => "void",
ret => "remote_${name}_ret"
}
}
}
}
# REMOTE_PROC_CLOSE has no args or ret.
$calls{close} = {
name => "close",
ProcName => "Close",
UC_NAME => "CLOSE",
args => "void",
ret => "void",
};
#----------------------------------------------------------------------
# Output
print <<__EOF__;
/* Automatically generated by remote_generate_stubs.pl.
* Do not edit this file. Any changes you make will be lost.
*/
__EOF__
# Debugging.
if ($opt_d) {
my @keys = sort (keys %calls);
foreach (@keys) {
print "$_:\n";
print "\tname $calls{$_}->{name} ($calls{$_}->{ProcName})\n";
print "\t$calls{$_}->{args} -> $calls{$_}->{ret}\n";
}
}
# Prototypes for dispatch functions ("remote_dispatch_prototypes.h").
elsif ($opt_i) {
my @keys = sort (keys %calls);
foreach (@keys) {
print "static int remoteDispatch$calls{$_}->{ProcName} (struct qemud_client *client, remote_message_header *req, $calls{$_}->{args} *args, $calls{$_}->{ret} *ret);\n";
}
}
# Local variables used inside remoteDispatchClientRequest
# ("remote_dispatch_localvars.h").
elsif ($opt_v) {
my @values = values %calls;
foreach (@values) {
if ($_->{args} ne "void") {
print "$_->{args} lv_$_->{args};\n";
}
if ($_->{ret} ne "void") {
print "$_->{ret} lv_$_->{ret};\n";
}
}
}
# Inside the switch statement, prepare the 'fn', 'args_filter', etc
# ("remote_dispatch_proc_switch.h").
elsif ($opt_w) {
my @keys = sort (keys %calls);
foreach (@keys) {
print "case REMOTE_PROC_$calls{$_}->{UC_NAME}:\n";
print "\tfn = (dispatch_fn) remoteDispatch$calls{$_}->{ProcName};\n";
if ($calls{$_}->{args} ne "void") {
print "\targs_filter = (xdrproc_t) xdr_$calls{$_}->{args};\n";
print "\targs = (char *) &lv_$calls{$_}->{args};\n";
print "\tmemset (&lv_$calls{$_}->{args}, 0, sizeof lv_$calls{$_}->{args});\n"
}
if ($calls{$_}->{ret} ne "void") {
print "\tret_filter = (xdrproc_t) xdr_$calls{$_}->{ret};\n";
print "\tret = (char *) &lv_$calls{$_}->{ret};\n";
print "\tmemset (&lv_$calls{$_}->{ret}, 0, sizeof lv_$calls{$_}->{ret});\n"
}
print "\tbreak;\n";
}
}
# Generate client stubs - just used to generate the first
# version of the stubs in remote_internal.c. They need
# hand-hacking afterwards.
elsif ($opt_c) {
my @keys = sort (keys %calls);
foreach (@keys) {
my $args = $calls{$_}->{args};
my $argsvoid = $args eq "void";
my $ret = $calls{$_}->{ret};
my $retvoid = $ret eq "void";
print "static @@\n";
print "remote$calls{$_}->{ProcName} (@@)\n";
print "{\n";
if (!$argsvoid) {
print " $args args;\n";
}
if (!$retvoid) {
print " $ret ret;\n";
}
print " GET_PRIVATE (conn, @@);\n";
print "\n";
if (!$argsvoid) {
print " @@\n";
print "\n";
}
if (!$retvoid) {
print " memset (&ret, 0, sizeof ret);\n";
}
print " if (call (conn, priv, 0, REMOTE_PROC_$calls{$_}->{UC_NAME},\n";
print " (xdrproc_t) xdr_$args, (char *) ";
if ($argsvoid) {
print "NULL";
} else {
print "&args";
}
print ",\n";
print " (xdrproc_t) xdr_$ret, (char *) ";
if ($retvoid) {
print "NULL";
} else {
print "&ret";
}
print ") == -1)\n";
print " return -1;\n";
print "\n @@\n";
print "}\n\n";
}
}
# Generate server stubs - just used to generate the first
# version of the stubs in remote.c. They need hand-hacking
# afterwards.
elsif ($opt_s) {
my @keys = sort (keys %calls);
foreach (@keys) {
my $args = $calls{$_}->{args};
my $argsvoid = $args eq "void";
my $ret = $calls{$_}->{ret};
my $retvoid = $ret eq "void";
print "static int\n";
print "remoteDispatch$calls{$_}->{ProcName} (struct qemud_client *client,\n";
print " remote_message_header *req,\n";
print " remote_get_max_vcpus_args *args,\n";
print " remote_get_max_vcpus_ret *ret)\n";
print "{\n";
if (!$argsvoid || !$retvoid) {
print " @@\n";
}
print " CHECK_CONN;\n";
print "\n";
if (!$argsvoid) {
print " @@\n";
print "\n";
}
print " @@ = vir$calls{$_}->{ProcName} (@@);\n";
print " if (@@) return -1;\n";
print "\n";
if (!$retvoid) {
print " @@\n";
print "\n";
}
print " return 0;\n";
print "}\n\n";
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册