]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Assign newDef of active domain as persistent conf if it is NULL
authorOsier Yang <jyang@redhat.com>
Thu, 1 Sep 2011 13:33:29 +0000 (21:33 +0800)
committerOsier Yang <jyang@redhat.com>
Tue, 20 Sep 2011 03:15:44 +0000 (11:15 +0800)
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.

src/conf/domain_conf.c

index 74764476771cae8a72ed77dd23d86c24c79a5fcc..eebcba06f91d703c2c4e8f1d693eb687e97b815f 100644 (file)
@@ -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;
     }