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

John Ferlan posted 5 patches 7 years, 4 months ago
[libvirt] [PATCH 1/5] storage: Clean up stateFile if refreshPool fails
Posted by John Ferlan 7 years, 4 months ago
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>
---
 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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list