[PATCH] storage: Add unique UUID check for virStoragePoolObjAssignDef

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---

 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux