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:
Erik Skultety 2015-04-02 16:41:51 +02:00
parent 6ae1190956
commit 39b183b483
3 changed files with 37 additions and 0 deletions

View File

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

View File

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

View File

@ -824,6 +824,7 @@ virStoragePoolObjRemove;
virStoragePoolObjSaveDef;
virStoragePoolObjUnlock;
virStoragePoolSaveConfig;
virStoragePoolSaveState;
virStoragePoolSourceAdapterTypeFromString;
virStoragePoolSourceAdapterTypeToString;
virStoragePoolSourceClear;