Change code generator to give async event messages their own postfix

The naming convention for structs used in the RPC layer is for
incoming requests to be called XXXX_args, and the associated
outgoing reply to be called XXXX_ret.  Asynchronously emitted
messages (eg events) are re-using the XXXX_ret naming scheme.
This patch changes that such that async messages are XXXX_msg,
and stops adding entries for them in the dispatch table, avoiding
the need for a dummy no-op implementation.

* qemud/remote.c: Remove dummy remoteDispatchDomainEvent, no
  longer required. Update to replace remote_domain_event_ret
  with xdr_remote_domain_event_msg
* qemud/remote_protocol.x: Rename remote_domain_event_ret to
  remote_domain_event_msg
* qemud/remote_generate_stubs.pl: Adding handling for new
  XXX_msg structs.
* src/remote_internal.c: Rename remote_domain_event_ret to
  remote_domain_event_msg
* qemud/remote_dispatch_prototypes.h, qemud/remote_dispatch_ret.h,
  qemud/remote_dispatch_table.h, qemud/remote_protocol.h,
  qemud/remote_protocol.c: auto-regenerate
This commit is contained in:
Daniel P. Berrange 2009-07-10 12:38:41 +01:00
parent 852fa7d04a
commit aa23d432cd
9 changed files with 38 additions and 45 deletions

View File

@ -4365,24 +4365,6 @@ remoteDispatchNodeDeviceDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
} }
/**************************
* Async Events
**************************/
static int
remoteDispatchDomainEvent (struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn ATTRIBUTE_UNUSED,
remote_error *rerr ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_domain_event_ret *ret ATTRIBUTE_UNUSED)
{
/* This call gets dispatched from a client call.
* This does not make sense, as this should not be intiated
* from the client side in generated code.
*/
remoteDispatchFormatError(rerr, "%s", _("unexpected async event method call"));
return -1;
}
/*************************** /***************************
* Register / deregister events * Register / deregister events
@ -4434,7 +4416,7 @@ remoteDispatchDomainEventSend (struct qemud_client *client,
struct qemud_client_message *msg = NULL; struct qemud_client_message *msg = NULL;
XDR xdr; XDR xdr;
unsigned int len; unsigned int len;
remote_domain_event_ret data; remote_domain_event_msg data;
if (VIR_ALLOC(msg) < 0) if (VIR_ALLOC(msg) < 0)
return; return;
@ -4460,7 +4442,7 @@ remoteDispatchDomainEventSend (struct qemud_client *client,
data.event = event; data.event = event;
data.detail = detail; data.detail = detail;
if (!xdr_remote_domain_event_ret(&xdr, &data)) if (!xdr_remote_domain_event_msg(&xdr, &data))
goto xdr_error; goto xdr_error;

View File

@ -114,13 +114,6 @@ static int remoteDispatchDomainDumpXml(
remote_error *err, remote_error *err,
remote_domain_dump_xml_args *args, remote_domain_dump_xml_args *args,
remote_domain_dump_xml_ret *ret); remote_domain_dump_xml_ret *ret);
static int remoteDispatchDomainEvent(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_error *err,
void *args,
remote_domain_event_ret *ret);
static int remoteDispatchDomainEventsDeregister( static int remoteDispatchDomainEventsDeregister(
struct qemud_server *server, struct qemud_server *server,
struct qemud_client *client, struct qemud_client *client,

View File

@ -75,7 +75,6 @@
remote_domain_memory_peek_ret val_remote_domain_memory_peek_ret; remote_domain_memory_peek_ret val_remote_domain_memory_peek_ret;
remote_domain_events_register_ret val_remote_domain_events_register_ret; remote_domain_events_register_ret val_remote_domain_events_register_ret;
remote_domain_events_deregister_ret val_remote_domain_events_deregister_ret; remote_domain_events_deregister_ret val_remote_domain_events_deregister_ret;
remote_domain_event_ret val_remote_domain_event_ret;
remote_domain_migrate_prepare2_ret val_remote_domain_migrate_prepare2_ret; remote_domain_migrate_prepare2_ret val_remote_domain_migrate_prepare2_ret;
remote_domain_migrate_finish2_ret val_remote_domain_migrate_finish2_ret; remote_domain_migrate_finish2_ret val_remote_domain_migrate_finish2_ret;
remote_get_uri_ret val_remote_get_uri_ret; remote_get_uri_ret val_remote_get_uri_ret;

View File

@ -537,10 +537,10 @@
.args_filter = (xdrproc_t) xdr_void, .args_filter = (xdrproc_t) xdr_void,
.ret_filter = (xdrproc_t) xdr_remote_domain_events_deregister_ret, .ret_filter = (xdrproc_t) xdr_remote_domain_events_deregister_ret,
}, },
{ /* DomainEvent => 107 */ { /* Async event DomainEvent => 107 */
.fn = (dispatch_fn) remoteDispatchDomainEvent, .fn = NULL,
.args_filter = (xdrproc_t) xdr_void, .args_filter = (xdrproc_t) xdr_void,
.ret_filter = (xdrproc_t) xdr_remote_domain_event_ret, .ret_filter = (xdrproc_t) xdr_void,
}, },
{ /* DomainMigratePrepare2 => 108 */ { /* DomainMigratePrepare2 => 108 */
.fn = (dispatch_fn) remoteDispatchDomainMigratePrepare2, .fn = (dispatch_fn) remoteDispatchDomainMigratePrepare2,

View File

@ -65,6 +65,16 @@ while (<>) {
ret => "remote_${name}_ret" ret => "remote_${name}_ret"
} }
} }
} elsif (/^struct remote_(.*)_msg/) {
$name = $1;
$ProcName = name_to_ProcName ($name);
$calls{$name} = {
name => $name,
ProcName => $ProcName,
UC_NAME => uc $name,
msg => "remote_${name}_msg"
}
} elsif (/^\s*REMOTE_PROC_(.*?)\s+=\s+(\d+),?$/) { } elsif (/^\s*REMOTE_PROC_(.*?)\s+=\s+(\d+),?$/) {
$name = lc $1; $name = lc $1;
$id = $2; $id = $2;
@ -98,6 +108,9 @@ if ($opt_d) {
elsif ($opt_p) { elsif ($opt_p) {
my @keys = sort (keys %calls); my @keys = sort (keys %calls);
foreach (@keys) { foreach (@keys) {
# Skip things which are REMOTE_MESSAGE
next if $calls{$_}->{msg};
print "static int remoteDispatch$calls{$_}->{ProcName}(\n"; print "static int remoteDispatch$calls{$_}->{ProcName}(\n";
print " struct qemud_server *server,\n"; print " struct qemud_server *server,\n";
print " struct qemud_client *client,\n"; print " struct qemud_client *client,\n";
@ -113,6 +126,7 @@ elsif ($opt_p) {
elsif ($opt_a) { elsif ($opt_a) {
for ($id = 0 ; $id <= $#calls ; $id++) { for ($id = 0 ; $id <= $#calls ; $id++) {
if (defined $calls[$id] && if (defined $calls[$id] &&
!$calls[$id]->{msg} &&
$calls[$id]->{args} ne "void") { $calls[$id]->{args} ne "void") {
print " $calls[$id]->{args} val_$calls[$id]->{args};\n"; print " $calls[$id]->{args} val_$calls[$id]->{args};\n";
} }
@ -124,6 +138,7 @@ elsif ($opt_a) {
elsif ($opt_r) { elsif ($opt_r) {
for ($id = 0 ; $id <= $#calls ; $id++) { for ($id = 0 ; $id <= $#calls ; $id++) {
if (defined $calls[$id] && if (defined $calls[$id] &&
!$calls[$id]->{msg} &&
$calls[$id]->{ret} ne "void") { $calls[$id]->{ret} ne "void") {
print " $calls[$id]->{ret} val_$calls[$id]->{ret};\n"; print " $calls[$id]->{ret} val_$calls[$id]->{ret};\n";
} }
@ -134,7 +149,7 @@ elsif ($opt_r) {
# ("remote_dispatch_table.h"). # ("remote_dispatch_table.h").
elsif ($opt_t) { elsif ($opt_t) {
for ($id = 0 ; $id <= $#calls ; $id++) { for ($id = 0 ; $id <= $#calls ; $id++) {
if (defined $calls[$id]) { if (defined $calls[$id] && !$calls[$id]->{msg}) {
print "{ /* $calls[$id]->{ProcName} => $id */\n"; print "{ /* $calls[$id]->{ProcName} => $id */\n";
print " .fn = (dispatch_fn) remoteDispatch$calls[$id]->{ProcName},\n"; print " .fn = (dispatch_fn) remoteDispatch$calls[$id]->{ProcName},\n";
if ($calls[$id]->{args} ne "void") { if ($calls[$id]->{args} ne "void") {
@ -149,7 +164,11 @@ elsif ($opt_t) {
} }
print "},\n"; print "},\n";
} else { } else {
print "{ /* (unused) => $id */\n"; if ($calls[$id]->{msg}) {
print "{ /* Async event $calls[$id]->{ProcName} => $id */\n";
} else {
print "{ /* (unused) => $id */\n";
}
print " .fn = NULL,\n"; print " .fn = NULL,\n";
print " .args_filter = (xdrproc_t) xdr_void,\n"; print " .args_filter = (xdrproc_t) xdr_void,\n";
print " .ret_filter = (xdrproc_t) xdr_void,\n"; print " .ret_filter = (xdrproc_t) xdr_void,\n";

View File

@ -2448,7 +2448,7 @@ xdr_remote_domain_events_deregister_ret (XDR *xdrs, remote_domain_events_deregis
} }
bool_t bool_t
xdr_remote_domain_event_ret (XDR *xdrs, remote_domain_event_ret *objp) xdr_remote_domain_event_msg (XDR *xdrs, remote_domain_event_msg *objp)
{ {
if (!xdr_remote_nonnull_domain (xdrs, &objp->dom)) if (!xdr_remote_nonnull_domain (xdrs, &objp->dom))

View File

@ -1378,12 +1378,12 @@ struct remote_domain_events_deregister_ret {
}; };
typedef struct remote_domain_events_deregister_ret remote_domain_events_deregister_ret; typedef struct remote_domain_events_deregister_ret remote_domain_events_deregister_ret;
struct remote_domain_event_ret { struct remote_domain_event_msg {
remote_nonnull_domain dom; remote_nonnull_domain dom;
int event; int event;
int detail; int detail;
}; };
typedef struct remote_domain_event_ret remote_domain_event_ret; typedef struct remote_domain_event_msg remote_domain_event_msg;
struct remote_domain_xml_from_native_args { struct remote_domain_xml_from_native_args {
remote_nonnull_string nativeFormat; remote_nonnull_string nativeFormat;
@ -1802,7 +1802,7 @@ extern bool_t xdr_remote_node_device_create_xml_ret (XDR *, remote_node_device_
extern bool_t xdr_remote_node_device_destroy_args (XDR *, remote_node_device_destroy_args*); extern bool_t xdr_remote_node_device_destroy_args (XDR *, remote_node_device_destroy_args*);
extern bool_t xdr_remote_domain_events_register_ret (XDR *, remote_domain_events_register_ret*); extern bool_t xdr_remote_domain_events_register_ret (XDR *, remote_domain_events_register_ret*);
extern bool_t xdr_remote_domain_events_deregister_ret (XDR *, remote_domain_events_deregister_ret*); extern bool_t xdr_remote_domain_events_deregister_ret (XDR *, remote_domain_events_deregister_ret*);
extern bool_t xdr_remote_domain_event_ret (XDR *, remote_domain_event_ret*); extern bool_t xdr_remote_domain_event_msg (XDR *, remote_domain_event_msg*);
extern bool_t xdr_remote_domain_xml_from_native_args (XDR *, remote_domain_xml_from_native_args*); extern bool_t xdr_remote_domain_xml_from_native_args (XDR *, remote_domain_xml_from_native_args*);
extern bool_t xdr_remote_domain_xml_from_native_ret (XDR *, remote_domain_xml_from_native_ret*); extern bool_t xdr_remote_domain_xml_from_native_ret (XDR *, remote_domain_xml_from_native_ret*);
extern bool_t xdr_remote_domain_xml_to_native_args (XDR *, remote_domain_xml_to_native_args*); extern bool_t xdr_remote_domain_xml_to_native_args (XDR *, remote_domain_xml_to_native_args*);
@ -2037,7 +2037,7 @@ extern bool_t xdr_remote_node_device_create_xml_ret ();
extern bool_t xdr_remote_node_device_destroy_args (); extern bool_t xdr_remote_node_device_destroy_args ();
extern bool_t xdr_remote_domain_events_register_ret (); extern bool_t xdr_remote_domain_events_register_ret ();
extern bool_t xdr_remote_domain_events_deregister_ret (); extern bool_t xdr_remote_domain_events_deregister_ret ();
extern bool_t xdr_remote_domain_event_ret (); extern bool_t xdr_remote_domain_event_msg ();
extern bool_t xdr_remote_domain_xml_from_native_args (); extern bool_t xdr_remote_domain_xml_from_native_args ();
extern bool_t xdr_remote_domain_xml_from_native_ret (); extern bool_t xdr_remote_domain_xml_from_native_ret ();
extern bool_t xdr_remote_domain_xml_to_native_args (); extern bool_t xdr_remote_domain_xml_to_native_args ();

View File

@ -1222,7 +1222,7 @@ struct remote_domain_events_deregister_ret {
int cb_registered; int cb_registered;
}; };
struct remote_domain_event_ret { struct remote_domain_event_msg {
remote_nonnull_domain dom; remote_nonnull_domain dom;
int event; int event;
int detail; int detail;

View File

@ -7099,23 +7099,23 @@ cleanup:
static virDomainEventPtr static virDomainEventPtr
remoteDomainReadEvent(virConnectPtr conn, XDR *xdr) remoteDomainReadEvent(virConnectPtr conn, XDR *xdr)
{ {
remote_domain_event_ret ret; remote_domain_event_msg msg;
virDomainPtr dom; virDomainPtr dom;
virDomainEventPtr event = NULL; virDomainEventPtr event = NULL;
memset (&ret, 0, sizeof ret); memset (&msg, 0, sizeof msg);
/* unmarshall parameters, and process it*/ /* unmarshall parameters, and process it*/
if (! xdr_remote_domain_event_ret(xdr, &ret) ) { if (! xdr_remote_domain_event_msg(xdr, &msg) ) {
error (conn, VIR_ERR_RPC, error (conn, VIR_ERR_RPC,
_("remoteDomainProcessEvent: unmarshalling ret")); _("remoteDomainProcessEvent: unmarshalling msg"));
return NULL; return NULL;
} }
dom = get_nonnull_domain(conn,ret.dom); dom = get_nonnull_domain(conn,msg.dom);
if (!dom) if (!dom)
return NULL; return NULL;
event = virDomainEventNewFromDom(dom, ret.event, ret.detail); event = virDomainEventNewFromDom(dom, msg.event, msg.detail);
virDomainFree(dom); virDomainFree(dom);
return event; return event;