mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
conf: Introduce virStoragePoolSaveState
Introduce virStoragePoolSaveState to properly format the state XML in the same manner as virStoragePoolDefFormat, except for adding a <poolstate> ... </poolstate> around the definition. This is similar to virNetworkObjFormat used to save the live/active network information.
This commit is contained in:
parent
6ae1190956
commit
39b183b483
@ -1927,6 +1927,40 @@ static int virStoragePoolSaveXML(const char *path,
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virStoragePoolSaveState(const char *stateFile,
|
||||
virStoragePoolDefPtr def)
|
||||
{
|
||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||
int ret = -1;
|
||||
char *xml;
|
||||
|
||||
virBufferAddLit(&buf, "<poolstate>\n");
|
||||
virBufferAdjustIndent(&buf, 2);
|
||||
|
||||
if (virStoragePoolDefFormatBuf(&buf, def) < 0)
|
||||
goto error;
|
||||
|
||||
virBufferAdjustIndent(&buf, -2);
|
||||
virBufferAddLit(&buf, "</poolstate>\n");
|
||||
|
||||
if (virBufferCheckError(&buf) < 0)
|
||||
goto error;
|
||||
|
||||
if (!(xml = virBufferContentAndReset(&buf)))
|
||||
goto error;
|
||||
|
||||
if (virStoragePoolSaveXML(stateFile, def, xml))
|
||||
goto error;
|
||||
|
||||
ret = 0;
|
||||
|
||||
error:
|
||||
VIR_FREE(xml);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virStoragePoolSaveConfig(const char *configFile,
|
||||
virStoragePoolDefPtr def)
|
||||
|
@ -371,6 +371,8 @@ virStoragePoolObjPtr
|
||||
virStoragePoolObjAssignDef(virStoragePoolObjListPtr pools,
|
||||
virStoragePoolDefPtr def);
|
||||
|
||||
int virStoragePoolSaveState(const char *stateFile,
|
||||
virStoragePoolDefPtr def);
|
||||
int virStoragePoolSaveConfig(const char *configDir,
|
||||
virStoragePoolDefPtr def);
|
||||
int virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
|
||||
|
@ -824,6 +824,7 @@ virStoragePoolObjRemove;
|
||||
virStoragePoolObjSaveDef;
|
||||
virStoragePoolObjUnlock;
|
||||
virStoragePoolSaveConfig;
|
||||
virStoragePoolSaveState;
|
||||
virStoragePoolSourceAdapterTypeFromString;
|
||||
virStoragePoolSourceAdapterTypeToString;
|
||||
virStoragePoolSourceClear;
|
||||
|
Loading…
Reference in New Issue
Block a user