First, we don't need to call prlsdkApplyConfig after
creating new VM or containers, because it's done in
functions prlsdkCreateVm and prlsdkCreateCt.
Also we don't need to calls prlsdkAddDomain here, because
new domain will be added to domains list from the events
handler.
Signed-off-by: Dmitry Guryanov <dguryanov(a)parallels.com>
---
src/parallels/parallels_driver.c | 32 ++++++++++----------------------
1 file changed, 10 insertions(+), 22 deletions(-)
diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index c9da259..5633eab 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -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,23 @@ 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
- 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)"));
- goto cleanup;
- }
- }
+ } else {
+ int ret;
- if (prlsdkApplyConfig(conn, olddom, def) < 0) {
+ ret = prlsdkApplyConfig(conn, olddom, def);
virObjectUnlock(olddom);
- goto cleanup;
+ if (ret)
+ 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:
virDomainDefFree(def);
parallelsDriverUnlock(privconn);
- return ret;
+ return retdom;
}
static int
--
1.9.3