From nobody Fri May 3 23:03:25 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 1512565707060868.2582000641363; Wed, 6 Dec 2017 05:08:27 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BCD2F61D05; Wed, 6 Dec 2017 13:08:25 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 99A307A3AB; Wed, 6 Dec 2017 13:08:25 +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 651394EA2F; Wed, 6 Dec 2017 13:08:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB6D8B7u023389 for ; Wed, 6 Dec 2017 08:08:11 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0B58A4D71F; Wed, 6 Dec 2017 13:08:11 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-84.phx2.redhat.com [10.3.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id C75675C888 for ; Wed, 6 Dec 2017 13:08:10 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 6 Dec 2017 08:08:03 -0500 Message-Id: <20171206130806.13619-2-jferlan@redhat.com> In-Reply-To: <20171206130806.13619-1-jferlan@redhat.com> References: <20171206130806.13619-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/4] qemu: Tolerate storage source private data being NULL for hotplug SCSI hostdev 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 06 Dec 2017 13:08:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Commit id 'c5c96545' neglected to validate that the srcPriv was non-NULL before dereferencing. Similar problem to what was fixed by commit id '8056721c' but missed during multiple rebases and code reworks. Signed-off-by: John Ferlan Reviewed-by: Eric Farman --- src/qemu/qemu_hotplug.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 6ef28bf05..9317e134a 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2286,7 +2286,7 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn, virDomainHostdevSubsysSCSIPtr scsisrc =3D &hostdev->source.subsys.u.sc= si; virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc =3D &scsisrc->u.iscsi; qemuDomainStorageSourcePrivatePtr srcPriv; - qemuDomainSecretInfoPtr secinfo; + qemuDomainSecretInfoPtr secinfo =3D NULL; =20 if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -2328,7 +2328,8 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn, goto cleanup; =20 srcPriv =3D QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(iscsisrc->src); - secinfo =3D srcPriv->secinfo; + if (srcPriv) + secinfo =3D srcPriv->secinfo; if (secinfo && secinfo->type =3D=3D VIR_DOMAIN_SECRET_INFO_TYPE_AES) { if (qemuBuildSecretInfoProps(secinfo, &secobjProps) < 0) goto cleanup; --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 23:03:25 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 1512565763117415.4034385770045; Wed, 6 Dec 2017 05:09:23 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1B6D47F7B9; Wed, 6 Dec 2017 13:09:22 +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 EC8C863775; Wed, 6 Dec 2017 13:09:21 +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 B17061800BDB; Wed, 6 Dec 2017 13:09:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB6D8BO0023394 for ; Wed, 6 Dec 2017 08:08:11 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9DABC4D71F; Wed, 6 Dec 2017 13:08:11 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-84.phx2.redhat.com [10.3.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 641D05C888 for ; Wed, 6 Dec 2017 13:08:11 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 6 Dec 2017 08:08:04 -0500 Message-Id: <20171206130806.13619-3-jferlan@redhat.com> In-Reply-To: <20171206130806.13619-1-jferlan@redhat.com> References: <20171206130806.13619-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/4] qemu: Use same model when adding hostdev SCSI controller 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 06 Dec 2017 13:09:22 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When qemuDomainFindOrCreateSCSIDiskController adds a controller, let's use the same model as a currently found controller under the assumption that the reason to add the controller in hotplug is because virDomainHostdevAssignAddress determined that there were too many devices on the existing controller, but only assigned a new controller index and did not add a new controller and we desire to use the same controller model as any existing conroller and not take a chance that qemuDomainSetSCSIControllerModel would use a default that may be incompatible. Signed-off-by: John Ferlan Reviewed-by: Eric Farman --- src/qemu/qemu_hotplug.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 9317e134a..90d50e7b1 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -587,6 +587,7 @@ qemuDomainFindOrCreateSCSIDiskController(virQEMUDriverP= tr driver, { size_t i; virDomainControllerDefPtr cont; + virDomainControllerModelSCSI model =3D -1; =20 for (i =3D 0; i < vm->def->ncontrollers; i++) { cont =3D vm->def->controllers[i]; @@ -596,6 +597,12 @@ qemuDomainFindOrCreateSCSIDiskController(virQEMUDriver= Ptr driver, =20 if (cont->idx =3D=3D controller) return cont; + + /* Save off the model - if we end up creating a controller it's + * because the user didn't provide one and we need to automagically + * create one because the existing one is full - so let's be sure + * to keep the same model in that case. */ + model =3D cont->model; } =20 /* No SCSI controller present, for backward compatibility we @@ -604,11 +611,10 @@ qemuDomainFindOrCreateSCSIDiskController(virQEMUDrive= rPtr driver, return NULL; cont->type =3D VIR_DOMAIN_CONTROLLER_TYPE_SCSI; cont->idx =3D controller; - cont->model =3D -1; + cont->model =3D model; =20 - VIR_INFO("No SCSI controller present, hotplugging one"); - if (qemuDomainAttachControllerDevice(driver, - vm, cont) < 0) { + VIR_INFO("No SCSI controller present, hotplugging one model=3D%d", mod= el); + if (qemuDomainAttachControllerDevice(driver, vm, cont) < 0) { VIR_FREE(cont); return NULL; } --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 23:03:25 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 1512565704505488.88955500582574; Wed, 6 Dec 2017 05:08:24 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9FE28C119CB1; Wed, 6 Dec 2017 13:08:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 728B868D2F; Wed, 6 Dec 2017 13:08:23 +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 2C8394EA2D; Wed, 6 Dec 2017 13:08:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB6D8CrZ023402 for ; Wed, 6 Dec 2017 08:08:12 -0500 Received: by smtp.corp.redhat.com (Postfix) id 082414D71F; Wed, 6 Dec 2017 13:08:12 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-84.phx2.redhat.com [10.3.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id C26D75C888 for ; Wed, 6 Dec 2017 13:08:11 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 6 Dec 2017 08:08:05 -0500 Message-Id: <20171206130806.13619-4-jferlan@redhat.com> In-Reply-To: <20171206130806.13619-1-jferlan@redhat.com> References: <20171206130806.13619-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/4] conf: Use existing SCSI hostdev model to create new 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 06 Dec 2017 13:08:24 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In virDomainDefMaybeAddHostdevSCSIcontroller when we add a new controller because someone neglected to add one or we're adding one because the existing one is full, we should copy over the model number from the existing controller since whatever we create should at least have the same characteristics as the one we cannot use because it's full. NB: This affects the existing hostdev-scsi-autogen-address test which would add a default ('lsi') SCSI controller for the various scsi_host's that would create a controller for the hostdev. Signed-off-by: John Ferlan Reviewed-by: Eric Farman --- src/conf/domain_conf.c | 13 +++++++++++= +- tests/qemuxml2xmloutdata/hostdev-scsi-autogen-address.xml | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 66e21c4bd..61b4a0075 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17689,12 +17689,22 @@ virDomainDefMaybeAddHostdevSCSIcontroller(virDoma= inDefPtr def) size_t i; int maxController =3D -1; virDomainHostdevDefPtr hostdev; + virDomainControllerModelSCSI model =3D -1; + virDomainControllerModelSCSI newModel =3D -1; =20 for (i =3D 0; i < def->nhostdevs; i++) { hostdev =3D def->hostdevs[i]; if (virHostdevIsSCSIDevice(hostdev) && (int)hostdev->info->addr.drive.controller > maxController) { maxController =3D hostdev->info->addr.drive.controller; + /* We may be creating a new controller because this one is ful= l. + * So let's grab the model from it and update the model we're + * going to add as long as this one isn't undefined. The premi= se + * being keeping the same controller model for all SCSI hostde= vs. */ + model =3D virDomainDeviceFindControllerModel(def, hostdev->inf= o, + VIR_DOMAIN_CONTROLL= ER_TYPE_SCSI); + if (model !=3D -1) + newModel =3D model; } } =20 @@ -17702,7 +17712,8 @@ virDomainDefMaybeAddHostdevSCSIcontroller(virDomain= DefPtr def) return 0; =20 for (i =3D 0; i <=3D maxController; i++) { - if (virDomainDefMaybeAddController(def, VIR_DOMAIN_CONTROLLER_TYPE= _SCSI, i, -1) < 0) + if (virDomainDefMaybeAddController(def, VIR_DOMAIN_CONTROLLER_TYPE= _SCSI, + i, newModel) < 0) return -1; } =20 diff --git a/tests/qemuxml2xmloutdata/hostdev-scsi-autogen-address.xml b/te= sts/qemuxml2xmloutdata/hostdev-scsi-autogen-address.xml index 8e93056ee..cea212b64 100644 --- a/tests/qemuxml2xmloutdata/hostdev-scsi-autogen-address.xml +++ b/tests/qemuxml2xmloutdata/hostdev-scsi-autogen-address.xml @@ -29,7 +29,7 @@
- +
--=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 23:03:25 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 1512565709250591.0770765644711; Wed, 6 Dec 2017 05:08:29 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3589C5D9E4; Wed, 6 Dec 2017 13:08:28 +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 111C25E25F; Wed, 6 Dec 2017 13:08: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 CD5DA1800BDF; Wed, 6 Dec 2017 13:08:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB6D8CRO023409 for ; Wed, 6 Dec 2017 08:08:12 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6F6854D71F; Wed, 6 Dec 2017 13:08:12 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-84.phx2.redhat.com [10.3.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 35F42679D5 for ; Wed, 6 Dec 2017 13:08:12 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 6 Dec 2017 08:08:06 -0500 Message-Id: <20171206130806.13619-5-jferlan@redhat.com> In-Reply-To: <20171206130806.13619-1-jferlan@redhat.com> References: <20171206130806.13619-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/4] conf: Fix generating addresses for SCSI hostdev 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 06 Dec 2017 13:08:28 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1519130 Commit id 'dc692438' reverted the automagic addition of a SCSI controller attempt during virDomainHostdevAssignAddress; however, the logic to determine where to place the next_unit depended upon the "new" controller being added. Without the new controller the the next time through the call for the next SCSI hostdev found would result in the "next_unit" never changing from 0 (zero) and as a result the addition of the device will fail due to being a duplicate unit number of the first with the error message: virDomainDefCheckDuplicateDriveAddresses:$line : unsupported configuration: SCSI host address controller=3D'0' bus=3D'1' target=3D'0' unit=3D'0' in use by another SCSI host device So instead of walking the controller list looking for SCSI controllers, all we can do is "pretend" that they exist and allow other code to create them later as necessary. Signed-off-by: John Ferlan --- src/conf/domain_conf.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 61b4a0075..73c6708cf 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4322,10 +4322,8 @@ virDomainHostdevAssignAddress(virDomainXMLOptionPtr = xmlopt, const virDomainDef *def, virDomainHostdevDefPtr hostdev) { - int next_unit =3D 0; - unsigned controller =3D 0; + int controller =3D 0; unsigned int max_unit; - size_t i; int ret; =20 if (xmlopt->config.features & VIR_DOMAIN_DEF_FEATURE_WIDE_SCSI) @@ -4333,33 +4331,30 @@ virDomainHostdevAssignAddress(virDomainXMLOptionPtr= xmlopt, else max_unit =3D SCSI_NARROW_BUS_MAX_CONT_UNIT; =20 - for (i =3D 0; i < def->ncontrollers; i++) { - if (def->controllers[i]->type !=3D VIR_DOMAIN_CONTROLLER_TYPE_SCSI) - continue; - - controller++; - ret =3D virDomainControllerSCSINextUnit(def, max_unit, - def->controllers[i]->idx); - if (ret >=3D 0) { - next_unit =3D ret; - controller =3D def->controllers[i]->idx; - break; - } - } - /* NB: Do not attempt calling virDomainDefMaybeAddController to * automagically add a "new" controller. Doing so will result in * qemuDomainFindOrCreateSCSIDiskController "finding" the controller * in the domain def list and thus not hotplugging the controller as * well as the hostdev in the event that there are either no SCSI * controllers defined or there was no space on an existing one. + * + * Because we cannot add a controller, then we should not walk the + * defined controllers list in order to find empty space. Doing + * so fails to return the valid next unit number for the 2nd + * hostdev being added to the as yet to be created controller. */ + do { + ret =3D virDomainControllerSCSINextUnit(def, max_unit, controller); + if (ret < 0) + controller++; + } while (ret < 0); + =20 hostdev->info->type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE; hostdev->info->addr.drive.controller =3D controller; hostdev->info->addr.drive.bus =3D 0; hostdev->info->addr.drive.target =3D 0; - hostdev->info->addr.drive.unit =3D next_unit; + hostdev->info->addr.drive.unit =3D ret; =20 return 0; } --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list