提交 32c3c1f0 编写于 作者: C Chris Lalancette

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: NChris Lalancette <clalance@redhat.com>
上级 9b55a52b
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册