Commit id '4b2e0ed6e' converted to using hash tables for storing
storage pool objs by name and uuid; however, neglected to add a check
to virStoragePoolObjAssignDef that the pool by uuid wasn't defined.
This caused issues for the virt-manager test driver which ended up
using the same UUID for a newly named pool and started having failures
from adding a non unique UUID.
So instead of getting a "Duplicate key", let's add a more descriptive
error message indicating which pool object by name already exists
using the same UUID as the pool object that is attempting to be added.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
FWIW: The virt-manager test was also fixed to not use a duplicate UUID
as of commit '4224b0926' in the virt-manager git repo.
src/conf/virstorageobj.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c
index 49fe24b28..e3acc817c 100644
--- a/src/conf/virstorageobj.c
+++ b/src/conf/virstorageobj.c
@@ -747,10 +747,18 @@ virStoragePoolObjAssignDef(virStoragePoolObjListPtr pools,
return obj;
}
+ virUUIDFormat(def->uuid, uuidstr);
+ if ((obj = virStoragePoolObjFindByUUIDLocked(pools, def->uuid))) {
+ virObjectLock(obj);
+ virReportError(VIR_ERR_OPERATION_FAILED,
+ _("storage pool '%s' already exists with uuid
%s"),
+ obj->def->name, uuidstr);
+ goto error;
+ }
+
if (!(obj = virStoragePoolObjNew()))
return NULL;
- virUUIDFormat(def->uuid, uuidstr);
if (virHashAddEntry(pools->objs, uuidstr, obj) < 0)
goto error;
virObjectRef(obj);
--
2.13.6