mirror of https://gitee.com/openkylin/libvirt.git
Introduce remote protocol support for virDomainCreate{XML}WithFiles
Since they make use of file descriptor passing, the remote protocol methods for virDomainCreate{XML}WithFiles must be written by hand. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
d76227bea3
commit
bfd663ef97
104
daemon/remote.c
104
daemon/remote.c
|
@ -4891,6 +4891,110 @@ cleanup:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int remoteDispatchDomainCreateXMLWithFiles(
|
||||||
|
virNetServerPtr server ATTRIBUTE_UNUSED,
|
||||||
|
virNetServerClientPtr client,
|
||||||
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
||||||
|
virNetMessageErrorPtr rerr,
|
||||||
|
remote_domain_create_xml_with_files_args *args,
|
||||||
|
remote_domain_create_xml_with_files_ret *ret)
|
||||||
|
{
|
||||||
|
int rv = -1;
|
||||||
|
virDomainPtr dom = NULL;
|
||||||
|
struct daemonClientPrivate *priv =
|
||||||
|
virNetServerClientGetPrivateData(client);
|
||||||
|
int *files = NULL;
|
||||||
|
unsigned int nfiles = 0;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (!priv->conn) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (VIR_ALLOC_N(files, msg->nfds) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
for (i = 0; i < msg->nfds; i++) {
|
||||||
|
if ((files[i] = virNetMessageDupFD(msg, i)) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
nfiles++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((dom = virDomainCreateXMLWithFiles(priv->conn, args->xml_desc,
|
||||||
|
nfiles, files,
|
||||||
|
args->flags)) == NULL)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
make_nonnull_domain(&ret->dom, dom);
|
||||||
|
rv = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
for (i = 0; i < nfiles; i++) {
|
||||||
|
VIR_FORCE_CLOSE(files[i]);
|
||||||
|
}
|
||||||
|
VIR_FREE(files);
|
||||||
|
if (rv < 0)
|
||||||
|
virNetMessageSaveError(rerr);
|
||||||
|
if (dom)
|
||||||
|
virDomainFree(dom);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int remoteDispatchDomainCreateWithFiles(
|
||||||
|
virNetServerPtr server ATTRIBUTE_UNUSED,
|
||||||
|
virNetServerClientPtr client,
|
||||||
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
||||||
|
virNetMessageErrorPtr rerr,
|
||||||
|
remote_domain_create_with_files_args *args,
|
||||||
|
remote_domain_create_with_files_ret *ret)
|
||||||
|
{
|
||||||
|
int rv = -1;
|
||||||
|
virDomainPtr dom = NULL;
|
||||||
|
struct daemonClientPrivate *priv =
|
||||||
|
virNetServerClientGetPrivateData(client);
|
||||||
|
int *files = NULL;
|
||||||
|
unsigned int nfiles = 0;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (!priv->conn) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (VIR_ALLOC_N(files, msg->nfds) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
for (i = 0; i < msg->nfds; i++) {
|
||||||
|
if ((files[i] = virNetMessageDupFD(msg, i)) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
nfiles++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (virDomainCreateWithFiles(dom,
|
||||||
|
nfiles, files,
|
||||||
|
args->flags) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
make_nonnull_domain(&ret->dom, dom);
|
||||||
|
rv = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
for (i = 0; i < nfiles; i++) {
|
||||||
|
VIR_FORCE_CLOSE(files[i]);
|
||||||
|
}
|
||||||
|
VIR_FREE(files);
|
||||||
|
if (rv < 0)
|
||||||
|
virNetMessageSaveError(rerr);
|
||||||
|
if (dom)
|
||||||
|
virDomainFree(dom);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*----- Helpers. -----*/
|
/*----- Helpers. -----*/
|
||||||
|
|
||||||
/* get_nonnull_domain and get_nonnull_network turn an on-wire
|
/* get_nonnull_domain and get_nonnull_network turn an on-wire
|
||||||
|
|
|
@ -6387,6 +6387,75 @@ cleanup:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static virDomainPtr
|
||||||
|
remoteDomainCreateXMLWithFiles(virConnectPtr conn, const char *xml_desc,
|
||||||
|
unsigned int nfiles, int *files, unsigned int flags)
|
||||||
|
{
|
||||||
|
virDomainPtr rv = NULL;
|
||||||
|
struct private_data *priv = conn->privateData;
|
||||||
|
remote_domain_create_xml_with_files_args args;
|
||||||
|
remote_domain_create_xml_with_files_ret ret;
|
||||||
|
|
||||||
|
remoteDriverLock(priv);
|
||||||
|
|
||||||
|
args.xml_desc = (char *)xml_desc;
|
||||||
|
args.flags = flags;
|
||||||
|
|
||||||
|
memset(&ret, 0, sizeof(ret));
|
||||||
|
|
||||||
|
if (callFull(conn, priv, 0,
|
||||||
|
files, nfiles,
|
||||||
|
NULL, NULL,
|
||||||
|
REMOTE_PROC_DOMAIN_CREATE_XML_WITH_FILES,
|
||||||
|
(xdrproc_t)xdr_remote_domain_create_xml_with_files_args, (char *)&args,
|
||||||
|
(xdrproc_t)xdr_remote_domain_create_xml_with_files_ret, (char *)&ret) == -1) {
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
rv = get_nonnull_domain(conn, ret.dom);
|
||||||
|
xdr_free((xdrproc_t)xdr_remote_domain_create_xml_with_files_ret, (char *)&ret);
|
||||||
|
|
||||||
|
done:
|
||||||
|
remoteDriverUnlock(priv);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
remoteDomainCreateWithFiles(virDomainPtr dom,
|
||||||
|
unsigned int nfiles, int *files,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
int rv = -1;
|
||||||
|
struct private_data *priv = dom->conn->privateData;
|
||||||
|
remote_domain_create_with_files_args args;
|
||||||
|
remote_domain_create_with_files_ret ret;
|
||||||
|
|
||||||
|
remoteDriverLock(priv);
|
||||||
|
|
||||||
|
make_nonnull_domain(&args.dom, dom);
|
||||||
|
args.flags = flags;
|
||||||
|
|
||||||
|
memset(&ret, 0, sizeof(ret));
|
||||||
|
|
||||||
|
if (callFull(dom->conn, priv, 0,
|
||||||
|
files, nfiles,
|
||||||
|
NULL, NULL,
|
||||||
|
REMOTE_PROC_DOMAIN_CREATE_WITH_FILES,
|
||||||
|
(xdrproc_t)xdr_remote_domain_create_with_files_args, (char *)&args,
|
||||||
|
(xdrproc_t)xdr_remote_domain_create_with_files_ret, (char *)&ret) == -1) {
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
dom->id = ret.dom.id;
|
||||||
|
xdr_free((xdrproc_t) &xdr_remote_domain_create_with_files_ret, (char *) &ret);
|
||||||
|
rv = 0;
|
||||||
|
|
||||||
|
done:
|
||||||
|
remoteDriverUnlock(priv);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
remoteDomainEventQueue(struct private_data *priv, virDomainEventPtr event)
|
remoteDomainEventQueue(struct private_data *priv, virDomainEventPtr event)
|
||||||
{
|
{
|
||||||
|
@ -6544,6 +6613,7 @@ static virDriver remote_driver = {
|
||||||
.connectNumOfDomains = remoteConnectNumOfDomains, /* 0.3.0 */
|
.connectNumOfDomains = remoteConnectNumOfDomains, /* 0.3.0 */
|
||||||
.connectListAllDomains = remoteConnectListAllDomains, /* 0.9.13 */
|
.connectListAllDomains = remoteConnectListAllDomains, /* 0.9.13 */
|
||||||
.domainCreateXML = remoteDomainCreateXML, /* 0.3.0 */
|
.domainCreateXML = remoteDomainCreateXML, /* 0.3.0 */
|
||||||
|
.domainCreateXMLWithFiles = remoteDomainCreateXMLWithFiles, /* 1.1.1 */
|
||||||
.domainLookupByID = remoteDomainLookupByID, /* 0.3.0 */
|
.domainLookupByID = remoteDomainLookupByID, /* 0.3.0 */
|
||||||
.domainLookupByUUID = remoteDomainLookupByUUID, /* 0.3.0 */
|
.domainLookupByUUID = remoteDomainLookupByUUID, /* 0.3.0 */
|
||||||
.domainLookupByName = remoteDomainLookupByName, /* 0.3.0 */
|
.domainLookupByName = remoteDomainLookupByName, /* 0.3.0 */
|
||||||
|
@ -6598,6 +6668,7 @@ static virDriver remote_driver = {
|
||||||
.connectNumOfDefinedDomains = remoteConnectNumOfDefinedDomains, /* 0.3.0 */
|
.connectNumOfDefinedDomains = remoteConnectNumOfDefinedDomains, /* 0.3.0 */
|
||||||
.domainCreate = remoteDomainCreate, /* 0.3.0 */
|
.domainCreate = remoteDomainCreate, /* 0.3.0 */
|
||||||
.domainCreateWithFlags = remoteDomainCreateWithFlags, /* 0.8.2 */
|
.domainCreateWithFlags = remoteDomainCreateWithFlags, /* 0.8.2 */
|
||||||
|
.domainCreateWithFiles = remoteDomainCreateWithFiles, /* 1.1.1 */
|
||||||
.domainDefineXML = remoteDomainDefineXML, /* 0.3.0 */
|
.domainDefineXML = remoteDomainDefineXML, /* 0.3.0 */
|
||||||
.domainUndefine = remoteDomainUndefine, /* 0.3.0 */
|
.domainUndefine = remoteDomainUndefine, /* 0.3.0 */
|
||||||
.domainUndefineFlags = remoteDomainUndefineFlags, /* 0.9.4 */
|
.domainUndefineFlags = remoteDomainUndefineFlags, /* 0.9.4 */
|
||||||
|
|
|
@ -734,6 +734,15 @@ struct remote_domain_create_xml_ret {
|
||||||
remote_nonnull_domain dom;
|
remote_nonnull_domain dom;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct remote_domain_create_xml_with_files_args {
|
||||||
|
remote_nonnull_string xml_desc;
|
||||||
|
unsigned int flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct remote_domain_create_xml_with_files_ret {
|
||||||
|
remote_nonnull_domain dom;
|
||||||
|
};
|
||||||
|
|
||||||
struct remote_domain_lookup_by_id_args {
|
struct remote_domain_lookup_by_id_args {
|
||||||
int id;
|
int id;
|
||||||
};
|
};
|
||||||
|
@ -995,6 +1004,15 @@ struct remote_domain_create_with_flags_ret {
|
||||||
remote_nonnull_domain dom;
|
remote_nonnull_domain dom;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct remote_domain_create_with_files_args {
|
||||||
|
remote_nonnull_domain dom;
|
||||||
|
unsigned int flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct remote_domain_create_with_files_ret {
|
||||||
|
remote_nonnull_domain dom;
|
||||||
|
};
|
||||||
|
|
||||||
struct remote_domain_define_xml_args {
|
struct remote_domain_define_xml_args {
|
||||||
remote_nonnull_string xml;
|
remote_nonnull_string xml;
|
||||||
};
|
};
|
||||||
|
@ -4958,5 +4976,18 @@ enum remote_procedure {
|
||||||
* @acl: domain:save:!VIR_DOMAIN_AFFECT_CONFIG|VIR_DOMAIN_AFFECT_LIVE
|
* @acl: domain:save:!VIR_DOMAIN_AFFECT_CONFIG|VIR_DOMAIN_AFFECT_LIVE
|
||||||
* @acl: domain:save:VIR_DOMAIN_AFFECT_CONFIG
|
* @acl: domain:save:VIR_DOMAIN_AFFECT_CONFIG
|
||||||
*/
|
*/
|
||||||
REMOTE_PROC_DOMAIN_SET_MEMORY_STATS_PERIOD = 308
|
REMOTE_PROC_DOMAIN_SET_MEMORY_STATS_PERIOD = 308,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @generate: none
|
||||||
|
* @acl: domain:write
|
||||||
|
* @acl: domain:start
|
||||||
|
*/
|
||||||
|
REMOTE_PROC_DOMAIN_CREATE_XML_WITH_FILES = 309,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @generate: none
|
||||||
|
* @acl: domain:start
|
||||||
|
*/
|
||||||
|
REMOTE_PROC_DOMAIN_CREATE_WITH_FILES = 310
|
||||||
};
|
};
|
||||||
|
|
|
@ -423,6 +423,13 @@ struct remote_domain_create_xml_args {
|
||||||
struct remote_domain_create_xml_ret {
|
struct remote_domain_create_xml_ret {
|
||||||
remote_nonnull_domain dom;
|
remote_nonnull_domain dom;
|
||||||
};
|
};
|
||||||
|
struct remote_domain_create_xml_with_files_args {
|
||||||
|
remote_nonnull_string xml_desc;
|
||||||
|
u_int flags;
|
||||||
|
};
|
||||||
|
struct remote_domain_create_xml_with_files_ret {
|
||||||
|
remote_nonnull_domain dom;
|
||||||
|
};
|
||||||
struct remote_domain_lookup_by_id_args {
|
struct remote_domain_lookup_by_id_args {
|
||||||
int id;
|
int id;
|
||||||
};
|
};
|
||||||
|
@ -650,6 +657,13 @@ struct remote_domain_create_with_flags_args {
|
||||||
struct remote_domain_create_with_flags_ret {
|
struct remote_domain_create_with_flags_ret {
|
||||||
remote_nonnull_domain dom;
|
remote_nonnull_domain dom;
|
||||||
};
|
};
|
||||||
|
struct remote_domain_create_with_files_args {
|
||||||
|
remote_nonnull_domain dom;
|
||||||
|
u_int flags;
|
||||||
|
};
|
||||||
|
struct remote_domain_create_with_files_ret {
|
||||||
|
remote_nonnull_domain dom;
|
||||||
|
};
|
||||||
struct remote_domain_define_xml_args {
|
struct remote_domain_define_xml_args {
|
||||||
remote_nonnull_string xml;
|
remote_nonnull_string xml;
|
||||||
};
|
};
|
||||||
|
@ -2607,4 +2621,6 @@ enum remote_procedure {
|
||||||
REMOTE_PROC_DOMAIN_MIGRATE_FINISH3_PARAMS = 306,
|
REMOTE_PROC_DOMAIN_MIGRATE_FINISH3_PARAMS = 306,
|
||||||
REMOTE_PROC_DOMAIN_MIGRATE_CONFIRM3_PARAMS = 307,
|
REMOTE_PROC_DOMAIN_MIGRATE_CONFIRM3_PARAMS = 307,
|
||||||
REMOTE_PROC_DOMAIN_SET_MEMORY_STATS_PERIOD = 308,
|
REMOTE_PROC_DOMAIN_SET_MEMORY_STATS_PERIOD = 308,
|
||||||
|
REMOTE_PROC_DOMAIN_CREATE_XML_WITH_FILES = 309,
|
||||||
|
REMOTE_PROC_DOMAIN_CREATE_WITH_FILES = 310,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue