From: Erik Skultety Date: Thu, 26 Mar 2015 15:49:20 +0000 (+0100) Subject: conf: Introduce virStoragePoolSaveXML X-Git-Tag: v1.2.15-rc1~315 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=22592a3febd9a049be4faf7aa9b2ae73951c7712;p=thirdparty%2Flibvirt.git conf: Introduce virStoragePoolSaveXML Make XML definition saving more generic by moving the common code into virStoragePoolSaveXML and leave case specific code to PoolSave{Status,Config,...} functions. --- diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index b0704487de..8b1898ba1a 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -1899,11 +1899,27 @@ virStoragePoolLoadAllConfigs(virStoragePoolObjListPtr pools, return ret; } + +static int virStoragePoolSaveXML(const char *path, + virStoragePoolDefPtr def, + const char *xml) +{ + char uuidstr[VIR_UUID_STRING_BUFLEN]; + int ret = -1; + + virUUIDFormat(def->uuid, uuidstr); + ret = virXMLSaveFile(path, + virXMLPickShellSafeComment(def->name, uuidstr), + "pool-edit", xml); + + return ret; +} + + int virStoragePoolSaveConfig(const char *configFile, virStoragePoolDefPtr def) { - char uuidstr[VIR_UUID_STRING_BUFLEN]; char *xml; int ret = -1; @@ -1913,12 +1929,12 @@ virStoragePoolSaveConfig(const char *configFile, return -1; } - virUUIDFormat(def->uuid, uuidstr); - ret = virXMLSaveFile(configFile, - virXMLPickShellSafeComment(def->name, uuidstr), - "pool-edit", xml); - VIR_FREE(xml); + if (virStoragePoolSaveXML(configFile, def, xml)) + goto cleanup; + ret = 0; + cleanup: + VIR_FREE(xml); return ret; }