From nobody Sat Feb 7 11:23:50 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1535039479360504.40269062947914; Thu, 23 Aug 2018 08:51:19 -0700 (PDT) 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 D5B623084219; Thu, 23 Aug 2018 15:51:16 +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 6AB8817CD5; Thu, 23 Aug 2018 15:51:16 +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 409E84BB7F; Thu, 23 Aug 2018 15:51:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7NFoHat027311 for ; Thu, 23 Aug 2018 11:50:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id C4A348C06D; Thu, 23 Aug 2018 15:50:17 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-58.phx2.redhat.com [10.3.116.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7BA7D9656E for ; Thu, 23 Aug 2018 15:50:17 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Thu, 23 Aug 2018 11:50:01 -0400 Message-Id: <20180823155002.19288-2-jferlan@redhat.com> In-Reply-To: <20180823155002.19288-1-jferlan@redhat.com> References: <20180823155002.19288-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] qemu: Add ability to set sgio values for 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.40]); Thu, 23 Aug 2018 15:51:17 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add necessary checks in order to allow setting sgio values for a scsi host device. Signed-off-by: John Ferlan --- src/qemu/qemu_conf.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index a4f545ef92..3d28c03fa1 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1633,13 +1633,15 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) virDomainDiskDefPtr disk =3D NULL; virDomainHostdevDefPtr hostdev =3D NULL; char *sysfs_path =3D NULL; + char *hostdev_path =3D NULL; const char *path =3D NULL; int val =3D -1; int ret =3D -1; =20 /* "sgio" is only valid for block disk; cdrom * and floopy disk can have empty source. - */ + * NB: The default is to filter SG_IO commands + * (i.e. set unpriv_sgio to 0). */ if (dev->type =3D=3D VIR_DOMAIN_DEVICE_DISK) { disk =3D dev->data.disk; =20 @@ -1648,20 +1650,19 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) return 0; =20 path =3D virDomainDiskGetSource(disk); + val =3D (disk->sgio =3D=3D VIR_DOMAIN_DEVICE_SGIO_UNFILTERED); } else if (dev->type =3D=3D VIR_DOMAIN_DEVICE_HOSTDEV) { hostdev =3D dev->data.hostdev; =20 if (!qemuIsSharedHostdev(hostdev)) return 0; =20 - if (hostdev->source.subsys.u.scsi.sgio) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("'sgio' is not supported for SCSI " - "generic device yet ")); + if (!(hostdev_path =3D qemuGetHostdevPath(hostdev))) goto cleanup; - } =20 - return 0; + path =3D hostdev_path; + val =3D (hostdev->source.subsys.u.scsi.sgio =3D=3D + VIR_DOMAIN_DEVICE_SGIO_UNFILTERED); } else { return 0; } @@ -1669,9 +1670,6 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) if (!(sysfs_path =3D virGetUnprivSGIOSysfsPath(path, NULL))) goto cleanup; =20 - /* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0. = */ - val =3D (disk->sgio =3D=3D VIR_DOMAIN_DEVICE_SGIO_UNFILTERED); - /* Do not do anything if unpriv_sgio is not supported by the kernel an= d the * whitelist is enabled. But if requesting unfiltered access, always = call * virSetDeviceUnprivSGIO, to report an error for unsupported unpriv_s= gio. @@ -1683,6 +1681,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) ret =3D 0; =20 cleanup: + VIR_FREE(hostdev_path); VIR_FREE(sysfs_path); return ret; } --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Feb 7 11:23:50 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1535039782958565.0451473734425; Thu, 23 Aug 2018 08:56:22 -0700 (PDT) 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 9240A3086271; Thu, 23 Aug 2018 15:56:20 +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 190FE18EDF; Thu, 23 Aug 2018 15:56:20 +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 1E6434A463; Thu, 23 Aug 2018 15:56:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7NFoIS8027316 for ; Thu, 23 Aug 2018 11:50:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 45D80907FE; Thu, 23 Aug 2018 15:50:18 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-58.phx2.redhat.com [10.3.116.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id F14D98C06D for ; Thu, 23 Aug 2018 15:50:17 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Thu, 23 Aug 2018 11:50:02 -0400 Message-Id: <20180823155002.19288-3-jferlan@redhat.com> In-Reply-To: <20180823155002.19288-1-jferlan@redhat.com> References: <20180823155002.19288-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] qemu: Add check for unpriv sgio for SCSI generic host device 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.49]); Thu, 23 Aug 2018 15:56:21 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Check if the hostdev has set the sgio filtered/unfiltered and handle appropriately. This restores functionality removed by commit id 'ce346623' to remove sgio support for the SCSI generic host device in the formerly named method qemuCheckSharedDevice. For most kernels the result of this operation is a no-op; however, for those that do support it the check is necessary. Note that this patch fixes a bug found in the reverted change where if the qemuGetDeviceUnprivSGIO returned either 0 or 1 in 'val', the 'disk' would be dereferenced; however, since a hostdev didn't have one - that dereference would have caused a segfault. That was fixed by commit id 'cd01d2ad5' using virDomainDiskGetSource. Instead these changes use the hostdev's address value. Signed-off-by: John Ferlan --- src/qemu/qemu_conf.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 3d28c03fa1..3f24c8b8fc 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1473,6 +1473,8 @@ qemuAddSharedHostdev(virQEMUDriverPtr driver, { char *dev_path =3D NULL; char *key =3D NULL; + virDomainHostdevSubsysSCSIPtr scsisrc =3D &hostdev->source.subsys.u.sc= si; + virDomainHostdevSubsysSCSIHostPtr scsihostsrc =3D &scsisrc->u.host; int ret =3D -1; =20 if (!qemuIsSharedHostdev(hostdev)) @@ -1481,6 +1483,19 @@ qemuAddSharedHostdev(virQEMUDriverPtr driver, if (!(dev_path =3D qemuGetHostdevPath(hostdev))) goto cleanup; =20 + if ((ret =3D qemuCheckUnprivSGIO(driver->sharedDevices, dev_path, + scsisrc->sgio)) < 0) { + if (ret =3D=3D -2) { + virReportError(VIR_ERR_OPERATION_INVALID, + _("sgio of shared scsi host device '%s-%u-%u-%l= lu' " + "conflicts with other active domains"), + scsihostsrc->adapter, scsihostsrc->bus, + scsihostsrc->target, scsihostsrc->unit); + ret =3D -1; + } + goto cleanup; + } + if (!(key =3D qemuGetSharedDeviceKey(dev_path))) goto cleanup; =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list