[PATCH] storage: Check and possibly update config file after build

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

 



https://bugzilla.redhat.com/show_bug.cgi?id=1464313

As it turns out, the on-disk config file (e.g. not the stateDir file)
needs to be updated when --override is provided since it's possible and
highly probable that the def->source.format has been adjusted and could
cause a future start after perhaps a libvirtd restart to have the older
format from a define operation from the backend.

So in the 2 places where it's possible a write would be needed (create
after define and build), let's perform a check and do the save/write
operation on the configFile if it's necessary.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/storage/storage_driver.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 7cf5943..afb0404 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -651,6 +651,22 @@ storagePoolIsPersistent(virStoragePoolPtr pool)
 }
 
 
+/* After a pool build, it's possible the inactive configFile needs to
+ * be updated especially since overwriting the pool more than likely
+ * changes the source format and may change/update a few other fields. */
+static int
+storagePoolBuildCheckUpdateConfig(virStoragePoolObjPtr obj,
+                                  unsigned int flags)
+{
+    int ret = 0;
+
+    if ((flags & VIR_STORAGE_POOL_BUILD_OVERWRITE) && obj->configFile)
+        ret = virStoragePoolSaveConfig(obj->configFile, obj->def);
+
+    return ret;
+}
+
+
 static virStoragePoolPtr
 storagePoolCreateXML(virConnectPtr conn,
                      const char *xml,
@@ -916,6 +932,9 @@ storagePoolCreate(virStoragePoolPtr pool,
             if (backend->buildPool(pool->conn, obj, build_flags) < 0)
                 goto cleanup;
         }
+
+        if (storagePoolBuildCheckUpdateConfig(obj, build_flags) < 0)
+            goto cleanup;
     }
 
     VIR_INFO("Starting up storage pool '%s'", obj->def->name);
@@ -980,6 +999,10 @@ storagePoolBuild(virStoragePoolPtr pool,
     if (backend->buildPool &&
         backend->buildPool(pool->conn, obj, flags) < 0)
         goto cleanup;
+
+    if (storagePoolBuildCheckUpdateConfig(obj, flags) < 0)
+        goto cleanup;
+
     ret = 0;
 
  cleanup:
-- 
2.9.5

--
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]
  Powered by Linux