mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
test: Use virStoragePoolObjIsDuplicate for storage define/create
Avoid the chance that there could be a duplicate storage pool UUID or Name from the test driver storage pool define/create functions.
This commit is contained in:
parent
607524af4f
commit
394eaa6b39
@ -4440,14 +4440,8 @@ testStoragePoolCreateXML(virConnectPtr conn,
|
||||
if (!(newDef = virStoragePoolDefParseString(xml)))
|
||||
goto cleanup;
|
||||
|
||||
obj = virStoragePoolObjFindByUUID(privconn->pools, newDef->uuid);
|
||||
if (!obj)
|
||||
obj = virStoragePoolObjFindByName(privconn->pools, newDef->name);
|
||||
if (obj) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("storage pool already exists"));
|
||||
if (virStoragePoolObjIsDuplicate(privconn->pools, newDef, true) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!(obj = virStoragePoolObjAssignDef(privconn->pools, newDef)))
|
||||
goto cleanup;
|
||||
@ -4520,6 +4514,9 @@ testStoragePoolDefineXML(virConnectPtr conn,
|
||||
newDef->allocation = defaultPoolAlloc;
|
||||
newDef->available = defaultPoolCap - defaultPoolAlloc;
|
||||
|
||||
if (virStoragePoolObjIsDuplicate(privconn->pools, newDef, false) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(obj = virStoragePoolObjAssignDef(privconn->pools, newDef)))
|
||||
goto cleanup;
|
||||
newDef = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user