From a94bb4ebdf07f643133acbac3953975bcaf951db Mon Sep 17 00:00:00 2001 From: Shichangkuo Date: Tue, 10 Jul 2018 07:15:24 +0000 Subject: [PATCH] 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 Signed-off-by: Michal Privoznik --- src/storage/storage_driver.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 254818e308..8070d159ea 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -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);