
On Thu, Jun 10, 2010 at 12:21:20PM -0600, Eric Blake wrote:
Define the wire format for the new virDomainCreateWithFlags API, and implement client and server side of marshaling code.
* daemon/remote.c (remoteDispatchDomainCreateWithFlags): Add server side dispatch for virDomainCreateWithFlags. * src/remote/remote_driver.c (remoteDomainCreateWithFlags) (remote_driver): Client side serialization. * src/remote/remote_protocol.x (remote_domain_create_with_flags_args) (remote_domain_create_with_flags_ret) (REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS): Define wire format. * daemon/remote_dispatch_args.h: Regenerate. * daemon/remote_dispatch_prototypes.h: Likewise. * daemon/remote_dispatch_table.h: Likewise. * src/remote/remote_protocol.c: Likewise. * src/remote/remote_protocol.h: Likewise. * src/remote_protocol-structs: Likewise. ---
diff from v1: use right type in .x, then rerun 'make rpcgen'.
daemon/remote.c | 27 +++++++++++++++++++++++++++ daemon/remote_dispatch_args.h | 1 + daemon/remote_dispatch_prototypes.h | 8 ++++++++ daemon/remote_dispatch_ret.h | 1 + daemon/remote_dispatch_table.h | 5 +++++ src/remote/remote_driver.c | 34 +++++++++++++++++++++++++++++++++- src/remote/remote_protocol.c | 20 ++++++++++++++++++++ src/remote/remote_protocol.h | 16 ++++++++++++++++ src/remote/remote_protocol.x | 14 ++++++++++++-- src/remote_protocol-structs | 7 +++++++ 10 files changed, 130 insertions(+), 3 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c index c54565c..88a5494 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -1213,6 +1213,33 @@ remoteDispatchDomainCreate (struct qemud_server *server ATTRIBUTE_UNUSED, }
static int +remoteDispatchDomainCreateWithFlags (struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_domain_create_with_flags_args *args, + remote_domain_create_with_flags_ret *ret) +{ + virDomainPtr dom; + + dom = get_nonnull_domain (conn, args->dom); + if (dom == NULL) { + remoteDispatchConnError(rerr, conn); + return -1; + } + + if (virDomainCreateWithFlags (dom, args->flags) == -1) { + virDomainFree(dom); + remoteDispatchConnError(rerr, conn); + return -1; + } + ret->dom.id = dom->id;
Although its only the 'id' value the client cares about, since we have a full 'remote_domain' object on the wire, we should initialize all the fields just in case we need it in the future. So just call into make_nonnull_domain() instead of setting dom.id directly.
+ virDomainFree(dom); + return 0; +} + +static int remoteDispatchDomainCreateXml (struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client ATTRIBUTE_UNUSED, virConnectPtr conn, diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index c8f81f3..2e67931 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -406,6 +406,13 @@ struct remote_num_of_defined_domains_ret { struct remote_domain_create_args { remote_nonnull_domain dom; }; +struct remote_domain_create_with_flags_args { + remote_nonnull_domain dom; + int flags; +};
I think this needs updating to 'unsigned' to match the changed .x file too
+struct remote_domain_create_with_flags_ret { + remote_nonnull_domain dom; +}; struct remote_domain_define_xml_args { remote_nonnull_string xml; };
Regards, Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|