1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

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 <clalance@redhat.com>
This commit is contained in:
Chris Lalancette 2010-04-02 10:41:47 -04:00
parent 9b55a52b4f
commit 32c3c1f0b7

View File

@ -6151,22 +6151,25 @@ static virDomainObjPtr virDomainLoadConfig(virCapsPtr caps,
if ((configFile = virDomainConfigFile(configDir, name)) == NULL)
goto error;
if (!(def = virDomainDefParseFile(caps, configFile,
VIR_DOMAIN_XML_INACTIVE)))
goto error;
/* 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 (!(def = virDomainDefParseFile(caps, configFile,
VIR_DOMAIN_XML_INACTIVE)))
goto error;
if ((dom = virDomainFindByName(doms, def->name))) {
virDomainObjUnlock(dom);
dom = NULL;
newVM = 0;
}
if (!(dom = virDomainAssignDef(caps, doms, def, false)))
goto error;