Just like a few commits earlier, checking for pool source duplicates and unlocking pools list afterwards is a buggy pattern. The check must go into virStoragePoolObjAssignDef. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/conf/virstorageobj.c | 7 ++++--- src/conf/virstorageobj.h | 4 ---- src/libvirt_private.syms | 1 - src/storage/storage_driver.c | 6 ------ 4 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index dce45ce870..c717176133 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 572d1a1e22..e107efedcc 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1157,7 +1157,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; -- 2.16.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list