From nobody Mon Feb 9 10:27:18 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1704444062277148.56193056274742; Fri, 5 Jan 2024 00:41:02 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 3E7D8180C; Fri, 5 Jan 2024 03:41:01 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 4D3A21976; Fri, 5 Jan 2024 03:21:26 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id B963317FB; Fri, 5 Jan 2024 03:20:28 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id D5440180E for ; Fri, 5 Jan 2024 03:20:20 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-213-Rd04g7OwMFS3ZaAXyqnKzA-1; Fri, 05 Jan 2024 03:20:19 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B079B85A589 for ; Fri, 5 Jan 2024 08:20:18 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.16.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id 953BE2026D6F; Fri, 5 Jan 2024 08:20:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: Rd04g7OwMFS3ZaAXyqnKzA-1 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH v3 09/13] conf: replace virHostdevIsVFIODevice with virHostdevIsPCIDevice Date: Fri, 5 Jan 2024 03:20:12 -0500 Message-ID: <20240105082016.281442-10-laine@redhat.com> In-Reply-To: <20240105082016.281442-1-laine@redhat.com> References: <20240105082016.281442-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: UQRMITJSPNE6GUDTX563LIAFREA53FAH X-Message-ID-Hash: UQRMITJSPNE6GUDTX563LIAFREA53FAH X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Peter Krempa X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1704444064605100001 virHostdevIsVFIODevice() and virDomainDefHasVFIOHostdev() are only ever called from the QEMU driver, and in the case of the QEMU driver, any PCI hostdev by definition uses VFIO, so really all these callers only need to know if the device is a PCI hostdev. (It turned out that the less specific virHostdevIsPCIDevice() already existed in hypervisor/virhostdev.c, so I had to remove one of them; since conf is a lower level directory than hypervisor, and the function is called from conf, keeping the copy in hypervisor would have required moving its caller (virDomainDefHasPCIHostdev()) into hypervisor as well, so I just removed the copy in hypervisor.) Signed-off-by: Laine Stump Reviewed-by: Peter Krempa --- src/conf/domain_conf.c | 13 ++++++------- src/conf/domain_conf.h | 4 ++-- src/hypervisor/virhostdev.c | 8 -------- src/hypervisor/virhostdev.h | 2 -- src/libvirt_private.syms | 5 ++--- src/qemu/qemu_domain.c | 6 +++--- src/qemu/qemu_hostdev.c | 2 +- src/qemu/qemu_hotplug.c | 2 +- 8 files changed, 15 insertions(+), 27 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b3c7b50f97..0f137543e0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -30653,12 +30653,12 @@ virDomainDefHasNVMeDisk(const virDomainDef *def) =20 =20 bool -virDomainDefHasVFIOHostdev(const virDomainDef *def) +virDomainDefHasPCIHostdev(const virDomainDef *def) { size_t i; =20 for (i =3D 0; i < def->nhostdevs; i++) { - if (virHostdevIsVFIODevice(def->hostdevs[i])) + if (virHostdevIsPCIDevice(def->hostdevs[i])) return true; } =20 @@ -30929,17 +30929,16 @@ virHostdevIsMdevDevice(const virDomainHostdevDef = *hostdev) =20 =20 /** - * virHostdevIsVFIODevice: + * virHostdevIsPCIDevice: * @hostdev: host device to check * - * Returns true if @hostdev is a PCI device with VFIO backend, false other= wise. + * Returns true if @hostdev is a PCI device, false otherwise. */ bool -virHostdevIsVFIODevice(const virDomainHostdevDef *hostdev) +virHostdevIsPCIDevice(const virDomainHostdevDef *hostdev) { return hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && - hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_= PCI && - hostdev->source.subsys.u.pci.driver.name =3D=3D VIR_DEVICE_HOSTDEV= _PCI_DRIVER_NAME_VFIO; + hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_= PCI; } =20 =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ee8bcbc6b3..7dd5bdbe56 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -4418,7 +4418,7 @@ bool virDomainDefHasNVMeDisk(const virDomainDef *def); =20 bool -virDomainDefHasVFIOHostdev(const virDomainDef *def); +virDomainDefHasPCIHostdev(const virDomainDef *def); =20 bool virDomainDefHasMdevHostdev(const virDomainDef *def); @@ -4476,7 +4476,7 @@ bool virHostdevIsMdevDevice(const virDomainHostdevDef *hostdev) ATTRIBUTE_NONNULL(1); bool -virHostdevIsVFIODevice(const virDomainHostdevDef *hostdev) +virHostdevIsPCIDevice(const virDomainHostdevDef *hostdev) ATTRIBUTE_NONNULL(1); =20 int diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c index 27b0acdc91..40f8a4bc2c 100644 --- a/src/hypervisor/virhostdev.c +++ b/src/hypervisor/virhostdev.c @@ -344,14 +344,6 @@ virHostdevNetDevice(virDomainHostdevDef *hostdev, } =20 =20 -bool -virHostdevIsPCIDevice(const virDomainHostdevDef *hostdev) -{ - return hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && - hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_= PCI; -} - - static bool virHostdevIsPCINetDevice(const virDomainHostdevDef *hostdev) { diff --git a/src/hypervisor/virhostdev.h b/src/hypervisor/virhostdev.h index 642d753ffb..22ec3068db 100644 --- a/src/hypervisor/virhostdev.h +++ b/src/hypervisor/virhostdev.h @@ -232,5 +232,3 @@ virHostdevUpdateActiveNVMeDevices(virHostdevManager *ho= stdev_mgr, const char *dom_name, virDomainDiskDef **disks, size_t ndisks); - -bool virHostdevIsPCIDevice(const virDomainHostdevDef *hostdev); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 002a3986d1..cccefe5a81 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -340,11 +340,11 @@ virDomainDefHasMemoryHotplug; virDomainDefHasNVMeDisk; virDomainDefHasOldStyleROUEFI; virDomainDefHasOldStyleUEFI; +virDomainDefHasPCIHostdev; virDomainDefHasSpiceGraphics; virDomainDefHasUSB; virDomainDefHasVcpusOffline; virDomainDefHasVDPANet; -virDomainDefHasVFIOHostdev; virDomainDefLifecycleActionAllowed; virDomainDefMaybeAddController; virDomainDefMaybeAddInput; @@ -777,8 +777,8 @@ virDomainEventWatchdogNewFromObj; virDomainQemuMonitorEventNew; virDomainQemuMonitorEventStateRegisterID; virHostdevIsMdevDevice; +virHostdevIsPCIDevice; virHostdevIsSCSIDevice; -virHostdevIsVFIODevice; =20 =20 # conf/domain_nwfilter.h @@ -1641,7 +1641,6 @@ virCloseCallbacksDomainRunForConn; =20 # hypervisor/virhostdev.h virHostdevFindUSBDevice; -virHostdevIsPCIDevice; virHostdevManagerGetDefault; virHostdevPCINodeDeviceDetach; virHostdevPCINodeDeviceReAttach; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 1aeeb74503..9357ce8d62 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9343,7 +9343,7 @@ getPPC64MemLockLimitBytes(virDomainDef *def) for (i =3D 0; i < def->nhostdevs; i++) { virDomainHostdevDef *dev =3D def->hostdevs[i]; =20 - if (virHostdevIsVFIODevice(dev)) { + if (virHostdevIsPCIDevice(dev)) { =20 pciAddr =3D &dev->source.subsys.u.pci.addr; if (virPCIDeviceAddressIsValid(pciAddr, false)) { @@ -9448,7 +9448,7 @@ qemuDomainGetNumVFIOHostdevs(const virDomainDef *def) int n =3D 0; =20 for (i =3D 0; i < def->nhostdevs; i++) { - if (virHostdevIsVFIODevice(def->hostdevs[i]) || + if (virHostdevIsPCIDevice(def->hostdevs[i]) || virHostdevIsMdevDevice(def->hostdevs[i])) n++; } @@ -10489,7 +10489,7 @@ qemuDomainSupportsVideoVga(const virDomainVideoDef = *video, bool qemuDomainNeedsVFIO(const virDomainDef *def) { - return virDomainDefHasVFIOHostdev(def) || + return virDomainDefHasPCIHostdev(def) || virDomainDefHasMdevHostdev(def) || virDomainDefHasNVMeDisk(def); } diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index 4992c23ee0..15b543dbff 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -133,7 +133,7 @@ qemuHostdevUpdateActiveDomainDevices(virQEMUDriver *dri= ver, bool qemuHostdevNeedsVFIO(const virDomainHostdevDef *hostdev) { - return virHostdevIsVFIODevice(hostdev) || + return virHostdevIsPCIDevice(hostdev) || virHostdevIsMdevDevice(hostdev); } =20 diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 75e1d39b60..0e45bd53e1 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -4738,7 +4738,7 @@ qemuDomainRemoveHostDevice(virQEMUDriver *driver, =20 virDomainAuditHostdev(vm, hostdev, "detach", true); =20 - if (!virHostdevIsVFIODevice(hostdev) && + if (!virHostdevIsPCIDevice(hostdev) && qemuSecurityRestoreHostdevLabel(driver, vm, hostdev) < 0) VIR_WARN("Failed to restore host device labelling"); =20 --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org