storagePoolDefineXML: prefer using newDef to save config file

When re-defining an active storage pool, due to a bug the config
file on disk is not changed. This is because we are passing old
definition instead of new one to virStoragePoolObjSaveDef.
This issue was introduced by bfcd8fc9,

Signed-off-by: Changkuo Shi <shi.changkuo@h3c.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Shichangkuo 2018-07-10 07:15:24 +00:00 committed by Michal Privoznik
parent fac0dacd54
commit a94bb4ebdf

View File

@ -810,13 +810,14 @@ storagePoolDefineXML(virConnectPtr conn,
if (!(obj = virStoragePoolObjAssignDef(driver->pools, newDef)))
goto cleanup;
newDef = NULL;
newDef = virStoragePoolObjGetNewDef(obj);
def = virStoragePoolObjGetDef(obj);
if (virStoragePoolObjSaveDef(driver, obj, def) < 0) {
if (virStoragePoolObjSaveDef(driver, obj, newDef ? newDef : def) < 0) {
virStoragePoolObjRemove(driver->pools, obj);
virObjectUnref(obj);
obj = NULL;
newDef = NULL;
goto cleanup;
}
@ -826,6 +827,7 @@ storagePoolDefineXML(virConnectPtr conn,
VIR_INFO("Defining storage pool '%s'", def->name);
pool = virGetStoragePool(conn, def->name, def->uuid, NULL, NULL);
newDef = NULL;
cleanup:
virObjectEventStateQueue(driver->storageEventState, event);