提交 03d813bb 编写于 作者: M Marek Marczykowski 提交者: Michal Privoznik

remote: fix dom->id after virDomainCreateWithFlags

The same issue as (already fixed) in virDomainCreate -
REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS doesn't return new domain ID, only
-1 on error or 0 on success.

Besides this one fix it is more general problem - local domain object
ID can desynchronize with the real one, for example in case of another
client creates/destroys domain in the meantime. Perhaps virDomainGetID
should be called remotely (with all performance implications...)? Or
some event-based notification used?
Signed-off-by: NMarek Marczykowski <marmarek@invisiblethingslab.com>
上级 47562282
......@@ -2400,6 +2400,46 @@ done:
return rv;
}
static int
remoteDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
{
int rv = -1;
struct private_data *priv = dom->conn->privateData;
remote_domain_create_with_flags_args args;
remote_domain_lookup_by_uuid_args args2;
remote_domain_lookup_by_uuid_ret ret2;
remoteDriverLock(priv);
make_nonnull_domain(&args.dom, dom);
args.flags = flags;
if (call(dom->conn, priv, 0, REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS,
(xdrproc_t)xdr_remote_domain_create_with_flags_args, (char *)&args,
(xdrproc_t)xdr_void, (char *)NULL) == -1) {
goto done;
}
/* Need to do a lookup figure out ID of newly started guest, because
* bug in design of REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS means we aren't getting
* it returned.
*/
memcpy(args2.uuid, dom->uuid, VIR_UUID_BUFLEN);
memset(&ret2, 0, sizeof(ret2));
if (call(dom->conn, priv, 0, REMOTE_PROC_DOMAIN_LOOKUP_BY_UUID,
(xdrproc_t) xdr_remote_domain_lookup_by_uuid_args, (char *) &args2,
(xdrproc_t) xdr_remote_domain_lookup_by_uuid_ret, (char *) &ret2) == -1)
goto done;
dom->id = ret2.dom.id;
xdr_free((xdrproc_t) &xdr_remote_domain_lookup_by_uuid_ret, (char *) &ret2);
rv = 0;
done:
remoteDriverUnlock(priv);
return rv;
}
static char *
remoteDomainGetSchedulerType(virDomainPtr domain, int *nparams)
{
......
......@@ -3875,7 +3875,7 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_EVENT_IO_ERROR_REASON = 195,
/**
* @generate: both
* @generate: server
*/
REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS = 196,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册