mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
storage: Introduce virStoragePoolSaveConfig
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
This commit is contained in:
parent
5b226fcdc6
commit
523c6908f8
@ -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
|
||||
|
@ -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);
|
||||
|
@ -753,6 +753,7 @@ virStoragePoolObjLock;
|
||||
virStoragePoolObjRemove;
|
||||
virStoragePoolObjSaveDef;
|
||||
virStoragePoolObjUnlock;
|
||||
virStoragePoolSaveConfig;
|
||||
virStoragePoolSourceAdapterTypeFromString;
|
||||
virStoragePoolSourceAdapterTypeToString;
|
||||
virStoragePoolSourceClear;
|
||||
|
Loading…
Reference in New Issue
Block a user