]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: Clean up stateFile if refreshPool fails
authorJohn Ferlan <jferlan@redhat.com>
Wed, 12 Sep 2018 12:29:32 +0000 (08:29 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 20 Sep 2018 11:49:19 +0000 (07:49 -0400)
If the virStoragePoolRefresh fails and we call stopPool, the
code neglected to clean up the state file leading to the next
libvirtd restart attempting to start the pool. For a transient
pool this could make it unexpectedly reappear.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
src/storage/storage_driver.c

index e0023cf0353abe208994089b3c519a181b941786..301a9d7292534c4aaf510903eb073adbf0cba2aa 100644 (file)
@@ -1171,8 +1171,13 @@ storagePoolRefresh(virStoragePoolPtr pool,
 
     virStoragePoolObjClearVols(obj);
     if (backend->refreshPool(obj) < 0) {
+        char *stateFile = virFileBuildPath(driver->stateDir, def->name, ".xml");
+
+        if (stateFile)
+            unlink(stateFile);
         if (backend->stopPool)
             backend->stopPool(obj);
+        VIR_FREE(stateFile);
 
         event = virStoragePoolEventLifecycleNew(def->name,
                                                 def->uuid,