1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-26 03:21:44 +03: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:
John Ferlan 2014-11-10 12:23:46 -05:00
parent 5b226fcdc6
commit 523c6908f8
3 changed files with 25 additions and 15 deletions

View File

@ -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

View File

@ -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);

View File

@ -753,6 +753,7 @@ virStoragePoolObjLock;
virStoragePoolObjRemove;
virStoragePoolObjSaveDef;
virStoragePoolObjUnlock;
virStoragePoolSaveConfig;
virStoragePoolSourceAdapterTypeFromString;
virStoragePoolSourceAdapterTypeToString;
virStoragePoolSourceClear;