Remote protocol support for domain XML conversion APIs

This commit is contained in:
Daniel P. Berrange 2009-05-21 13:50:56 +00:00
parent 4d5383fd36
commit 60d4777190
10 changed files with 249 additions and 6 deletions

View File

@ -1,3 +1,14 @@
Thu May 21 14:48:22 BST 2009 Daniel P. Berrange <berrange@redhat.com>
Remote protocol support for domain XML conversion APIs
* qemud/remote.c: Handlers for new RPC messages
* qemud/remote_dispatch_*.h, qemud/remote_protocol.c,
qemud/remote_protocol.h: Re-generate for new RPC calls
* qemud/remote_protocol.x: Add domain XML conversion APIs
* src/remote_internal.c: Client for domain XML conversion
APIs
Thu May 21 14:32:22 BST 2009 Daniel P. Berrange <berrange@redhat.com>
Public APIs for domain XML conversions.

View File

@ -1239,6 +1239,47 @@ remoteDispatchDomainDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
return 0;
}
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,

View File

@ -114,3 +114,5 @@
remote_interface_undefine_args val_remote_interface_undefine_args;
remote_interface_create_args val_remote_interface_create_args;
remote_interface_destroy_args val_remote_interface_destroy_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;

View File

@ -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,

View File

@ -96,3 +96,5 @@
remote_interface_lookup_by_mac_string_ret val_remote_interface_lookup_by_mac_string_ret;
remote_interface_get_xml_desc_ret val_remote_interface_get_xml_desc_ret;
remote_interface_define_xml_ret val_remote_interface_define_xml_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;

View File

@ -677,3 +677,13 @@
.args_filter = (xdrproc_t) xdr_remote_interface_destroy_args,
.ret_filter = (xdrproc_t) xdr_void,
},
{ /* DomainXmlFromNative => 135 */
.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 => 136 */
.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,
},

View File

@ -2460,6 +2460,50 @@ xdr_remote_domain_event_ret (XDR *xdrs, remote_domain_event_ret *objp)
return TRUE;
}
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)
{

View File

@ -1384,6 +1384,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
@ -1522,6 +1546,8 @@ enum remote_procedure {
REMOTE_PROC_INTERFACE_UNDEFINE = 132,
REMOTE_PROC_INTERFACE_CREATE = 133,
REMOTE_PROC_INTERFACE_DESTROY = 134,
REMOTE_PROC_DOMAIN_XML_FROM_NATIVE = 135,
REMOTE_PROC_DOMAIN_XML_TO_NATIVE = 136,
};
typedef enum remote_procedure remote_procedure;
@ -1777,6 +1803,10 @@ extern bool_t xdr_remote_node_device_destroy_args (XDR *, remote_node_device_de
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*);
@ -2008,6 +2038,10 @@ 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_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 ();

View File

@ -1228,6 +1228,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. */
@ -1369,21 +1392,21 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_GET_SECURITY_LABEL = 121,
REMOTE_PROC_NODE_GET_SECURITY_MODEL = 122,
REMOTE_PROC_NODE_DEVICE_CREATE_XML = 123,
REMOTE_PROC_NODE_DEVICE_DESTROY = 124,
REMOTE_PROC_STORAGE_VOL_CREATE_XML_FROM = 125,
REMOTE_PROC_NUM_OF_INTERFACES = 126,
REMOTE_PROC_LIST_INTERFACES = 127,
REMOTE_PROC_INTERFACE_LOOKUP_BY_NAME = 128,
REMOTE_PROC_INTERFACE_LOOKUP_BY_MAC_STRING = 129,
REMOTE_PROC_INTERFACE_GET_XML_DESC = 130,
REMOTE_PROC_INTERFACE_DEFINE_XML = 131,
REMOTE_PROC_INTERFACE_UNDEFINE = 132,
REMOTE_PROC_INTERFACE_CREATE = 133,
REMOTE_PROC_INTERFACE_DESTROY = 134
REMOTE_PROC_INTERFACE_DESTROY = 134,
REMOTE_PROC_DOMAIN_XML_FROM_NATIVE = 135,
REMOTE_PROC_DOMAIN_XML_TO_NATIVE = 136
};
/* Custom RPC structure. */

View File

@ -2404,6 +2404,68 @@ done:
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);
return rv;
}
static int
remoteDomainMigratePrepare (virConnectPtr dconn,
char **cookie, int *cookielen,
@ -7301,8 +7363,8 @@ static virDriver driver = {
remoteDomainGetSecurityLabel, /* domainGetSecurityLabel */
remoteNodeGetSecurityModel, /* nodeGetSecurityModel */
remoteDomainDumpXML, /* domainDumpXML */
NULL, /* domainXmlFromNative */
NULL, /* domainXmlToNative */
remoteDomainXMLFromNative, /* domainXMLFromNative */
remoteDomainXMLToNative, /* domainXMLToNative */
remoteListDefinedDomains, /* listDefinedDomains */
remoteNumOfDefinedDomains, /* numOfDefinedDomains */
remoteDomainCreate, /* domainCreate */