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(a)redhat.com>
---
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