]> xenbits.xensource.com Git - libvirt.git/commitdiff
test: Use virStoragePoolObjIsDuplicate for storage define/create
authorJohn Ferlan <jferlan@redhat.com>
Mon, 18 Dec 2017 12:41:16 +0000 (07:41 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 4 Jan 2018 15:54:08 +0000 (10:54 -0500)
Avoid the chance that there could be a duplicate storage pool UUID
or Name from the test driver storage pool define/create functions.

src/test/test_driver.c

index 8adc2167b454b13bc90054038d36c7f2109d34cc..dc743b49883542bbe4c4e53925f0579011a2193c 100644 (file)
@@ -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;