[PATCH 2/4] storage: Don't leave stale state file if pool startup fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



After pool startup we call refreshPool(). If that fails, we leave
a stale pool state file hanging around.

Hit this trying to create a pool with qemu:///session containing
root owned files.
---
 src/storage/storage_driver.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 3b7746b..06686bf 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -180,6 +180,8 @@ storageDriverAutostart(void)
                 virStoragePoolSaveState(stateFile, pool->def) < 0 ||
                 backend->refreshPool(conn, pool) < 0) {
                 virErrorPtr err = virGetLastError();
+                if (stateFile)
+                    unlink(stateFile);
                 if (backend->stopPool)
                     backend->stopPool(conn, pool);
                 VIR_ERROR(_("Failed to autostart storage pool '%s': %s"),
@@ -690,6 +692,8 @@ storagePoolCreateXML(virConnectPtr conn,
 
     if (!stateFile || virStoragePoolSaveState(stateFile, pool->def) < 0 ||
         backend->refreshPool(conn, pool) < 0) {
+        if (stateFile)
+            unlink(stateFile);
         if (backend->stopPool)
             backend->stopPool(conn, pool);
         virStoragePoolObjRemove(&driver->pools, pool);
@@ -856,6 +860,8 @@ storagePoolCreate(virStoragePoolPtr obj,
 
     if (!stateFile || virStoragePoolSaveState(stateFile, pool->def) < 0 ||
         backend->refreshPool(obj->conn, pool) < 0) {
+        if (stateFile)
+            unlink(stateFile);
         if (backend->stopPool)
             backend->stopPool(obj->conn, pool);
         goto cleanup;
-- 
2.3.6

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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]