https://bugzilla.redhat.com/show_bug.cgi?id=1160926
Introduce the ability to save a configuration of a persistent configuration
that may be changed by storage pool backend activity, such as start or stop
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/conf/storage_conf.c | 37 ++++++++++++++++++++++---------------
src/conf/storage_conf.h | 2 ++
src/libvirt_private.syms | 1 +
3 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 52656e5..4126451 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1884,14 +1884,33 @@ virStoragePoolLoadAllConfigs(virStoragePoolObjListPtr pools,
}
int
-virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
- virStoragePoolObjPtr pool,
+virStoragePoolSaveConfig(const char *configFile,
virStoragePoolDefPtr def)
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
char *xml;
int ret = -1;
+ if (!(xml = virStoragePoolDefFormat(def))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("failed to generate XML"));
+ return -1;
+ }
+
+ virUUIDFormat(def->uuid, uuidstr);
+ ret = virXMLSaveFile(configFile,
+ virXMLPickShellSafeComment(def->name, uuidstr),
+ "pool-edit", xml);
+ VIR_FREE(xml);
+
+ return ret;
+}
+
+int
+virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
+ virStoragePoolObjPtr pool,
+ virStoragePoolDefPtr def)
+{
if (!pool->configFile) {
if (virFileMakePath(driver->configDir) < 0) {
virReportSystemError(errno,
@@ -1912,19 +1931,7 @@ virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
}
}
- if (!(xml = virStoragePoolDefFormat(def))) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("failed to generate XML"));
- return -1;
- }
-
- virUUIDFormat(def->uuid, uuidstr);
- ret = virXMLSaveFile(pool->configFile,
- virXMLPickShellSafeComment(def->name, uuidstr),
- "pool-edit", xml);
- VIR_FREE(xml);
-
- return ret;
+ return virStoragePoolSaveConfig(pool->configFile, def);
}
int
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index a9b5bdb..67145a0 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -360,6 +360,8 @@ virStoragePoolObjPtr
virStoragePoolObjAssignDef(virStoragePoolObjListPtr pools,
virStoragePoolDefPtr def);
+int virStoragePoolSaveConfig(const char *configDir,
+ virStoragePoolDefPtr def);
int virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
virStoragePoolObjPtr pool,
virStoragePoolDefPtr def);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b8f35e8..0864618 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -753,6 +753,7 @@ virStoragePoolObjLock;
virStoragePoolObjRemove;
virStoragePoolObjSaveDef;
virStoragePoolObjUnlock;
+virStoragePoolSaveConfig;
virStoragePoolSourceAdapterTypeFromString;
virStoragePoolSourceAdapterTypeToString;
virStoragePoolSourceClear;
--
1.9.3