remote: protocol implementation for virDomainCreateWithFlags

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.
This commit is contained in:
Eric Blake 2010-06-10 08:53:28 -06:00
parent 460ca88b98
commit 6c83e7ca6f
10 changed files with 131 additions and 3 deletions

View File

@ -1212,6 +1212,34 @@ remoteDispatchDomainCreate (struct qemud_server *server ATTRIBUTE_UNUSED,
return 0;
}
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;
}
make_nonnull_domain (&ret->dom, dom);
virDomainFree(dom);
return 0;
}
static int
remoteDispatchDomainCreateXml (struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client ATTRIBUTE_UNUSED,

View File

@ -164,3 +164,4 @@
remote_domain_revert_to_snapshot_args val_remote_domain_revert_to_snapshot_args;
remote_domain_snapshot_delete_args val_remote_domain_snapshot_delete_args;
remote_domain_get_block_info_args val_remote_domain_get_block_info_args;
remote_domain_create_with_flags_args val_remote_domain_create_with_flags_args;

View File

@ -122,6 +122,14 @@ static int remoteDispatchDomainCreate(
remote_error *err,
remote_domain_create_args *args,
void *ret);
static int remoteDispatchDomainCreateWithFlags(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_domain_create_with_flags_args *args,
remote_domain_create_with_flags_ret *ret);
static int remoteDispatchDomainCreateXml(
struct qemud_server *server,
struct qemud_client *client,

View File

@ -134,3 +134,4 @@
remote_domain_has_current_snapshot_ret val_remote_domain_has_current_snapshot_ret;
remote_domain_snapshot_current_ret val_remote_domain_snapshot_current_ret;
remote_domain_get_block_info_ret val_remote_domain_get_block_info_ret;
remote_domain_create_with_flags_ret val_remote_domain_create_with_flags_ret;

View File

@ -982,3 +982,8 @@
.args_filter = (xdrproc_t) xdr_void,
.ret_filter = (xdrproc_t) xdr_void,
},
{ /* DomainCreateWithFlags => 196 */
.fn = (dispatch_fn) remoteDispatchDomainCreateWithFlags,
.args_filter = (xdrproc_t) xdr_remote_domain_create_with_flags_args,
.ret_filter = (xdrproc_t) xdr_remote_domain_create_with_flags_ret,
},

View File

@ -3036,6 +3036,38 @@ done:
return rv;
}
static int
remoteDomainCreateWithFlags (virDomainPtr domain, unsigned int flags)
{
int rv = -1;
remote_domain_create_with_flags_args args;
remote_domain_create_with_flags_ret ret;
struct private_data *priv = domain->conn->privateData;
remoteDriverLock(priv);
make_nonnull_domain (&args.dom, domain);
args.flags = flags;
memset (&ret, 0, sizeof ret);
if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS,
(xdrproc_t) xdr_remote_domain_create_with_flags_args,
(char *) &args,
(xdrproc_t) xdr_remote_domain_create_with_flags_ret,
(char *) &ret) == -1)
goto done;
domain->id = ret.dom.id;
xdr_free ((xdrproc_t) &xdr_remote_domain_create_with_flags_ret,
(char *) &ret);
rv = 0;
done:
remoteDriverUnlock(priv);
return rv;
}
static virDomainPtr
remoteDomainDefineXML (virConnectPtr conn, const char *xml)
{
@ -10215,7 +10247,7 @@ static virDriver remote_driver = {
remoteListDefinedDomains, /* listDefinedDomains */
remoteNumOfDefinedDomains, /* numOfDefinedDomains */
remoteDomainCreate, /* domainCreate */
NULL, /* domainCreateWithFlags */
remoteDomainCreateWithFlags, /* domainCreateWithFlags */
remoteDomainDefineXML, /* domainDefineXML */
remoteDomainUndefine, /* domainUndefine */
remoteDomainAttachDevice, /* domainAttachDevice */

View File

@ -1202,6 +1202,26 @@ xdr_remote_domain_create_args (XDR *xdrs, remote_domain_create_args *objp)
return TRUE;
}
bool_t
xdr_remote_domain_create_with_flags_args (XDR *xdrs, remote_domain_create_with_flags_args *objp)
{
if (!xdr_remote_nonnull_domain (xdrs, &objp->dom))
return FALSE;
if (!xdr_u_int (xdrs, &objp->flags))
return FALSE;
return TRUE;
}
bool_t
xdr_remote_domain_create_with_flags_ret (XDR *xdrs, remote_domain_create_with_flags_ret *objp)
{
if (!xdr_remote_nonnull_domain (xdrs, &objp->dom))
return FALSE;
return TRUE;
}
bool_t
xdr_remote_domain_define_xml_args (XDR *xdrs, remote_domain_define_xml_args *objp)
{

View File

@ -666,6 +666,17 @@ struct remote_domain_create_args {
};
typedef struct remote_domain_create_args remote_domain_create_args;
struct remote_domain_create_with_flags_args {
remote_nonnull_domain dom;
u_int flags;
};
typedef struct remote_domain_create_with_flags_args remote_domain_create_with_flags_args;
struct remote_domain_create_with_flags_ret {
remote_nonnull_domain dom;
};
typedef struct remote_domain_create_with_flags_ret remote_domain_create_with_flags_ret;
struct remote_domain_define_xml_args {
remote_nonnull_string xml;
};
@ -2215,6 +2226,7 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_SNAPSHOT_DELETE = 193,
REMOTE_PROC_DOMAIN_GET_BLOCK_INFO = 194,
REMOTE_PROC_DOMAIN_EVENT_IO_ERROR_REASON = 195,
REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS = 196,
};
typedef enum remote_procedure remote_procedure;
@ -2345,6 +2357,8 @@ extern bool_t xdr_remote_list_defined_domains_args (XDR *, remote_list_defined_
extern bool_t xdr_remote_list_defined_domains_ret (XDR *, remote_list_defined_domains_ret*);
extern bool_t xdr_remote_num_of_defined_domains_ret (XDR *, remote_num_of_defined_domains_ret*);
extern bool_t xdr_remote_domain_create_args (XDR *, remote_domain_create_args*);
extern bool_t xdr_remote_domain_create_with_flags_args (XDR *, remote_domain_create_with_flags_args*);
extern bool_t xdr_remote_domain_create_with_flags_ret (XDR *, remote_domain_create_with_flags_ret*);
extern bool_t xdr_remote_domain_define_xml_args (XDR *, remote_domain_define_xml_args*);
extern bool_t xdr_remote_domain_define_xml_ret (XDR *, remote_domain_define_xml_ret*);
extern bool_t xdr_remote_domain_undefine_args (XDR *, remote_domain_undefine_args*);
@ -2678,6 +2692,8 @@ extern bool_t xdr_remote_list_defined_domains_args ();
extern bool_t xdr_remote_list_defined_domains_ret ();
extern bool_t xdr_remote_num_of_defined_domains_ret ();
extern bool_t xdr_remote_domain_create_args ();
extern bool_t xdr_remote_domain_create_with_flags_args ();
extern bool_t xdr_remote_domain_create_with_flags_ret ();
extern bool_t xdr_remote_domain_define_xml_args ();
extern bool_t xdr_remote_domain_define_xml_ret ();
extern bool_t xdr_remote_domain_undefine_args ();

View File

@ -3,7 +3,7 @@
* remote_internal driver and libvirtd. This protocol is
* internal and may change at any time.
*
* Copyright (C) 2006-2008 Red Hat, Inc.
* Copyright (C) 2006-2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -696,6 +696,15 @@ struct remote_domain_create_args {
remote_nonnull_domain dom;
};
struct remote_domain_create_with_flags_args {
remote_nonnull_domain dom;
unsigned int flags;
};
struct remote_domain_create_with_flags_ret {
remote_nonnull_domain dom;
};
struct remote_domain_define_xml_args {
remote_nonnull_string xml;
};
@ -2004,7 +2013,8 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_REVERT_TO_SNAPSHOT = 192,
REMOTE_PROC_DOMAIN_SNAPSHOT_DELETE = 193,
REMOTE_PROC_DOMAIN_GET_BLOCK_INFO = 194,
REMOTE_PROC_DOMAIN_EVENT_IO_ERROR_REASON = 195
REMOTE_PROC_DOMAIN_EVENT_IO_ERROR_REASON = 195,
REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS = 196
/*
* Notice how the entries are grouped in sets of 10 ?

View File

@ -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;
u_int flags;
};
struct remote_domain_create_with_flags_ret {
remote_nonnull_domain dom;
};
struct remote_domain_define_xml_args {
remote_nonnull_string xml;
};