diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 817d9a4146..0b3ba84af2 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -1486,17 +1486,15 @@ virStoragePoolObjSourceFindDuplicateCb(const void *payload, } -int +static int virStoragePoolObjSourceFindDuplicate(virStoragePoolObjListPtr pools, virStoragePoolDefPtr def) { struct _virStoragePoolObjFindDuplicateData data = {.def = def}; virStoragePoolObjPtr obj = NULL; - virObjectRWLockRead(pools); obj = virHashSearch(pools->objs, virStoragePoolObjSourceFindDuplicateCb, &data, NULL); - virObjectRWUnlock(pools); if (obj) { virReportError(VIR_ERR_OPERATION_FAILED, @@ -1531,6 +1529,9 @@ virStoragePoolObjAssignDef(virStoragePoolObjListPtr pools, virObjectRWLockWrite(pools); + if (virStoragePoolObjSourceFindDuplicate(pools, def) < 0) + goto error; + rc = virStoragePoolObjIsDuplicate(pools, def, check_active, &obj); if (rc < 0) diff --git a/src/conf/virstorageobj.h b/src/conf/virstorageobj.h index bc24db1928..abd6166d88 100644 --- a/src/conf/virstorageobj.h +++ b/src/conf/virstorageobj.h @@ -245,10 +245,6 @@ void virStoragePoolObjRemove(virStoragePoolObjListPtr pools, virStoragePoolObjPtr obj); -int -virStoragePoolObjSourceFindDuplicate(virStoragePoolObjListPtr pools, - virStoragePoolDefPtr def); - int virStoragePoolObjListExport(virConnectPtr conn, virStoragePoolObjListPtr poolobjs, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fe518f7325..93e6e8a14c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1160,7 +1160,6 @@ virStoragePoolObjSetActive; virStoragePoolObjSetAutostart; virStoragePoolObjSetConfigFile; virStoragePoolObjSetDef; -virStoragePoolObjSourceFindDuplicate; virStoragePoolObjVolumeGetNames; virStoragePoolObjVolumeListExport; diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index df4f86c4bd..e7085e4773 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -705,9 +705,6 @@ storagePoolCreateXML(virConnectPtr conn, if (virStoragePoolCreateXMLEnsureACL(conn, newDef) < 0) goto cleanup; - if (virStoragePoolObjSourceFindDuplicate(driver->pools, newDef) < 0) - goto cleanup; - if ((backend = virStorageBackendForType(newDef->type)) == NULL) goto cleanup; @@ -796,9 +793,6 @@ storagePoolDefineXML(virConnectPtr conn, if (virStoragePoolDefineXMLEnsureACL(conn, newDef) < 0) goto cleanup; - if (virStoragePoolObjSourceFindDuplicate(driver->pools, newDef) < 0) - goto cleanup; - if (virStorageBackendForType(newDef->type) == NULL) goto cleanup;