[libvirt] [PATCH 1/5] storage: Clean up stateFile if refreshPool fails

John Ferlan jferlan at redhat.com
Wed Sep 12 16:08:59 UTC 2018


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 at redhat.com>
---
 src/storage/storage_driver.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 8943df1f84..1dbeb213e3 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -1174,8 +1174,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,
-- 
2.17.1




More information about the libvir-list mailing list