From nobody Mon May 6 00:17:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 151327575206355.11120148795669; Thu, 14 Dec 2017 10:22:32 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2E97961B8C; Thu, 14 Dec 2017 18:22:29 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 92AB67D92A; Thu, 14 Dec 2017 18:22:28 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 83FDB1801219; Thu, 14 Dec 2017 18:22:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vBEIMPnf004442 for ; Thu, 14 Dec 2017 13:22:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id 169AC413A; Thu, 14 Dec 2017 18:22:25 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-148.phx2.redhat.com [10.3.117.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD6137DF58 for ; Thu, 14 Dec 2017 18:22:22 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Thu, 14 Dec 2017 13:22:20 -0500 Message-Id: <20171214182220.24718-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] storage: Add unique UUID check for virStoragePoolObjAssignDef X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 14 Dec 2017 18:22:31 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 --- 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 p= ools, return obj; } =20 + virUUIDFormat(def->uuid, uuidstr); + if ((obj =3D 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 =3D virStoragePoolObjNew())) return NULL; =20 - virUUIDFormat(def->uuid, uuidstr); if (virHashAddEntry(pools->objs, uuidstr, obj) < 0) goto error; virObjectRef(obj); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list