From: Chris Lalancette Date: Fri, 2 Apr 2010 14:41:47 +0000 (-0400) Subject: Only assign newDef when we have a new def. X-Git-Tag: v0.8.0~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32c3c1f0b7f5257903cca0028f9723b9365ca0a7;p=thirdparty%2Flibvirt.git Only assign newDef when we have a new def. While playing around with def/newDef with the qemu code, I noticed that newDef was *always* getting set to a value, even when I didn't redefine the domain. I think the problem is the virDomainLoadConfig is always doing virDomainAssignDef regardless of whether the domain already exists in the hashtable. In turn, virDomainAssignDef is assigning the definition (which is actually a duplicate) to newDef. Fix this so that newDef stays NULL until we actually have a new def. Signed-off-by: Chris Lalancette --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 41c83fde08..3cd43eb050 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6151,22 +6151,25 @@ static virDomainObjPtr virDomainLoadConfig(virCapsPtr caps, if ((configFile = virDomainConfigFile(configDir, name)) == NULL) goto error; - if ((autostartLink = virDomainConfigFile(autostartDir, name)) == NULL) - goto error; - - if ((autostart = virFileLinkPointsTo(autostartLink, configFile)) < 0) - goto error; - if (!(def = virDomainDefParseFile(caps, configFile, VIR_DOMAIN_XML_INACTIVE))) goto error; - if ((dom = virDomainFindByName(doms, def->name))) { - virDomainObjUnlock(dom); - dom = NULL; - newVM = 0; + /* if the domain is already in our hashtable, we don't need to do + * anything further + */ + if ((dom = virDomainFindByUUID(doms, def->uuid))) { + VIR_FREE(configFile); + virDomainDefFree(def); + return dom; } + if ((autostartLink = virDomainConfigFile(autostartDir, name)) == NULL) + goto error; + + if ((autostart = virFileLinkPointsTo(autostartLink, configFile)) < 0) + goto error; + if (!(dom = virDomainAssignDef(caps, doms, def, false))) goto error;