From nobody Mon Apr 29 14:55:59 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; 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 1521197623289751.0858386496268; Fri, 16 Mar 2018 03:53:43 -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 966EF7FEB5; Fri, 16 Mar 2018 10:53:41 +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 86B725D9CD; Fri, 16 Mar 2018 10:53:40 +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 DE6E5181B9FE; Fri, 16 Mar 2018 10:53:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2GAoD9t003135 for ; Fri, 16 Mar 2018 06:50:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 12257C1234; Fri, 16 Mar 2018 10:50:13 +0000 (UTC) Received: from beluga.usersys.redhat.com (unknown [10.43.2.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FE8FBDC4B; Fri, 16 Mar 2018 10:50:12 +0000 (UTC) From: Erik Skultety To: libvir-list@redhat.com Date: Fri, 16 Mar 2018 11:50:01 +0100 Message-Id: <7526f4dd5e7619eb2d566e03df4b7c5e53b61023.1521196942.git.eskultet@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH 1/2] util:mdev: Improve the error msg on non-existent mdev prior to VM start 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]); Fri, 16 Mar 2018 10:53:42 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" What one currently gets is: failed to read '/sys/bus/mdev/devices//mdev_type/device_api': No such file or directory This indicates that something is missing within the device's sysfs tree which likely might be not be the case here because the device simply doesn't exist yet. So, when creating our internal mdev obj, let's check whether the device exists first prior to trying to verify the user-provided model within domain XML. Signed-off-by: Erik Skultety --- src/util/virmdev.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/util/virmdev.c b/src/util/virmdev.c index e4816cf20..2e3769aa6 100644 --- a/src/util/virmdev.c +++ b/src/util/virmdev.c @@ -150,13 +150,22 @@ virMediatedDeviceNew(const char *uuidstr, virMediated= DeviceModelType model) { virMediatedDevicePtr ret =3D NULL; virMediatedDevicePtr dev =3D NULL; + char *sysfspath =3D NULL; + + if (!(sysfspath =3D virMediatedDeviceGetSysfsPath(uuidstr))) + goto cleanup; + + if (!virFileExists(sysfspath)) { + virReportSystemError(errno, _("failed to read device '%s'"), + sysfspath); + goto cleanup; + } =20 if (VIR_ALLOC(dev) < 0) - return NULL; - - if (!(dev->path =3D virMediatedDeviceGetSysfsPath(uuidstr))) goto cleanup; =20 + VIR_STEAL_PTR(dev->path, sysfspath); + /* Check whether the user-provided model corresponds with the actually * supported mediated device's API. */ @@ -167,6 +176,7 @@ virMediatedDeviceNew(const char *uuidstr, virMediatedDe= viceModelType model) VIR_STEAL_PTR(ret, dev); =20 cleanup: + VIR_FREE(sysfspath); virMediatedDeviceFree(dev); return ret; } --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 14:55:59 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; 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 1521197679665902.1130192150248; Fri, 16 Mar 2018 03:54:39 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 59F3E4DD7C; Fri, 16 Mar 2018 10:54:38 +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 3157660F90; Fri, 16 Mar 2018 10:54:38 +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 E9196180613A; Fri, 16 Mar 2018 10:54:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2GAoD96003145 for ; Fri, 16 Mar 2018 06:50:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id C1CD3BDC4B; Fri, 16 Mar 2018 10:50:13 +0000 (UTC) Received: from beluga.usersys.redhat.com (unknown [10.43.2.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B8C5AFD6C; Fri, 16 Mar 2018 10:50:13 +0000 (UTC) From: Erik Skultety To: libvir-list@redhat.com Date: Fri, 16 Mar 2018 11:50:02 +0100 Message-Id: <80280a4935a8a97314338781752a5b8f959104c2.1521196942.git.eskultet@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH 2/2] qemu: hostdev: Don't error out on domain with an mdev when IOMMU is off 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 16 Mar 2018 10:54:38 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Commit b4c2ac8d56 made a false assumption that IOMMU support necessary for an mdev device to be assigned to a VM. Unlike direct PCI assignment, IOMMU support is not needed for mediated devices, as the physical parent device provides the IOMMU isolation, therefore, simply checking for VFIO presence is enough to successfully start a VM. Luckily, this issue is not very serious, since as of yet, libvirt mandates the mdevs to be pre-created prior to a domain's launch, so this patch will merely change the error the end user is going to see. Previously: unsupported configuration: Mediated host device assignment requires VFIO support Now: failed to read device '/sys/bus/mdev/devices//': No such file or directory Signed-off-by: Erik Skultety --- src/qemu/qemu_hostdev.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index 73d26f4c6..afe445d4e 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -330,9 +330,14 @@ qemuHostdevPrepareMediatedDevices(virQEMUDriverPtr dri= ver, int nhostdevs) { virHostdevManagerPtr hostdev_mgr =3D driver->hostdevMgr; - bool supportsVFIO =3D qemuHostdevHostSupportsPassthroughVFIO(); + bool supportsVFIO; size_t i; + /* Checking for VFIO only is fine with mdev, as IOMMU isolation is ach= ieved + * by the physical parent device. + */ + supportsVFIO =3D virFileExists("/dev/vfio/vfio"); + for (i =3D 0; i < nhostdevs; i++) { if (hostdevs[i]->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && hostdevs[i]->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBS= YS_TYPE_MDEV) { -- 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list