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 Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx> --- qemud/remote.c | 22 ++-------------------- qemud/remote_dispatch_prototypes.h | 7 ------- qemud/remote_dispatch_ret.h | 1 - qemud/remote_dispatch_table.h | 6 +++--- qemud/remote_generate_stubs.pl | 23 +++++++++++++++++++++-- qemud/remote_protocol.c | 2 +- qemud/remote_protocol.h | 8 ++++---- qemud/remote_protocol.x | 2 +- src/remote_internal.c | 12 ++++++------ 9 files changed, 38 insertions(+), 45 deletions(-) diff --git a/qemud/remote.c b/qemud/remote.c index fb06dc3..bb49c29 100644 --- a/qemud/remote.c +++ b/qemud/remote.c @@ -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 @@ -4434,7 +4416,7 @@ remoteDispatchDomainEventSend (struct qemud_client *client, struct qemud_client_message *msg = NULL; XDR xdr; unsigned int len; - remote_domain_event_ret data; + remote_domain_event_msg data; if (VIR_ALLOC(msg) < 0) return; @@ -4460,7 +4442,7 @@ remoteDispatchDomainEventSend (struct qemud_client *client, data.event = event; data.detail = detail; - if (!xdr_remote_domain_event_ret(&xdr, &data)) + if (!xdr_remote_domain_event_msg(&xdr, &data)) goto xdr_error; diff --git a/qemud/remote_dispatch_prototypes.h b/qemud/remote_dispatch_prototypes.h index a20ac4e..aa9c3fc 100644 --- a/qemud/remote_dispatch_prototypes.h +++ b/qemud/remote_dispatch_prototypes.h @@ -114,13 +114,6 @@ static int remoteDispatchDomainDumpXml( remote_error *err, remote_domain_dump_xml_args *args, 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( struct qemud_server *server, struct qemud_client *client, diff --git a/qemud/remote_dispatch_ret.h b/qemud/remote_dispatch_ret.h index d83ffd5..fb4a86e 100644 --- a/qemud/remote_dispatch_ret.h +++ b/qemud/remote_dispatch_ret.h @@ -75,7 +75,6 @@ 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_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_finish2_ret val_remote_domain_migrate_finish2_ret; remote_get_uri_ret val_remote_get_uri_ret; diff --git a/qemud/remote_dispatch_table.h b/qemud/remote_dispatch_table.h index ae0af28..f3a0b10 100644 --- a/qemud/remote_dispatch_table.h +++ b/qemud/remote_dispatch_table.h @@ -537,10 +537,10 @@ .args_filter = (xdrproc_t) xdr_void, .ret_filter = (xdrproc_t) xdr_remote_domain_events_deregister_ret, }, -{ /* DomainEvent => 107 */ - .fn = (dispatch_fn) remoteDispatchDomainEvent, +{ /* Async event DomainEvent => 107 */ + .fn = NULL, .args_filter = (xdrproc_t) xdr_void, - .ret_filter = (xdrproc_t) xdr_remote_domain_event_ret, + .ret_filter = (xdrproc_t) xdr_void, }, { /* DomainMigratePrepare2 => 108 */ .fn = (dispatch_fn) remoteDispatchDomainMigratePrepare2, diff --git a/qemud/remote_generate_stubs.pl b/qemud/remote_generate_stubs.pl index 44e1552..9bca0cc 100755 --- a/qemud/remote_generate_stubs.pl +++ b/qemud/remote_generate_stubs.pl @@ -65,6 +65,16 @@ while (<>) { 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+),?$/) { $name = lc $1; $id = $2; @@ -98,6 +108,9 @@ if ($opt_d) { elsif ($opt_p) { my @keys = sort (keys %calls); foreach (@keys) { + # Skip things which are REMOTE_MESSAGE + next if $calls{$_}->{msg}; + print "static int remoteDispatch$calls{$_}->{ProcName}(\n"; print " struct qemud_server *server,\n"; print " struct qemud_client *client,\n"; @@ -113,6 +126,7 @@ elsif ($opt_p) { 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"; } @@ -124,6 +138,7 @@ elsif ($opt_a) { 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"; } @@ -134,7 +149,7 @@ elsif ($opt_r) { # ("remote_dispatch_table.h"). elsif ($opt_t) { for ($id = 0 ; $id <= $#calls ; $id++) { - if (defined $calls[$id]) { + if (defined $calls[$id] && !$calls[$id]->{msg}) { print "{ /* $calls[$id]->{ProcName} => $id */\n"; print " .fn = (dispatch_fn) remoteDispatch$calls[$id]->{ProcName},\n"; if ($calls[$id]->{args} ne "void") { @@ -149,7 +164,11 @@ elsif ($opt_t) { } print "},\n"; } 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 " .args_filter = (xdrproc_t) xdr_void,\n"; print " .ret_filter = (xdrproc_t) xdr_void,\n"; diff --git a/qemud/remote_protocol.c b/qemud/remote_protocol.c index 5d09167..f6dac7a 100644 --- a/qemud/remote_protocol.c +++ b/qemud/remote_protocol.c @@ -2448,7 +2448,7 @@ xdr_remote_domain_events_deregister_ret (XDR *xdrs, remote_domain_events_deregis } 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)) diff --git a/qemud/remote_protocol.h b/qemud/remote_protocol.h index 87a5925..21eae07 100644 --- a/qemud/remote_protocol.h +++ b/qemud/remote_protocol.h @@ -1378,12 +1378,12 @@ struct 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; int event; 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 { 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_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_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_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*); @@ -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_domain_events_register_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_ret (); extern bool_t xdr_remote_domain_xml_to_native_args (); diff --git a/qemud/remote_protocol.x b/qemud/remote_protocol.x index 56385f4..1fb826b 100644 --- a/qemud/remote_protocol.x +++ b/qemud/remote_protocol.x @@ -1222,7 +1222,7 @@ struct remote_domain_events_deregister_ret { int cb_registered; }; -struct remote_domain_event_ret { +struct remote_domain_event_msg { remote_nonnull_domain dom; int event; int detail; diff --git a/src/remote_internal.c b/src/remote_internal.c index 6df0282..e7beb49 100644 --- a/src/remote_internal.c +++ b/src/remote_internal.c @@ -7093,23 +7093,23 @@ cleanup: static virDomainEventPtr remoteDomainReadEvent(virConnectPtr conn, XDR *xdr) { - remote_domain_event_ret ret; + remote_domain_event_msg msg; virDomainPtr dom; virDomainEventPtr event = NULL; - memset (&ret, 0, sizeof ret); + memset (&msg, 0, sizeof msg); /* 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, - _("remoteDomainProcessEvent: unmarshalling ret")); + _("remoteDomainProcessEvent: unmarshalling msg")); return NULL; } - dom = get_nonnull_domain(conn,ret.dom); + dom = get_nonnull_domain(conn,msg.dom); if (!dom) return NULL; - event = virDomainEventNewFromDom(dom, ret.event, ret.detail); + event = virDomainEventNewFromDom(dom, msg.event, msg.detail); virDomainFree(dom); return event; -- 1.6.2.5 -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list