On Thu, Dec 14, 2017 at 01:22:20PM -0500, John Ferlan wrote:
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 <jfer...@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);

For storage driver, this duplicates the error from virStoragePoolObjIsDuplicate:
           virReportError(VIR_ERR_OPERATION_FAILED,
                          _("pool '%s' is already defined with uuid %s"),
                          obj->def->name, uuidstr);

Test driver should use that function instead of adding duplicate error
checks to 'functional' code. Also, it seems this would not cover the
opposite case - same name but different UUIDs (which is already covered
by virStoragePoolObjIsDuplicate).

Jan

Attachment: signature.asc
Description: Digital signature

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

Reply via email to