From nobody Mon Feb 9 01:06:29 2026 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568207873; cv=none; d=zoho.com; s=zohoarc; b=JwV9vGRxbm+tsXky/2U98FYbXx3jhXPnC7YH3nhA+q2u70IWzKfA379YXhFqAz12AzTIDq7CP5hIhRnzHm2aCz18O/HyeORbbIppqC8GWcy/i2tNxEH/UJIdF7oZXJvWT6HSlQxG7RaT592YcUpoOS5tikqrZmEFliuJnSi9Jbg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568207873; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=rP4AMzQDAfC2qTcTdEvUTyrNFTYgcui8ZkiZ85m2iZg=; b=k5p5Tm1xg7HiL/ZbU+9MFh8DiBuSTt+zvUZuX1QNGJGIs3FhxpqgIUeCh/122q/91EbahCM3QlWOSohYZ70zLgf0XuCN8XpPYyGUxFIwDu/IB64CM2VxK/4K8/zLnQiJYphSMr4MnaQhkFRKTdiZ8CdvSvKzPSNWdFPE9poDSaY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1568207873873290.83919551515487; Wed, 11 Sep 2019 06:17:53 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 22A48693C8; Wed, 11 Sep 2019 13:17:52 +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 E507119C78; Wed, 11 Sep 2019 13:17:51 +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 79688E205; Wed, 11 Sep 2019 13:17:51 +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 x8BDHmYC003010 for ; Wed, 11 Sep 2019 09:17:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id A52CB60C44; Wed, 11 Sep 2019 13:17:48 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D6B160BEC for ; Wed, 11 Sep 2019 13:17:48 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 11 Sep 2019 15:17:42 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 2/2] domain_conf: Relax SCSI addr used check 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 11 Sep 2019 13:17:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" In domain_conf.c we have virDomainSCSIDriveAddressIsUsed() function which returns true or false if given drive address is already in use for given domain config or not. However, it also takes a shortcut and returns true (meaning address in use) if the unit number equals 7. This is because for some controllers this is reserved address. The limitation comes mostly from vmware and applies to lsilogic, buslogic, spapr-vscsi and vmpvscsi models. On the other hand, we were not checking for the maximum unit number (aka LUN number) which is also relevant and differs from model to model. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 53 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 69c486f382..3e7603891f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4813,11 +4813,54 @@ bool virDomainSCSIDriveAddressIsUsed(const virDomainDef *def, const virDomainDeviceDriveAddress *addr) { - /* In current implementation, the maximum unit number of a controller - * is either 16 or 7 (narrow SCSI bus), and if the maximum unit number - * is 16, the controller itself is on unit 7 */ - if (addr->unit =3D=3D 7) - return true; + const virDomainControllerDef *cont; + + cont =3D virDomainDeviceFindSCSIController(def, addr); + if (cont) { + int max =3D -1; + int reserved =3D -1; + + /* Different controllers have different limits. These limits here = are + * taken from QEMU source code, but nevertheless they should apply= to + * other hypervisors too. */ + switch ((virDomainControllerModelSCSI) cont->model) { + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL: + max =3D 16383; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI: + max =3D 31; + reserved =3D 7; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068: + max =3D 1; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078: + max =3D 255; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC: + max =3D 0; + reserved =3D 7; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI: + max =3D 0; + reserved =3D 7; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC: + reserved =3D 7; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST: + break; + } + + if (max !=3D -1 && addr->unit >=3D max) + return true; + if (reserved !=3D -1 && addr->unit =3D=3D reserved) + return true; + } =20 if (virDomainDriveAddressIsUsedByDisk(def, VIR_DOMAIN_DISK_BUS_SCSI, addr) || --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list