1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-12 13:17:58 +03:00

parallels: refactor parallelsDomainDefineXML

First, we don't need to call prlsdkApplyConfig after
creating new VM or containers, because it's done in
functions prlsdkCreateVm and prlsdkCreateCt.

No need to check, if domain exists in the list after
prlsdkAddDomain.

Also organize code, so that we can call virObjectUnlock
in one place.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
This commit is contained in:
Dmitry Guryanov 2014-12-01 18:38:54 +03:00 committed by Peter Krempa
parent 66d89199b4
commit 54a60fd70e
3 changed files with 17 additions and 23 deletions

View File

@ -661,10 +661,9 @@ static virDomainPtr
parallelsDomainDefineXML(virConnectPtr conn, const char *xml)
{
parallelsConnPtr privconn = conn->privateData;
virDomainPtr ret = NULL;
virDomainPtr retdom = NULL;
virDomainDefPtr def;
virDomainObjPtr olddom = NULL;
virDomainObjPtr dom = NULL;
parallelsDriverLock(privconn);
if ((def = virDomainDefParseString(xml, privconn->caps, privconn->xmlopt,
@ -689,34 +688,28 @@ parallelsDomainDefineXML(virConnectPtr conn, const char *xml)
_("Unsupported OS type: %s"), def->os.type);
goto cleanup;
}
dom = prlsdkAddDomain(privconn, def->uuid);
if (dom)
virObjectUnlock(dom);
else
olddom = prlsdkAddDomain(privconn, def->uuid);
if (!olddom)
goto cleanup;
olddom = virDomainObjListFindByName(privconn->domains, def->name);
if (!olddom) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Domain for '%s' is not defined after creation"),
def->name ? def->name : _("(unnamed)"));
} else {
if (prlsdkApplyConfig(conn, olddom, def))
goto cleanup;
if (prlsdkUpdateDomain(privconn, olddom))
goto cleanup;
}
}
if (prlsdkApplyConfig(conn, olddom, def) < 0) {
virObjectUnlock(olddom);
goto cleanup;
}
virObjectUnlock(olddom);
ret = virGetDomain(conn, def->name, def->uuid);
if (ret)
ret->id = def->id;
retdom = virGetDomain(conn, def->name, def->uuid);
if (retdom)
retdom->id = def->id;
cleanup:
if (olddom)
virObjectUnlock(olddom);
virDomainDefFree(def);
parallelsDriverUnlock(privconn);
return ret;
return retdom;
}
static int

View File

@ -1258,7 +1258,7 @@ prlsdkAddDomain(parallelsConnPtr privconn, const unsigned char *uuid)
return dom;
}
static int
int
prlsdkUpdateDomain(parallelsConnPtr privconn, virDomainObjPtr dom)
{
PRL_HANDLE job;

View File

@ -32,6 +32,7 @@ int
prlsdkLoadDomains(parallelsConnPtr privconn);
virDomainObjPtr
prlsdkAddDomain(parallelsConnPtr privconn, const unsigned char *uuid);
int prlsdkUpdateDomain(parallelsConnPtr privconn, virDomainObjPtr dom);
int prlsdkSubscribeToPCSEvents(parallelsConnPtr privconn);
void prlsdkUnsubscribeFromPCSEvents(parallelsConnPtr privconn);
int prlsdkStart(parallelsConnPtr privconn, PRL_HANDLE sdkdom);