From: Osier Yang Date: Thu, 1 Sep 2011 13:33:29 +0000 (+0800) Subject: conf: Assign newDef of active domain as persistent conf if it is NULL X-Git-Tag: v0.9.5~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4c3be5943d90a7222eeef860f4554c994b7fe0b;p=thirdparty%2Flibvirt.git conf: Assign newDef of active domain as persistent conf if it is NULL Libvirt loads the domain conf from status XML if it's running when starting up. The problem is there is no record of the original conf. (dom->newDef is NULL here). So libvirt won't be able to restore the domain conf to original one when destroying/shutdown. E.g. 1) attach a device without "--persistent" 2) restart libvirtd 3) destroy domain 4) start domain One will see the the disk still exists. This patch is to fix the peoblem by assigning persistent domain conf to dom->newDef if it's NULL and the domain is running. --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7476447677..eebcba06f9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11092,9 +11092,15 @@ static virDomainObjPtr virDomainLoadConfig(virCapsPtr caps, if ((dom = virDomainFindByUUID(doms, def->uuid))) { dom->autostart = autostart; + if (virDomainObjIsActive(dom) && + !dom->newDef) { + virDomainObjAssignDef(dom, def, false); + } else { + virDomainDefFree(def); + } + VIR_FREE(configFile); VIR_FREE(autostartLink); - virDomainDefFree(def); return dom; }