]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
parallels: don't add domain to the list twice
authorDmitry Guryanov <dguryanov@parallels.com>
Wed, 23 Apr 2014 14:35:02 +0000 (18:35 +0400)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 7 May 2014 13:56:39 +0000 (14:56 +0100)
There is a problem with function parallelsDomainDefineXML. If we
are defining a new domain, then we need to do 2 things: aclually
create a VM in PCS and add new domain to the cached list of domains
_parallelsConn.domains.

This is done in the function parallelsLoadDomains. So call to
virDomainObjListAdd will return a error, because a domain
with the same name and id will already be in the list.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
src/parallels/parallels_driver.c

index 1c58b456fbd532e73d097ed9a4b238dba42f191e..4ab3e1c3acafc9cb6f70c05f13f790237f21c9c3 100644 (file)
@@ -2303,7 +2303,7 @@ parallelsDomainDefineXML(virConnectPtr conn, const char *xml)
     parallelsConnPtr privconn = conn->privateData;
     virDomainPtr ret = NULL;
     virDomainDefPtr def;
-    virDomainObjPtr dom = NULL, olddom = NULL;
+    virDomainObjPtr olddom = NULL;
 
     parallelsDriverLock(privconn);
     if ((def = virDomainDefParseString(xml, privconn->caps, privconn->xmlopt,
@@ -2345,24 +2345,12 @@ parallelsDomainDefineXML(virConnectPtr conn, const char *xml)
     }
     virObjectUnlock(olddom);
 
-    if (!(dom = virDomainObjListAdd(privconn->domains, def,
-                                    privconn->xmlopt,
-                                    0, NULL))) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Can't allocate domobj"));
-        goto cleanup;
-    }
-
-    def = NULL;
-
-    ret = virGetDomain(conn, dom->def->name, dom->def->uuid);
+    ret = virGetDomain(conn, def->name, def->uuid);
     if (ret)
-        ret->id = dom->def->id;
+        ret->id = def->id;
 
  cleanup:
     virDomainDefFree(def);
-    if (dom)
-        virObjectUnlock(dom);
     parallelsDriverUnlock(privconn);
     return ret;
 }