mirror of https://gitee.com/openkylin/libvirt.git
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:
parent
852fa7d04a
commit
aa23d432cd
|
@ -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;
|
||||
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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 ();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -7099,23 +7099,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;
|
||||
|
|
Loading…
Reference in New Issue