|
|
9119d9 |
From 3eec7952223f0d0277fb6d258806d48d6052aff2 Mon Sep 17 00:00:00 2001
|
|
|
9119d9 |
Message-Id: <3eec7952223f0d0277fb6d258806d48d6052aff2@dist-git>
|
|
|
9119d9 |
From: John Ferlan <jferlan@redhat.com>
|
|
|
9119d9 |
Date: Wed, 12 Nov 2014 13:34:49 -0500
|
|
|
9119d9 |
Subject: [PATCH] storage: Introduce virStoragePoolSaveConfig
|
|
|
9119d9 |
|
|
|
9119d9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1160926
|
|
|
9119d9 |
|
|
|
9119d9 |
Introduce the ability to save a configuration of a persistent configuration
|
|
|
9119d9 |
that may be changed by storage pool backend activity, such as start or stop
|
|
|
9119d9 |
|
|
|
9119d9 |
(cherry picked from commit 523c6908f8c21cede0121a8fdac9ad76c01d4d1c)
|
|
|
9119d9 |
Signed-off-by: John Ferlan <jferlan@redhat.com>
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
---
|
|
|
9119d9 |
src/conf/storage_conf.c | 37 ++++++++++++++++++++++---------------
|
|
|
9119d9 |
src/conf/storage_conf.h | 2 ++
|
|
|
9119d9 |
src/libvirt_private.syms | 1 +
|
|
|
9119d9 |
3 files changed, 25 insertions(+), 15 deletions(-)
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
|
|
|
9119d9 |
index 3ceb0b5..71e152f 100644
|
|
|
9119d9 |
--- a/src/conf/storage_conf.c
|
|
|
9119d9 |
+++ b/src/conf/storage_conf.c
|
|
|
9119d9 |
@@ -1883,14 +1883,33 @@ virStoragePoolLoadAllConfigs(virStoragePoolObjListPtr pools,
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
int
|
|
|
9119d9 |
-virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
|
|
|
9119d9 |
- virStoragePoolObjPtr pool,
|
|
|
9119d9 |
+virStoragePoolSaveConfig(const char *configFile,
|
|
|
9119d9 |
virStoragePoolDefPtr def)
|
|
|
9119d9 |
{
|
|
|
9119d9 |
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
|
|
9119d9 |
char *xml;
|
|
|
9119d9 |
int ret = -1;
|
|
|
9119d9 |
|
|
|
9119d9 |
+ if (!(xml = virStoragePoolDefFormat(def))) {
|
|
|
9119d9 |
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
9119d9 |
+ _("failed to generate XML"));
|
|
|
9119d9 |
+ return -1;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+ virUUIDFormat(def->uuid, uuidstr);
|
|
|
9119d9 |
+ ret = virXMLSaveFile(configFile,
|
|
|
9119d9 |
+ virXMLPickShellSafeComment(def->name, uuidstr),
|
|
|
9119d9 |
+ "pool-edit", xml);
|
|
|
9119d9 |
+ VIR_FREE(xml);
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+ return ret;
|
|
|
9119d9 |
+}
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+int
|
|
|
9119d9 |
+virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
|
|
|
9119d9 |
+ virStoragePoolObjPtr pool,
|
|
|
9119d9 |
+ virStoragePoolDefPtr def)
|
|
|
9119d9 |
+{
|
|
|
9119d9 |
if (!pool->configFile) {
|
|
|
9119d9 |
if (virFileMakePath(driver->configDir) < 0) {
|
|
|
9119d9 |
virReportSystemError(errno,
|
|
|
9119d9 |
@@ -1911,19 +1930,7 @@ virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
|
|
|
9119d9 |
}
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
- if (!(xml = virStoragePoolDefFormat(def))) {
|
|
|
9119d9 |
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
9119d9 |
- _("failed to generate XML"));
|
|
|
9119d9 |
- return -1;
|
|
|
9119d9 |
- }
|
|
|
9119d9 |
-
|
|
|
9119d9 |
- virUUIDFormat(def->uuid, uuidstr);
|
|
|
9119d9 |
- ret = virXMLSaveFile(pool->configFile,
|
|
|
9119d9 |
- virXMLPickShellSafeComment(def->name, uuidstr),
|
|
|
9119d9 |
- "pool-edit", xml);
|
|
|
9119d9 |
- VIR_FREE(xml);
|
|
|
9119d9 |
-
|
|
|
9119d9 |
- return ret;
|
|
|
9119d9 |
+ return virStoragePoolSaveConfig(pool->configFile, def);
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
int
|
|
|
9119d9 |
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
|
|
|
9119d9 |
index a9b5bdb..67145a0 100644
|
|
|
9119d9 |
--- a/src/conf/storage_conf.h
|
|
|
9119d9 |
+++ b/src/conf/storage_conf.h
|
|
|
9119d9 |
@@ -360,6 +360,8 @@ virStoragePoolObjPtr
|
|
|
9119d9 |
virStoragePoolObjAssignDef(virStoragePoolObjListPtr pools,
|
|
|
9119d9 |
virStoragePoolDefPtr def);
|
|
|
9119d9 |
|
|
|
9119d9 |
+int virStoragePoolSaveConfig(const char *configDir,
|
|
|
9119d9 |
+ virStoragePoolDefPtr def);
|
|
|
9119d9 |
int virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
|
|
|
9119d9 |
virStoragePoolObjPtr pool,
|
|
|
9119d9 |
virStoragePoolDefPtr def);
|
|
|
9119d9 |
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|
|
|
9119d9 |
index e7eba7e..de4b128 100644
|
|
|
9119d9 |
--- a/src/libvirt_private.syms
|
|
|
9119d9 |
+++ b/src/libvirt_private.syms
|
|
|
9119d9 |
@@ -749,6 +749,7 @@ virStoragePoolObjLock;
|
|
|
9119d9 |
virStoragePoolObjRemove;
|
|
|
9119d9 |
virStoragePoolObjSaveDef;
|
|
|
9119d9 |
virStoragePoolObjUnlock;
|
|
|
9119d9 |
+virStoragePoolSaveConfig;
|
|
|
9119d9 |
virStoragePoolSourceAdapterTypeFromString;
|
|
|
9119d9 |
virStoragePoolSourceAdapterTypeToString;
|
|
|
9119d9 |
virStoragePoolSourceClear;
|
|
|
9119d9 |
--
|
|
|
9119d9 |
2.1.3
|
|
|
9119d9 |
|