From nobody Thu May 15 01:08:04 2025 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