This patch wires up the new APIs to the remote driver and libvirtd daemon. qemud/remote.c | 41 ++++++++++++++++++++++ qemud/remote_dispatch_args.h | 2 + qemud/remote_dispatch_prototypes.h | 14 +++++++ qemud/remote_dispatch_ret.h | 2 + qemud/remote_dispatch_table.h | 10 +++++ qemud/remote_protocol.c | 44 ++++++++++++++++++++++++ qemud/remote_protocol.h | 34 +++++++++++++++++++ qemud/remote_protocol.x | 27 ++++++++++++++- src/remote_internal.c | 66 +++++++++++++++++++++++++++++++++++-- src/virsh.c | 4 +- 10 files changed, 239 insertions(+), 5 deletions(-) Daniel diff -r 4f46dfd24fdb qemud/remote.c --- a/qemud/remote.c Wed May 13 09:54:09 2009 -0400 +++ b/qemud/remote.c Wed May 13 10:00:22 2009 -0400 @@ -1236,6 +1236,47 @@ remoteDispatchDomainDumpXml (struct qemu } static int +remoteDispatchDomainXmlFromNative (struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_error *rerr, + remote_domain_xml_from_native_args *args, + remote_domain_xml_from_native_ret *ret) +{ + /* remoteDispatchClientRequest will free this. */ + ret->domainXml = virConnectDomainXMLFromNative (conn, + args->nativeFormat, + args->nativeConfig, + args->flags); + if (!ret->domainXml) { + remoteDispatchConnError(rerr, conn); + return -1; + } + return 0; +} + +static int +remoteDispatchDomainXmlToNative (struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_error *rerr, + remote_domain_xml_to_native_args *args, + remote_domain_xml_to_native_ret *ret) +{ + /* remoteDispatchClientRequest will free this. */ + ret->nativeConfig = virConnectDomainXMLToNative (conn, + args->nativeFormat, + args->domainXml, + args->flags); + if (!ret->nativeConfig) { + remoteDispatchConnError(rerr, conn); + return -1; + } + return 0; +} + + +static int remoteDispatchDomainGetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client ATTRIBUTE_UNUSED, virConnectPtr conn, diff -r 4f46dfd24fdb qemud/remote_dispatch_args.h --- a/qemud/remote_dispatch_args.h Wed May 13 09:54:09 2009 -0400 +++ b/qemud/remote_dispatch_args.h Wed May 13 10:02:06 2009 -0400 @@ -106,3 +106,5 @@ remote_node_device_create_xml_args val_remote_node_device_create_xml_args; remote_node_device_destroy_args val_remote_node_device_destroy_args; remote_storage_vol_create_xml_from_args val_remote_storage_vol_create_xml_from_args; + remote_domain_xml_from_native_args val_remote_domain_xml_from_native_args; + remote_domain_xml_to_native_args val_remote_domain_xml_to_native_args; diff -r 4f46dfd24fdb qemud/remote_dispatch_prototypes.h --- a/qemud/remote_dispatch_prototypes.h Wed May 13 09:54:09 2009 -0400 +++ b/qemud/remote_dispatch_prototypes.h Wed May 13 10:02:06 2009 -0400 @@ -359,6 +359,20 @@ static int remoteDispatchDomainUndefine( remote_error *err, remote_domain_undefine_args *args, void *ret); +static int remoteDispatchDomainXmlFromNative( + struct qemud_server *server, + struct qemud_client *client, + virConnectPtr conn, + remote_error *err, + remote_domain_xml_from_native_args *args, + remote_domain_xml_from_native_ret *ret); +static int remoteDispatchDomainXmlToNative( + struct qemud_server *server, + struct qemud_client *client, + virConnectPtr conn, + remote_error *err, + remote_domain_xml_to_native_args *args, + remote_domain_xml_to_native_ret *ret); static int remoteDispatchFindStoragePoolSources( struct qemud_server *server, struct qemud_client *client, diff -r 4f46dfd24fdb qemud/remote_dispatch_ret.h --- a/qemud/remote_dispatch_ret.h Wed May 13 09:54:09 2009 -0400 +++ b/qemud/remote_dispatch_ret.h Wed May 13 10:02:06 2009 -0400 @@ -90,3 +90,5 @@ remote_node_get_security_model_ret val_remote_node_get_security_model_ret; remote_node_device_create_xml_ret val_remote_node_device_create_xml_ret; remote_storage_vol_create_xml_from_ret val_remote_storage_vol_create_xml_from_ret; + remote_domain_xml_from_native_ret val_remote_domain_xml_from_native_ret; + remote_domain_xml_to_native_ret val_remote_domain_xml_to_native_ret; diff -r 4f46dfd24fdb qemud/remote_dispatch_table.h --- a/qemud/remote_dispatch_table.h Wed May 13 09:54:09 2009 -0400 +++ b/qemud/remote_dispatch_table.h Wed May 13 10:02:06 2009 -0400 @@ -632,3 +632,13 @@ .args_filter = (xdrproc_t) xdr_remote_storage_vol_create_xml_from_args, .ret_filter = (xdrproc_t) xdr_remote_storage_vol_create_xml_from_ret, }, +{ /* DomainXmlFromNative => 126 */ + .fn = (dispatch_fn) remoteDispatchDomainXmlFromNative, + .args_filter = (xdrproc_t) xdr_remote_domain_xml_from_native_args, + .ret_filter = (xdrproc_t) xdr_remote_domain_xml_from_native_ret, +}, +{ /* DomainXmlToNative => 127 */ + .fn = (dispatch_fn) remoteDispatchDomainXmlToNative, + .args_filter = (xdrproc_t) xdr_remote_domain_xml_to_native_args, + .ret_filter = (xdrproc_t) xdr_remote_domain_xml_to_native_ret, +}, diff -r 4f46dfd24fdb qemud/remote_protocol.c --- a/qemud/remote_protocol.c Wed May 13 09:54:09 2009 -0400 +++ b/qemud/remote_protocol.c Wed May 13 09:57:11 2009 -0400 @@ -2314,6 +2314,50 @@ xdr_remote_domain_event_ret (XDR *xdrs, } bool_t +xdr_remote_domain_xml_from_native_args (XDR *xdrs, remote_domain_xml_from_native_args *objp) +{ + + if (!xdr_remote_nonnull_string (xdrs, &objp->nativeFormat)) + return FALSE; + if (!xdr_remote_nonnull_string (xdrs, &objp->nativeConfig)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->flags)) + return FALSE; + return TRUE; +} + +bool_t +xdr_remote_domain_xml_from_native_ret (XDR *xdrs, remote_domain_xml_from_native_ret *objp) +{ + + if (!xdr_remote_nonnull_string (xdrs, &objp->domainXml)) + return FALSE; + return TRUE; +} + +bool_t +xdr_remote_domain_xml_to_native_args (XDR *xdrs, remote_domain_xml_to_native_args *objp) +{ + + if (!xdr_remote_nonnull_string (xdrs, &objp->nativeFormat)) + return FALSE; + if (!xdr_remote_nonnull_string (xdrs, &objp->domainXml)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->flags)) + return FALSE; + return TRUE; +} + +bool_t +xdr_remote_domain_xml_to_native_ret (XDR *xdrs, remote_domain_xml_to_native_ret *objp) +{ + + if (!xdr_remote_nonnull_string (xdrs, &objp->nativeConfig)) + return FALSE; + return TRUE; +} + +bool_t xdr_remote_procedure (XDR *xdrs, remote_procedure *objp) { diff -r 4f46dfd24fdb qemud/remote_protocol.h --- a/qemud/remote_protocol.h Wed May 13 09:54:09 2009 -0400 +++ b/qemud/remote_protocol.h Wed May 13 09:57:11 2009 -0400 @@ -1300,6 +1300,30 @@ struct remote_domain_event_ret { int detail; }; typedef struct remote_domain_event_ret remote_domain_event_ret; + +struct remote_domain_xml_from_native_args { + remote_nonnull_string nativeFormat; + remote_nonnull_string nativeConfig; + u_int flags; +}; +typedef struct remote_domain_xml_from_native_args remote_domain_xml_from_native_args; + +struct remote_domain_xml_from_native_ret { + remote_nonnull_string domainXml; +}; +typedef struct remote_domain_xml_from_native_ret remote_domain_xml_from_native_ret; + +struct remote_domain_xml_to_native_args { + remote_nonnull_string nativeFormat; + remote_nonnull_string domainXml; + u_int flags; +}; +typedef struct remote_domain_xml_to_native_args remote_domain_xml_to_native_args; + +struct remote_domain_xml_to_native_ret { + remote_nonnull_string nativeConfig; +}; +typedef struct remote_domain_xml_to_native_ret remote_domain_xml_to_native_ret; #define REMOTE_PROGRAM 0x20008086 #define REMOTE_PROTOCOL_VERSION 1 @@ -1429,6 +1453,8 @@ enum remote_procedure { REMOTE_PROC_NODE_DEVICE_CREATE_XML = 123, REMOTE_PROC_NODE_DEVICE_DESTROY = 124, REMOTE_PROC_STORAGE_VOL_CREATE_XML_FROM = 125, + REMOTE_PROC_DOMAIN_XML_FROM_NATIVE = 125, + REMOTE_PROC_DOMAIN_XML_TO_NATIVE = 126, }; typedef enum remote_procedure remote_procedure; @@ -1669,6 +1695,10 @@ extern bool_t xdr_remote_domain_events_ 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_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*); +extern bool_t xdr_remote_domain_xml_to_native_ret (XDR *, remote_domain_xml_to_native_ret*); extern bool_t xdr_remote_procedure (XDR *, remote_procedure*); extern bool_t xdr_remote_message_direction (XDR *, remote_message_direction*); extern bool_t xdr_remote_message_status (XDR *, remote_message_status*); @@ -1885,6 +1915,10 @@ extern bool_t xdr_remote_domain_events_r 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_xml_from_native_args (); +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_ret (); extern bool_t xdr_remote_procedure (); extern bool_t xdr_remote_message_direction (); extern bool_t xdr_remote_message_status (); diff -r 4f46dfd24fdb qemud/remote_protocol.x --- a/qemud/remote_protocol.x Wed May 13 09:54:09 2009 -0400 +++ b/qemud/remote_protocol.x Wed May 13 10:02:03 2009 -0400 @@ -1154,6 +1154,29 @@ struct remote_domain_event_ret { int detail; }; + +struct remote_domain_xml_from_native_args { + remote_nonnull_string nativeFormat; + remote_nonnull_string nativeConfig; + unsigned flags; +}; + +struct remote_domain_xml_from_native_ret { + remote_nonnull_string domainXml; +}; + + +struct remote_domain_xml_to_native_args { + remote_nonnull_string nativeFormat; + remote_nonnull_string domainXml; + unsigned flags; +}; + +struct remote_domain_xml_to_native_ret { + remote_nonnull_string nativeConfig; +}; + + /*----- Protocol. -----*/ /* Define the program number, protocol version and procedure numbers here. */ @@ -1299,7 +1322,9 @@ enum remote_procedure { REMOTE_PROC_NODE_DEVICE_CREATE_XML = 123, REMOTE_PROC_NODE_DEVICE_DESTROY = 124, - REMOTE_PROC_STORAGE_VOL_CREATE_XML_FROM = 125 + REMOTE_PROC_STORAGE_VOL_CREATE_XML_FROM = 125, + REMOTE_PROC_DOMAIN_XML_FROM_NATIVE = 126, + REMOTE_PROC_DOMAIN_XML_TO_NATIVE = 127 }; /* Custom RPC structure. */ diff -r 4f46dfd24fdb src/remote_internal.c --- a/src/remote_internal.c Wed May 13 09:54:09 2009 -0400 +++ b/src/remote_internal.c Wed May 13 09:54:10 2009 -0400 @@ -2395,6 +2395,68 @@ remoteDomainDumpXML (virDomainPtr domain /* Caller frees. */ rv = ret.xml; + +done: + remoteDriverUnlock(priv); + return rv; +} + +static char * +remoteDomainXMLFromNative (virConnectPtr conn, + const char *format, + const char *config, + unsigned int flags) +{ + char *rv = NULL; + remote_domain_xml_from_native_args args; + remote_domain_xml_from_native_ret ret; + struct private_data *priv = conn->privateData; + + remoteDriverLock(priv); + + args.nativeFormat = (char *)format; + args.nativeConfig = (char *)config; + args.flags = flags; + + memset (&ret, 0, sizeof ret); + if (call (conn, priv, 0, REMOTE_PROC_DOMAIN_XML_FROM_NATIVE, + (xdrproc_t) xdr_remote_domain_xml_from_native_args, (char *) &args, + (xdrproc_t) xdr_remote_domain_xml_from_native_ret, (char *) &ret) == -1) + goto done; + + /* Caller frees. */ + rv = ret.domainXml; + +done: + remoteDriverUnlock(priv); + return rv; +} + +static char * +remoteDomainXMLToNative (virConnectPtr conn, + const char *format, + const char *xml, + unsigned int flags) +{ + char *rv = NULL; + remote_domain_xml_to_native_args args; + remote_domain_xml_to_native_ret ret; + struct private_data *priv = conn->privateData; + + remoteDriverLock(priv); + + args.nativeFormat = (char *)format; + args.domainXml = (char *)xml; + args.flags = flags; + + memset (&ret, 0, sizeof ret); + if (call (conn, priv, 0, REMOTE_PROC_DOMAIN_XML_TO_NATIVE, + (xdrproc_t) xdr_remote_domain_xml_to_native_args, (char *) &args, + (xdrproc_t) xdr_remote_domain_xml_to_native_ret, (char *) &ret) == -1) + goto done; + + /* Caller frees. */ + rv = ret.nativeConfig; done: remoteDriverUnlock(priv); @@ -6968,8 +7030,8 @@ static virDriver driver = { remoteDomainGetSecurityLabel, /* domainGetSecurityLabel */ remoteNodeGetSecurityModel, /* nodeGetSecurityModel */ remoteDomainDumpXML, /* domainDumpXML */ - NULL, /* domainXmlFromNative */ - NULL, /* domainXmlToNative */ + remoteDomainXMLFromNative, /* domainXMLFromNative */ + remoteDomainXMLToNative, /* domainXMLToNative */ remoteListDefinedDomains, /* listDefinedDomains */ remoteNumOfDefinedDomains, /* numOfDefinedDomains */ remoteDomainCreate, /* domainCreate */ diff -r 4f46dfd24fdb src/virsh.c --- a/src/virsh.c Wed May 13 09:54:09 2009 -0400 +++ b/src/virsh.c Wed May 13 09:54:10 2009 -0400 @@ -4189,8 +4189,8 @@ makeCloneXML(char *origxml, char *newnam makeCloneXML(char *origxml, char *newname) { xmlDocPtr doc; - xmlXPathContextPtr ctxt; - xmlXPathObjectPtr obj; + xmlXPathContextPtr ctxt = NULL; + xmlXPathObjectPtr obj = NULL; xmlChar *newxml = NULL; int size; -- |: 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