storage: Create error label path for storagePoolCreateXML

Rather than duplicate the error code, let's create an error
label to keep code common.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
John Ferlan 2018-09-12 11:17:17 -04:00
parent 4a7abc67d5
commit 1ff45609d6

View File

@ -727,12 +727,8 @@ storagePoolCreateXML(virConnectPtr conn,
} }
if (backend->startPool && if (backend->startPool &&
backend->startPool(obj) < 0) { backend->startPool(obj) < 0)
virStoragePoolObjRemove(driver->pools, obj); goto error;
virObjectUnref(obj);
obj = NULL;
goto cleanup;
}
stateFile = virFileBuildPath(driver->stateDir, def->name, ".xml"); stateFile = virFileBuildPath(driver->stateDir, def->name, ".xml");
@ -743,10 +739,7 @@ storagePoolCreateXML(virConnectPtr conn,
unlink(stateFile); unlink(stateFile);
if (backend->stopPool) if (backend->stopPool)
backend->stopPool(obj); backend->stopPool(obj);
virStoragePoolObjRemove(driver->pools, obj); goto error;
virObjectUnref(obj);
obj = NULL;
goto cleanup;
} }
event = virStoragePoolEventLifecycleNew(def->name, event = virStoragePoolEventLifecycleNew(def->name,
@ -765,6 +758,12 @@ storagePoolCreateXML(virConnectPtr conn,
virObjectEventStateQueue(driver->storageEventState, event); virObjectEventStateQueue(driver->storageEventState, event);
virStoragePoolObjEndAPI(&obj); virStoragePoolObjEndAPI(&obj);
return pool; return pool;
error:
virStoragePoolObjRemove(driver->pools, obj);
virObjectUnref(obj);
obj = NULL;
goto cleanup;
} }
static virStoragePoolPtr static virStoragePoolPtr