From nobody Thu May 9 08:52:40 2024 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 1704443022487950.2764385822799; Fri, 5 Jan 2024 00:23:42 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 2319519A1; Fri, 5 Jan 2024 03:23:41 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 49CAA17FB; Fri, 5 Jan 2024 03:20:34 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id A3BEC1843; Fri, 5 Jan 2024 03:20:21 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 00C6B17FB for ; Fri, 5 Jan 2024 03:20:19 -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-484-N4cX1chIOC-5n61btb9BLA-1; Fri, 05 Jan 2024 03:20:17 -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 72314805849 for ; Fri, 5 Jan 2024 08:20:17 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.16.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55AA92026D6F; Fri, 5 Jan 2024 08:20:17 +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_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: N4cX1chIOC-5n61btb9BLA-1 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH v3 01/13] util: properly deal with VFIO module name vs. driver name Date: Fri, 5 Jan 2024 03:20:04 -0500 Message-ID: <20240105082016.281442-2-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: I2JX25JESYQDPWATEKLZSTX2OMU2CA4F X-Message-ID-Hash: I2JX25JESYQDPWATEKLZSTX2OMU2CA4F 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: 1704443024364100001 Historically libvirt hasn't differentiated between the name of a loadable kernel module, and the name of the device driver that module implements, but these two names can be (and usually are) at least subtly different. For example, the loadable module called "vfio_pci" implements a PCI driver called "vfio-pci". We have always used the name "vfio-pci" both to load the module (with modprobe) and to check (in /sys/bus/pci/drivers) if the driver is available. (This has happened to work because modprobe "normalizes" all the names it is given by replacing "-" with "_", so "vfio-pci" works for both loading the module and checking for the driver.) When we recently gained the ability to manually specify the driver for "virsh nodedev-detach", the fragility of this system became apparent - if a user gave the "driver name" as "vfio_pci", then we would modprobe the module correctly, but then erroneously believe it hadn't been loaded because /sys/bus/pci/drivers/vfio_pci didn't exist. For manual specification of the driver name, we could deal with this by telling the user "always use the correct name for the driver, don't assume that it has the same name as the module", but it would still end up confusing people, especially since some drivers do use underscore in their name (e.g. the mlx5_vfio_pci driver/module). This will only get worse when an upcoming patch starts automatically determining the driver to use for VFIO-assigned devices - it will look in the kernel's modules.alias file to find "best" VFIO variant *module* for a device, and 3 out of 4 current examples of vfio-pci/variant drivers have a mismatch between module name and driver name, so the current code would end up properly loading the module, but then erroneously think that the driver wasn't available. This patch makes the code more forgiving by 1) checking for both $drivername and underscore($drivername) in /sys/bus/pci/drivers 2) when we determine a module needs to be loaded, look at the link in /sys/module/$modulename/driver/pci:$drivername to determine the name of the driver we need to bind to the device(rather than just assuming the driver has the same name as the module Signed-off-by: Laine Stump Reviewed-by: Peter Krempa --- Change from V1: I tried to simplify the explanation in the commit log messa= ge src/util/virpci.c | 193 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 163 insertions(+), 30 deletions(-) diff --git a/src/util/virpci.c b/src/util/virpci.c index afce7b52b7..f6bdf56057 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -222,6 +222,13 @@ virPCIDriverDir(const char *driver) } =20 =20 +static char * +virPCIModuleDir(const char *module) +{ + return g_strdup_printf("/sys/module/%s", module); +} + + static char * virPCIFile(const char *device, const char *file) { @@ -1154,44 +1161,166 @@ virPCIDeviceReset(virPCIDevice *dev, } =20 =20 +/** + * virPCINameDashToUnderscore: + * @path: the module/driver name or path - will be directly modified + * + * Replace all occurences of "-" with "_" in the name + * part of the path (everything after final "/" + * + * return true if any change was made, otherwise false. + */ static int -virPCIProbeDriver(const char *driverName) +virPCINameDashToUnderscore(char *path) { - g_autofree char *drvpath =3D NULL; + bool changed =3D false; + char *tmp =3D strrchr(path, '/'); + + if (!tmp) + tmp =3D path; + + while (*tmp) { + if (*tmp =3D=3D '-') { + *tmp =3D '_'; + changed =3D true; + } + tmp++; + } + + return changed; +} + + +static int +virPCIProbeModule(const char *moduleName) +{ + g_autofree char *modulePath =3D NULL; g_autofree char *errbuf =3D NULL; =20 - drvpath =3D virPCIDriverDir(driverName); + modulePath =3D virPCIModuleDir(moduleName); =20 /* driver previously loaded, return */ - if (virFileExists(drvpath)) + if (virFileExists(modulePath)) return 0; =20 - if ((errbuf =3D virKModLoad(driverName))) { - VIR_WARN("failed to load driver %s: %s", driverName, errbuf); - goto cleanup; + if ((errbuf =3D virKModLoad(moduleName))) { + /* If we know failure was because of admin config, let's report th= at; + * otherwise, report a more generic failure message + */ + if (virKModIsProhibited(moduleName)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to load PCI driver module %1$s: admin= istratively prohibited"), + moduleName); + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to load PCI driver module %1$s: %2$s"= ), + moduleName, errbuf); + } + return -1; } =20 /* driver loaded after probing */ - if (virFileExists(drvpath)) + if (virFileExists(modulePath)) return 0; =20 - cleanup: - /* If we know failure was because of admin config, let's report that; - * otherwise, report a more generic failure message + virReportError(VIR_ERR_INTERNAL_ERROR, + _("modprobe reported success loading module '%1$s', but= module is missing from /sys/module"), + moduleName); + return -1; +} + +/** + * virPCIDeviceFindDriver: + * @dev: initialized virPCIDevice, including desired stubDriverName + * + * Checks if there is a driver named @dev->stubDriverName already + * loaded. If there is, we're done. If not, look for a driver with + * that same name, except with dashes replaced with underscores. + + * If neither of the above is found, then look for/load the module of + * the underscored version of the name, and follow the links from + * /sys/module/$name/drivers/pci:* to the PCI driver associated with that + * module, and update @dev->stubDriverName with that name. + * + * On a successful return, @dev->stubDriverName will be updated with + * the proper name for the driver, and that driver will be loaded. + * + * returns 0 on success, -1 on failure + */ +static int +virPCIDeviceFindDriver(virPCIDevice *dev) +{ + g_autofree char *driverPath =3D virPCIDriverDir(dev->stubDriverName); + g_autofree char *moduleName =3D NULL; + g_autofree char *moduleDriversDir =3D NULL; + g_autoptr(DIR) dir =3D NULL; + struct dirent *ent; + int direrr; + + /* unchanged stubDriverName */ + if (virFileExists(driverPath)) + return 0; + + /* try replacing "-" with "_" */ + if (virPCINameDashToUnderscore(driverPath) && virFileExists(driverPath= )) { + + /* update original name in dev */ + virPCINameDashToUnderscore(dev->stubDriverName); + return 0; + } + + /* look for a module with this name (but always replacing + * "-" with "_", since that's what modprobe does) */ - if (virKModIsProhibited(driverName)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to load PCI driver module %1$s: administr= atively prohibited"), - driverName); - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to load PCI driver module %1$s"), - driverName); + + moduleName =3D g_strdup(dev->stubDriverName); + virPCINameDashToUnderscore(moduleName); + + if (virPCIProbeModule(moduleName) < 0) + return -1; + + /* module was found/loaded. Now find the PCI driver it implements, + * linked to by /sys/module/$moduleName/drivers/pci:$driverName + */ + + moduleDriversDir =3D g_strdup_printf("/sys/module/%s/drivers", moduleN= ame); + + if (virDirOpen(&dir, moduleDriversDir) < 0) + return -1; + + while ((direrr =3D virDirRead(dir, &ent, moduleDriversDir))) { + + if (STRPREFIX(ent->d_name, "pci:")) { + /* this is the link to the driver we want */ + + g_autofree char *drvName =3D NULL; + g_autofree char *drvPath =3D NULL; + + /* extract the driver name from the link name */ + drvName =3D g_strdup(ent->d_name + strlen("pci:")); + + /* make sure that driver is actually loaded */ + drvPath =3D virPCIDriverDir(drvName); + if (!virFileExists(drvPath)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("pci driver '%1$s' supposedly loaded by m= odule '%2$s' not found in sysfs"), + drvName, moduleName); + return -1; + } + + g_free(dev->stubDriverName); + dev->stubDriverName =3D g_steal_pointer(&drvName); + return 0; + } } =20 + virReportError(VIR_ERR_INTERNAL_ERROR, + _("module '%1$s' does not implement any pci driver"), + moduleName); return -1; } =20 + int virPCIDeviceUnbind(virPCIDevice *dev) { @@ -1291,7 +1420,6 @@ virPCIDeviceUnbindFromStub(virPCIDevice *dev) static int virPCIDeviceBindToStub(virPCIDevice *dev) { - const char *stubDriverName =3D dev->stubDriverName; g_autofree char *stubDriverPath =3D NULL; g_autofree char *driverLink =3D NULL; =20 @@ -1303,30 +1431,35 @@ virPCIDeviceBindToStub(virPCIDevice *dev) return -1; } =20 - if (!stubDriverName - && !(stubDriverName =3D virPCIStubDriverTypeToString(dev->stubDriv= erType))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown stub driver configured for PCI device %1= $s"), - dev->name); - return -1; + if (!dev->stubDriverName) { + + const char *stubDriverName =3D NULL; + + if (!(stubDriverName =3D virPCIStubDriverTypeToString(dev->stubDri= verType))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown stub driver configured for PCI devic= e %1$s"), + dev->name); + return -1; + } + dev->stubDriverName =3D g_strdup(stubDriverName); } =20 - if (virPCIProbeDriver(stubDriverName) < 0) + if (virPCIDeviceFindDriver(dev) < 0) return -1; =20 - stubDriverPath =3D virPCIDriverDir(stubDriverName); + stubDriverPath =3D virPCIDriverDir(dev->stubDriverName); driverLink =3D virPCIFile(dev->name, "driver"); =20 if (virFileExists(driverLink)) { if (virFileLinkPointsTo(driverLink, stubDriverPath)) { /* The device is already bound to the correct driver */ VIR_DEBUG("Device %s is already bound to %s", - dev->name, stubDriverName); + dev->name, dev->stubDriverName); return 0; } } =20 - if (virPCIDeviceBindWithDriverOverride(dev, stubDriverName) < 0) + if (virPCIDeviceBindWithDriverOverride(dev, dev->stubDriverName) < 0) return -1; =20 dev->unbind_from_stub =3D true; --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Thu May 9 08:52:40 2024 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 1704445258106225.76657490088257; Fri, 5 Jan 2024 01:00:58 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id BE5D51976; Fri, 5 Jan 2024 04:00:56 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 2FEE41901; Fri, 5 Jan 2024 03:22:19 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id A5BE417FB; Fri, 5 Jan 2024 03:20:32 -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 CFE9C184D for ; Fri, 5 Jan 2024 03:20:24 -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-209-3COkQjSsPgqjG_Ih52RsMg-1; Fri, 05 Jan 2024 03:20:17 -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 977A68371C1 for ; Fri, 5 Jan 2024 08:20:17 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.16.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7BE5E2026D6F; Fri, 5 Jan 2024 08:20:17 +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: 3COkQjSsPgqjG_Ih52RsMg-1 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH v3 02/13] schema: consolidate RNG for all hostdev elements Date: Fri, 5 Jan 2024 03:20:05 -0500 Message-ID: <20240105082016.281442-3-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: K2KS3PR5RO7CG7A7ZLDVXUEIISLZVNJW X-Message-ID-Hash: K2KS3PR5RO7CG7A7ZLDVXUEIISLZVNJW 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: 1704445259082100001 The exact same element can appear in and , and nearly identical in and (these latter two don't include "xen" as a possible driver, but that's coincidental - there's no reason Xen couldn't also use the VF pools in virtual networks, it just doesn't). This patch modifies all 4 to use the same so that it is simpler to add something new. A side effect of this patch is that the grammar for the element in domain XML has been tightened up a bit - previously it was accepted by the schema (but nonsensical) to have virtio and network interface options specified; as a part of making the two different choices each a complete element (rather than each being a collection of attributes and subelements) these extra attributes/subelements that were irrelevant to the hostdev-type were made to be valid only for an emulated interface's . Signed-off-by: Laine Stump Reviewed-by: Peter Krempa --- src/conf/schemas/basictypes.rng | 13 +++ src/conf/schemas/domaincommon.rng | 173 ++++++++++++++---------------- src/conf/schemas/network.rng | 10 +- src/conf/schemas/networkport.rng | 10 +- 4 files changed, 94 insertions(+), 112 deletions(-) diff --git a/src/conf/schemas/basictypes.rng b/src/conf/schemas/basictypes.= rng index 26eb538077..8d5f4475ca 100644 --- a/src/conf/schemas/basictypes.rng +++ b/src/conf/schemas/basictypes.rng @@ -656,4 +656,17 @@ =20 + + + + + kvm + vfio + xen + + + + + + diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index b98a2ae602..d9754bf418 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -3759,18 +3759,12 @@ - - - - - - kvm - vfio - xen - - - - + + + + + + @@ -3808,90 +3802,90 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - + + + + @@ -6224,16 +6218,7 @@ - - - - kvm - vfio - xen - - - - + diff --git a/src/conf/schemas/network.rng b/src/conf/schemas/network.rng index cda174ab4b..e56e07d130 100644 --- a/src/conf/schemas/network.rng +++ b/src/conf/schemas/network.rng @@ -179,15 +179,7 @@ - - - - kvm - vfio - - - - + diff --git a/src/conf/schemas/networkport.rng b/src/conf/schemas/networkpor= t.rng index 14db949578..50995559e8 100644 --- a/src/conf/schemas/networkport.rng +++ b/src/conf/schemas/networkport.rng @@ -145,15 +145,7 @@ - - - - kvm - vfio - - - - + --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Thu May 9 08:52:40 2024 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 1704443435459877.5535355418368; Fri, 5 Jan 2024 00:30:35 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 4E9BC198B; Fri, 5 Jan 2024 03:30:34 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 627711912; Fri, 5 Jan 2024 03:20:50 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 554BC181C; Fri, 5 Jan 2024 03:20:24 -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 0AA1617E6 for ; Fri, 5 Jan 2024 03:20:19 -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-427-dnKSjrCqOcmiOauMVkcWxA-1; Fri, 05 Jan 2024 03:20:18 -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 C25718371CA for ; Fri, 5 Jan 2024 08:20:17 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.16.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1CB12026D6F; Fri, 5 Jan 2024 08:20:17 +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: dnKSjrCqOcmiOauMVkcWxA-1 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH v3 03/13] conf: move/rename hostdev PCI driver type enum to device_conf.h Date: Fri, 5 Jan 2024 03:20:06 -0500 Message-ID: <20240105082016.281442-4-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: VB3NMQXKIYCRHABWXDUY6BMO6VUH3H23 X-Message-ID-Hash: VB3NMQXKIYCRHABWXDUY6BMO6VUH3H23 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: 1704443435837100001 Currently this enum is defined in domain_conf.h and named virDomainHostdevSubsysPCIDriverType. I want to use it in parts of the network and networkport config, so am moving its definition to device_conf.h which is / can be included by all interested parties, and renaming it to match the name of the corresponding XML attribute ("driver name"). The name change (which includes enum values) does cause a lot of churn, but it's all mechanical. Signed-off-by: Laine Stump Reviewed-by: Peter Krempa --- Change from V2: the name of the enum and its values has changed (due to my decision to no longer repurpose the driver name attribute) src/conf/device_conf.c | 9 ++++++++ src/conf/device_conf.h | 12 +++++++++++ src/conf/domain_capabilities.c | 2 +- src/conf/domain_capabilities.h | 2 +- src/conf/domain_conf.c | 36 ++++++++++++-------------------- src/conf/domain_conf.h | 14 +------------ src/hypervisor/virhostdev.c | 8 +++---- src/libvirt_private.syms | 2 +- src/libxl/libxl_capabilities.c | 3 +-- src/libxl/libxl_domain.c | 6 +++--- src/libxl/libxl_driver.c | 4 ++-- src/qemu/qemu_capabilities.c | 4 ++-- src/qemu/qemu_command.c | 12 +++++------ src/qemu/qemu_domain.c | 22 +++++++++---------- src/qemu/qemu_validate.c | 2 +- src/security/security_apparmor.c | 2 +- src/security/security_dac.c | 4 ++-- src/security/security_selinux.c | 4 ++-- src/security/virt-aa-helper.c | 7 ++++--- src/test/test_driver.c | 14 ++++++------- tests/domaincapstest.c | 4 ++-- tests/virhostdevtest.c | 2 +- tools/virsh-completer-nodedev.c | 4 ++-- 23 files changed, 89 insertions(+), 90 deletions(-) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index f3d977f2b7..a80b901214 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -29,6 +29,15 @@ =20 #define VIR_FROM_THIS VIR_FROM_DEVICE =20 +VIR_ENUM_IMPL(virDeviceHostdevPCIDriverName, + VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_LAST, + "default", + "kvm", + "vfio", + "xen", +); + + VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST, "none", diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index a83377417a..18aa4125fa 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -31,6 +31,18 @@ #include "virnetdev.h" #include "virenum.h" =20 +/* the backend driver used for PCI hostdev devices */ +typedef enum { + VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT =3D 0, /* detect automatica= lly, prefer VFIO */ + VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_KVM, /* force legacy kvm style */ + VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO, /* force vfio */ + VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN, /* force legacy xen style, = use pciback */ + + VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_LAST +} virDeviceHostdevPCIDriverName; + +VIR_ENUM_DECL(virDeviceHostdevPCIDriverName); + typedef enum { VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE =3D 0, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI, diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index f6e09dc584..68eb3c9797 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -524,7 +524,7 @@ virDomainCapsDeviceHostdevFormat(virBuffer *buf, ENUM_PROCESS(hostdev, startupPolicy, virDomainStartupPolicyTypeToStrin= g); ENUM_PROCESS(hostdev, subsysType, virDomainHostdevSubsysTypeToString); ENUM_PROCESS(hostdev, capsType, virDomainHostdevCapsTypeToString); - ENUM_PROCESS(hostdev, pciBackend, virDomainHostdevSubsysPCIBackendType= ToString); + ENUM_PROCESS(hostdev, pciBackend, virDeviceHostdevPCIDriverNameTypeToS= tring); =20 FORMAT_EPILOGUE(hostdev); } diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index 01bcfa2e39..fadc30cdd7 100644 --- a/src/conf/domain_capabilities.h +++ b/src/conf/domain_capabilities.h @@ -99,7 +99,7 @@ STATIC_ASSERT_ENUM(VIR_DOMAIN_HOSTDEV_MODE_LAST); STATIC_ASSERT_ENUM(VIR_DOMAIN_STARTUP_POLICY_LAST); STATIC_ASSERT_ENUM(VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST); STATIC_ASSERT_ENUM(VIR_DOMAIN_HOSTDEV_CAPS_TYPE_LAST); -STATIC_ASSERT_ENUM(VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST); +STATIC_ASSERT_ENUM(VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_LAST); typedef struct _virDomainCapsDeviceHostdev virDomainCapsDeviceHostdev; struct _virDomainCapsDeviceHostdev { virTristateBool supported; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 22ad43e1d7..e7e6296f9c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1054,13 +1054,6 @@ VIR_ENUM_IMPL(virDomainHostdevSubsys, "mdev", ); =20 -VIR_ENUM_IMPL(virDomainHostdevSubsysPCIBackend, - VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST, - "default", - "kvm", - "vfio", - "xen", -); =20 VIR_ENUM_IMPL(virDomainHostdevSubsysSCSIProtocol, VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_LAST, @@ -6290,7 +6283,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, =20 driver_node =3D virXPathNode("./driver", ctxt); if (virXMLPropEnum(driver_node, "name", - virDomainHostdevSubsysPCIBackendTypeFromString, + virDeviceHostdevPCIDriverNameTypeFromString, VIR_XML_PROP_NONZERO, &pcisrc->backend) < 0) return -1; @@ -23387,8 +23380,8 @@ virDomainHostdevDefFormatSubsysPCI(virBuffer *buf, virBufferAsprintf(&sourceAttrBuf, " writeFiltering=3D'%s'", virTristateBoolTypeToString(def->writeFilter= ing)); =20 - if (pcisrc->backend !=3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT) { - const char *backend =3D virDomainHostdevSubsysPCIBackendTypeToStri= ng(pcisrc->backend); + if (pcisrc->backend !=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT) { + const char *backend =3D virDeviceHostdevPCIDriverNameTypeToString(= pcisrc->backend); =20 if (!backend) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -29919,18 +29912,15 @@ virDomainNetDefActualFromNetworkPort(virDomainNet= Def *iface, actual->data.hostdev.def.source.subsys.u.pci.addr =3D port->plug.h= ostdevpci.addr; switch ((virNetworkForwardDriverNameType)port->plug.hostdevpci.dri= ver) { case VIR_NETWORK_FORWARD_DRIVER_NAME_DEFAULT: - actual->data.hostdev.def.source.subsys.u.pci.backend =3D - VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT; + actual->data.hostdev.def.source.subsys.u.pci.backend =3D VIR_D= EVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT; break; =20 case VIR_NETWORK_FORWARD_DRIVER_NAME_KVM: - actual->data.hostdev.def.source.subsys.u.pci.backend =3D - VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM; + actual->data.hostdev.def.source.subsys.u.pci.backend =3D VIR_D= EVICE_HOSTDEV_PCI_DRIVER_NAME_KVM; break; =20 case VIR_NETWORK_FORWARD_DRIVER_NAME_VFIO: - actual->data.hostdev.def.source.subsys.u.pci.backend =3D - VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO; + actual->data.hostdev.def.source.subsys.u.pci.backend =3D VIR_D= EVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO; break; =20 case VIR_NETWORK_FORWARD_DRIVER_NAME_LAST: @@ -30041,26 +30031,26 @@ virDomainNetDefActualToNetworkPort(virDomainDef *= dom, port->plug.hostdevpci.managed =3D virTristateBoolFromBool(actual->= data.hostdev.def.managed); port->plug.hostdevpci.addr =3D actual->data.hostdev.def.source.sub= sys.u.pci.addr; switch (actual->data.hostdev.def.source.subsys.u.pci.backend) { - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT: port->plug.hostdevpci.driver =3D VIR_NETWORK_FORWARD_DRIVER_NA= ME_DEFAULT; break; =20 - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_KVM: port->plug.hostdevpci.driver =3D VIR_NETWORK_FORWARD_DRIVER_NA= ME_KVM; break; =20 - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO: port->plug.hostdevpci.driver =3D VIR_NETWORK_FORWARD_DRIVER_NA= ME_VFIO; break; =20 - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Unexpected PCI backend 'xen'")); break; =20 - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_LAST: default: - virReportEnumRangeError(virDomainHostdevSubsysPCIBackendType, + virReportEnumRangeError(virDeviceHostdevPCIDriverName, actual->data.hostdev.def.source.subsys= .u.pci.backend); return NULL; } @@ -31005,7 +30995,7 @@ virHostdevIsVFIODevice(const virDomainHostdevDef *h= ostdev) { 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.backend =3D=3D VIR_DOMAIN_HOSTDEV_PCI= _BACKEND_VFIO; + hostdev->source.subsys.u.pci.backend =3D=3D VIR_DEVICE_HOSTDEV_PCI= _DRIVER_NAME_VFIO; } =20 =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ed07859bc5..0582cc928d 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -201,18 +201,6 @@ typedef enum { VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST } virDomainHostdevSubsysType; =20 -/* the backend driver used for PCI hostdev devices */ -typedef enum { - VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT =3D 0, /* detect automatically,= prefer VFIO */ - VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM, /* force legacy kvm style */ - VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO, /* force vfio */ - VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN, /* force legacy xen style, use = pciback */ - - VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST -} virDomainHostdevSubsysPCIBackendType; - -VIR_ENUM_DECL(virDomainHostdevSubsysPCIBackend); - typedef enum { VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE, VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI, @@ -247,7 +235,7 @@ struct _virDomainHostdevSubsysUSB { =20 struct _virDomainHostdevSubsysPCI { virPCIDeviceAddress addr; /* host address */ - virDomainHostdevSubsysPCIBackendType backend; + virDeviceHostdevPCIDriverName backend; =20 virBitmap *origstates; }; diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c index 4672bd8785..26c9ac3c28 100644 --- a/src/hypervisor/virhostdev.c +++ b/src/hypervisor/virhostdev.c @@ -243,14 +243,14 @@ virHostdevGetPCIHostDevice(const virDomainHostdevDef = *hostdev, =20 virPCIDeviceSetManaged(actual, hostdev->managed); =20 - if (pcisrc->backend =3D=3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) { + if (pcisrc->backend =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO) { virPCIDeviceSetStubDriverType(actual, VIR_PCI_STUB_DRIVER_VFIO); - } else if (pcisrc->backend =3D=3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN) { + } else if (pcisrc->backend =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_X= EN) { virPCIDeviceSetStubDriverType(actual, VIR_PCI_STUB_DRIVER_XEN); } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("pci backend driver '%1$s' is not supported"), - virDomainHostdevSubsysPCIBackendTypeToString(pcisrc= ->backend)); + _("pci backend driver type '%1$s' is not supported"= ), + virDeviceHostdevPCIDriverNameTypeToString(pcisrc->b= ackend)); return -1; } =20 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 553b01b8c0..002a3986d1 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -126,6 +126,7 @@ virCPUModeTypeToString; =20 # conf/device_conf.h virCCWDeviceAddressParseXML; +virDeviceHostdevPCIDriverNameTypeToString; virDeviceInfoPCIAddressExtensionIsPresent; virDeviceInfoPCIAddressExtensionIsWanted; virDeviceInfoPCIAddressIsPresent; @@ -467,7 +468,6 @@ virDomainHostdevInsert; virDomainHostdevMatch; virDomainHostdevModeTypeToString; virDomainHostdevRemove; -virDomainHostdevSubsysPCIBackendTypeToString; virDomainHostdevSubsysSCSIVHostModelTypeFromString; virDomainHostdevSubsysSCSIVHostModelTypeToString; virDomainHostdevSubsysTypeToString; diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c index 177e8b988e..de88c00e15 100644 --- a/src/libxl/libxl_capabilities.c +++ b/src/libxl/libxl_capabilities.c @@ -630,8 +630,7 @@ libxlMakeDomainDeviceHostdevCaps(virDomainCapsDeviceHos= tdev *dev) virDomainCapsEnumClear(&dev->capsType); =20 virDomainCapsEnumClear(&dev->pciBackend); - VIR_DOMAIN_CAPS_ENUM_SET(dev->pciBackend, - VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN); + VIR_DOMAIN_CAPS_ENUM_SET(dev->pciBackend, VIR_DEVICE_HOSTDEV_PCI_DRIVE= R_NAME_XEN); return 0; } =20 diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 0c4beffd6a..88d977e79b 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -160,8 +160,8 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDef *dev, =20 if (hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_T= YPE_PCI && - pcisrc->backend =3D=3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT) - pcisrc->backend =3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN; + pcisrc->backend =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFA= ULT) + pcisrc->backend =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN; } =20 if (dev->type =3D=3D VIR_DOMAIN_DEVICE_VIDEO) { @@ -997,7 +997,7 @@ libxlNetworkPrepareDevices(virDomainDef *def) =20 if (hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBS= YS_TYPE_PCI) - pcisrc->backend =3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN; + pcisrc->backend =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN; =20 if (virDomainHostdevInsert(def, hostdev) < 0) return -1; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index c98d2d737a..d7f79089c3 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -3398,12 +3398,12 @@ libxlDomainAttachNetDevice(libxlDriverPrivate *driv= er, virDomainHostdevSubsysPCI *pcisrc =3D &hostdev->source.subsys.u.pc= i; =20 /* For those just allocated from a network pool whose backend is - * still VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT, we need to set + * still VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT, we need to set * backend correctly. */ if (hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_T= YPE_PCI) - pcisrc->backend =3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN; + pcisrc->backend =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN; =20 /* This is really a "smart hostdev", so it should be attached * as a hostdev (the hostdev code will reach over into the diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 83119e871a..1a3d75eeab 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -6352,8 +6352,8 @@ virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCaps *q= emuCaps, if (supportsPassthroughVFIO && virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) { VIR_DOMAIN_CAPS_ENUM_SET(hostdev->pciBackend, - VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT, - VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO); + VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAUL= T, + VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO); } } =20 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 23909dbbab..2f0b1d0acd 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4709,16 +4709,16 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def, =20 /* caller has to assign proper passthrough backend type */ switch (pcisrc->backend) { - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO: break; =20 - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM: - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT: - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN: - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_KVM: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid PCI passthrough type '%1$s'"), - virDomainHostdevSubsysPCIBackendTypeToString(pcisrc= ->backend)); + virDeviceHostdevPCIDriverNameTypeToString(pcisrc->b= ackend)); return NULL; } =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 953808fcfe..1e2b74af02 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -10531,7 +10531,7 @@ qemuDomainGetHostdevPath(virDomainHostdevDef *dev, case VIR_DOMAIN_HOSTDEV_MODE_SUBSYS: switch (dev->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: - if (pcisrc->backend =3D=3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO= ) { + if (pcisrc->backend =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_= VFIO) { if (!(tmpPath =3D virPCIDeviceAddressGetIOMMUGroupDev(&pci= src->addr))) return -1; =20 @@ -11302,14 +11302,14 @@ qemuDomainPrepareHostdevPCI(virDomainHostdevDef *= hostdev, virQEMUCaps *qemuCaps) { bool supportsPassthroughVFIO =3D qemuHostdevHostSupportsPassthroughVFI= O(); - virDomainHostdevSubsysPCIBackendType *backend =3D &hostdev->source.sub= sys.u.pci.backend; + virDeviceHostdevPCIDriverName *driverName =3D &hostdev->source.subsys.= u.pci.backend; =20 /* assign defaults for hostdev passthrough */ - switch (*backend) { - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT: + switch (*driverName) { + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT: if (supportsPassthroughVFIO) { if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) { - *backend =3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO; + *driverName =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO; } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("VFIO PCI device assignment is not suppor= ted by this version of QEMU")); @@ -11322,7 +11322,7 @@ qemuDomainPrepareHostdevPCI(virDomainHostdevDef *ho= stdev, } break; =20 - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO: if (!supportsPassthroughVFIO) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("host doesn't support VFIO PCI passthrough")); @@ -11330,20 +11330,20 @@ qemuDomainPrepareHostdevPCI(virDomainHostdevDef *= hostdev, } break; =20 - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_KVM: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("host doesn't support legacy PCI passthrough")); return false; =20 - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("QEMU does not support device assignment mode '%1= $s'"), - virDomainHostdevSubsysPCIBackendTypeToString(*backe= nd)); + virDeviceHostdevPCIDriverNameTypeToString(*driverNa= me)); return false; =20 default: - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST: - virReportEnumRangeError(virDomainHostdevSubsysPCIBackendType, *bac= kend); + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_LAST: + virReportEnumRangeError(virDeviceHostdevPCIDriverName, *driverName= ); break; } =20 diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index e475ad035e..2aab0d9db2 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2464,7 +2464,7 @@ qemuValidateDomainDeviceDefHostdev(const virDomainHos= tdevDef *hostdev, case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: backend =3D hostdev->source.subsys.u.pci.backend; =20 - if (backend =3D=3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) { + if (backend =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO) { if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("VFIO PCI device assignment is not su= pported by this version of qemu")); diff --git a/src/security/security_apparmor.c b/src/security/security_appar= mor.c index 6fd0aedacf..a1cbbc77e9 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -869,7 +869,7 @@ AppArmorSetSecurityHostdevLabel(virSecurityManager *mgr, if (!pci) goto done; =20 - if (pcisrc->backend =3D=3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) { + if (pcisrc->backend =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO= ) { char *vfioGroupDev =3D virPCIDeviceGetIOMMUGroupDev(pci); =20 if (!vfioGroupDev) { diff --git a/src/security/security_dac.c b/src/security/security_dac.c index c07e488db7..cb8b72b289 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -1257,7 +1257,7 @@ virSecurityDACSetHostdevLabel(virSecurityManager *mgr, if (!pci) return -1; =20 - if (pcisrc->backend =3D=3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) { + if (pcisrc->backend =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO= ) { g_autofree char *vfioGroupDev =3D virPCIDeviceGetIOMMUGroupDev= (pci); =20 if (!vfioGroupDev) @@ -1418,7 +1418,7 @@ virSecurityDACRestoreHostdevLabel(virSecurityManager = *mgr, if (!pci) return -1; =20 - if (pcisrc->backend =3D=3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) { + if (pcisrc->backend =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO= ) { g_autofree char *vfioGroupDev =3D virPCIDeviceGetIOMMUGroupDev= (pci); =20 if (!vfioGroupDev) diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index 84c5ce75ed..2ee542f6a4 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -2201,7 +2201,7 @@ virSecuritySELinuxSetHostdevSubsysLabel(virSecurityMa= nager *mgr, if (!pci) return -1; =20 - if (pcisrc->backend =3D=3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) { + if (pcisrc->backend =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO= ) { g_autofree char *vfioGroupDev =3D virPCIDeviceGetIOMMUGroupDev= (pci); =20 if (!vfioGroupDev) @@ -2437,7 +2437,7 @@ virSecuritySELinuxRestoreHostdevSubsysLabel(virSecuri= tyManager *mgr, if (!pci) return -1; =20 - if (pcisrc->backend =3D=3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) { + if (pcisrc->backend =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO= ) { g_autofree char *vfioGroupDev =3D virPCIDeviceGetIOMMUGroupDev= (pci); =20 if (!vfioGroupDev) diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index be13979cef..d01df8710d 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -1092,9 +1092,10 @@ get_files(vahControl * ctl) case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: { virPCIDevice *pci =3D virPCIDeviceNew(&dev->source.subsys.= u.pci.addr); =20 - virDomainHostdevSubsysPCIBackendType backend =3D dev->sour= ce.subsys.u.pci.backend; - if (backend =3D=3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO || - backend =3D=3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFA= ULT) { + virDeviceHostdevPCIDriverName driverName =3D dev->source.s= ubsys.u.pci.backend; + + if (driverName =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_V= FIO || + driverName =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_D= EFAULT) { needsVfio =3D true; } =20 diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 67f8e75296..63e1f743c3 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -10045,16 +10045,16 @@ testDomainAttachHostPCIDevice(testDriver *driver = G_GNUC_UNUSED, int backend =3D hostdev->source.subsys.u.pci.backend; =20 switch (backend) { - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO: - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT: - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_KVM: break; =20 - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN: - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_LAST: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("test hypervisor does not support device assignme= nt mode '%1$s'"), - virDomainHostdevSubsysPCIBackendTypeToString(backen= d)); + virDeviceHostdevPCIDriverNameTypeToString(backend)); return -1; } =20 @@ -10080,7 +10080,7 @@ testDomainAttachHostDevice(testDriver *driver, if (hostdev->source.subsys.type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PC= I) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("hotplug is not supported for hostdev subsys type= '%1$s'"), - virDomainHostdevSubsysTypeToString(hostdev->source.= subsys.type)); + virDeviceHostdevPCIDriverNameTypeToString(hostdev->= source.subsys.type)); return -1; } =20 diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index c4a4508430..97b306f652 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -109,8 +109,8 @@ fillQemuCaps(virDomainCaps *domCaps, * successfully mocked as they are not exposed as internal APIs. There= fore, * instead of mocking set the expected values here by hand. */ VIR_DOMAIN_CAPS_ENUM_SET(domCaps->hostdev.pciBackend, - VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT, - VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO); + VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT, + VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO); =20 /* As of f05b6a918e28 we are expecting to see OVMF_CODE.fd file which * may not exists everywhere. */ diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c index 04e6c00908..89b4fb5e7c 100644 --- a/tests/virhostdevtest.c +++ b/tests/virhostdevtest.c @@ -134,7 +134,7 @@ myInit(void) subsys->u.pci.addr.bus =3D 0; subsys->u.pci.addr.slot =3D i + 1; subsys->u.pci.addr.function =3D 0; - subsys->u.pci.backend =3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO; + subsys->u.pci.backend =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO; } =20 for (i =3D 0; i < nhostdevs; i++) { diff --git a/tools/virsh-completer-nodedev.c b/tools/virsh-completer-nodede= v.c index d743df460e..72951a54f6 100644 --- a/tools/virsh-completer-nodedev.c +++ b/tools/virsh-completer-nodedev.c @@ -110,6 +110,6 @@ virshNodeDevicePCIBackendCompleter(vshControl *ctl G_GN= UC_UNUSED, { virCheckFlags(0, NULL); =20 - return virshEnumComplete(VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST, - virDomainHostdevSubsysPCIBackendTypeToString); + return virshEnumComplete(VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_LAST, + virDeviceHostdevPCIDriverNameTypeToString); } --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Thu May 9 08:52:40 2024 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 1704443759001842.480258138422; Fri, 5 Jan 2024 00:35:59 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id B1F6718DE; Fri, 5 Jan 2024 03:35:57 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id B03D31931; Fri, 5 Jan 2024 03:21:09 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 63F171851; Fri, 5 Jan 2024 03:20:26 -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 8EAFE1824 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-461-I7SdyO5HNTuCUfdjapT3Ng-1; Fri, 05 Jan 2024 03:20:18 -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 E77E2185A782 for ; Fri, 5 Jan 2024 08:20:17 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.16.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id CBD2C2026D6F; Fri, 5 Jan 2024 08:20:17 +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: I7SdyO5HNTuCUfdjapT3Ng-1 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH v3 04/13] conf: normalize hostdev parsing to simplify adding new attr Date: Fri, 5 Jan 2024 03:20:07 -0500 Message-ID: <20240105082016.281442-5-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: 5S6H7CLBDNOF3MNCBUPNPCWTUKICAQNP X-Message-ID-Hash: 5S6H7CLBDNOF3MNCBUPNPCWTUKICAQNP 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: 1704443761174100001 The hostdev version of the subelement appears in four places: * The domain XML in the and elements (that's 2) * The network XML inside when the network is a pool of SRIOV VFs * the XML, which is used to communicate between the hypervisor driver and network driver. In order to make the pending addition of a new attribute to in all these cases simpler, this patch refactors the parsing of in all four places to use virXMLProp*() and virXMLFormatElement(). Making all of the different instances of the separate parse/format for look nearly identical will make it easier to see that the upcoming patch that converges all four to use a common parser/formatter is a functional NOP. Signed-off-by: Laine Stump Reviewed-by: Peter Krempa --- src/conf/domain_conf.c | 28 ++++++++++++++++------------ src/conf/network_conf.c | 26 ++++++++++++-------------- src/conf/network_conf.h | 2 +- src/conf/virnetworkportdef.c | 31 +++++++++++++++++++------------ src/conf/virnetworkportdef.h | 2 +- 5 files changed, 49 insertions(+), 40 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e7e6296f9c..35a9138a95 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6281,13 +6281,14 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, if (virDomainHostdevSubsysPCIDefParseXML(sourcenode, ctxt, def, fl= ags) < 0) return -1; =20 - driver_node =3D virXPathNode("./driver", ctxt); - if (virXMLPropEnum(driver_node, "name", - virDeviceHostdevPCIDriverNameTypeFromString, - VIR_XML_PROP_NONZERO, - &pcisrc->backend) < 0) - return -1; - + if ((driver_node =3D virXPathNode("./driver", ctxt))) { + if (virXMLPropEnum(driver_node, "name", + virDeviceHostdevPCIDriverNameTypeFromString, + VIR_XML_PROP_NONZERO, + &pcisrc->backend) < 0) { + return -1; + } + } break; =20 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: @@ -23372,14 +23373,11 @@ virDomainHostdevDefFormatSubsysPCI(virBuffer *buf, unsigned int flags, bool includeTypeInAddr) { + g_auto(virBuffer) driverAttrBuf =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) sourceAttrBuf =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) sourceChildBuf =3D VIR_BUFFER_INIT_CHILD(buf); virDomainHostdevSubsysPCI *pcisrc =3D &def->source.subsys.u.pci; =20 - if (def->writeFiltering !=3D VIR_TRISTATE_BOOL_ABSENT) - virBufferAsprintf(&sourceAttrBuf, " writeFiltering=3D'%s'", - virTristateBoolTypeToString(def->writeFilter= ing)); - if (pcisrc->backend !=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT) { const char *backend =3D virDeviceHostdevPCIDriverNameTypeToString(= pcisrc->backend); =20 @@ -23390,9 +23388,15 @@ virDomainHostdevDefFormatSubsysPCI(virBuffer *buf, return -1; } =20 - virBufferAsprintf(buf, "\n", backend); + virBufferAsprintf(&driverAttrBuf, " name=3D'%s'", backend); } =20 + virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL); + + if (def->writeFiltering !=3D VIR_TRISTATE_BOOL_ABSENT) + virBufferAsprintf(&sourceAttrBuf, " writeFiltering=3D'%s'", + virTristateBoolTypeToString(def->writeFilter= ing)); + virPCIDeviceAddressFormat(&sourceChildBuf, pcisrc->addr, includeTypeIn= Addr); =20 if (pcisrc->origstates && diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 0449b6f07c..984ff564b2 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -1334,8 +1334,8 @@ virNetworkForwardDefParseXML(const char *networkName, g_autofree xmlNodePtr *forwardNatNodes =3D NULL; g_autofree char *forwardDev =3D NULL; g_autofree char *forwardManaged =3D NULL; - g_autofree char *forwardDriverName =3D NULL; g_autofree char *type =3D NULL; + xmlNodePtr driverNode =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) =20 ctxt->node =3D node; @@ -1356,18 +1356,13 @@ virNetworkForwardDefParseXML(const char *networkNam= e, def->managed =3D true; } =20 - forwardDriverName =3D virXPathString("string(./driver/@name)", ctxt); - if (forwardDriverName) { - int driverName - =3D virNetworkForwardDriverNameTypeFromString(forwardDriverNam= e); - - if (driverName <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unknown forward in n= etwork %2$s"), - forwardDriverName, networkName); + if ((driverNode =3D virXPathNode("./driver", ctxt))) { + if (virXMLPropEnum(driverNode, "name", + virNetworkForwardDriverNameTypeFromString, + VIR_XML_PROP_NONZERO, + &def->driverName) < 0) { return -1; } - def->driverName =3D driverName; } =20 /* bridge and hostdev modes can use a pool of physical interfaces */ @@ -2329,6 +2324,7 @@ virNetworkDefFormatBuf(virBuffer *buf, if (def->forward.type !=3D VIR_NETWORK_FORWARD_NONE) { const char *dev =3D NULL; const char *mode =3D virNetworkForwardTypeToString(def->forward.ty= pe); + g_auto(virBuffer) driverAttrBuf =3D VIR_BUFFER_INITIALIZER; =20 if (!def->forward.npfs) dev =3D virNetworkDefForwardIf(def, 0); @@ -2359,8 +2355,7 @@ virNetworkDefFormatBuf(virBuffer *buf, virBufferAsprintf(buf, "%s>\n", shortforward ? "/" : ""); virBufferAdjustIndent(buf, 2); =20 - if (def->forward.driverName - !=3D VIR_NETWORK_FORWARD_DRIVER_NAME_DEFAULT) { + if (def->forward.driverName) { const char *driverName =3D virNetworkForwardDriverNameTypeToString(def->forward.d= riverName); if (!driverName) { @@ -2369,8 +2364,11 @@ virNetworkDefFormatBuf(virBuffer *buf, def->forward.driverName); return -1; } - virBufferAsprintf(buf, "\n", driverName); + virBufferAsprintf(&driverAttrBuf, " name=3D'%s'", driverName); } + + virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL); + if (def->forward.type =3D=3D VIR_NETWORK_FORWARD_NAT) { if (virNetworkForwardNatDefFormat(buf, &def->forward) < 0) return -1; diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h index 5a1bdb1284..497ae765f2 100644 --- a/src/conf/network_conf.h +++ b/src/conf/network_conf.h @@ -216,7 +216,7 @@ typedef struct _virNetworkForwardDef virNetworkForwardD= ef; struct _virNetworkForwardDef { int type; /* One of virNetworkForwardType constants */ bool managed; /* managed attribute for hostdev mode */ - int driverName; /* enum virNetworkForwardDriverNameType */ + virNetworkForwardDriverNameType driverName; =20 /* If there are multiple forward devices (i.e. a pool of * interfaces), they will be listed here. diff --git a/src/conf/virnetworkportdef.c b/src/conf/virnetworkportdef.c index fc06ef41d5..ac17313f83 100644 --- a/src/conf/virnetworkportdef.c +++ b/src/conf/virnetworkportdef.c @@ -87,10 +87,10 @@ virNetworkPortDefParseXML(xmlXPathContextPtr ctxt) xmlNodePtr addressNode; xmlNodePtr rxfiltersNode =3D NULL; xmlNodePtr plugNode =3D NULL; + xmlNodePtr driverNode =3D NULL; g_autofree char *mac =3D NULL; g_autofree char *macmgr =3D NULL; g_autofree char *mode =3D NULL; - g_autofree char *driver =3D NULL; =20 def =3D g_new0(virNetworkPortDef, 1); =20 @@ -223,14 +223,16 @@ virNetworkPortDefParseXML(xmlXPathContextPtr ctxt) VIR_XML_PROP_NONE, &def->plug.hostdevpci.managed) < 0) return NULL; - driver =3D virXPathString("string(./plug/driver/@name)", ctxt); - if (driver && - (def->plug.hostdevpci.driver =3D - virNetworkForwardDriverNameTypeFromString(driver)) <=3D 0) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing network port driver name")); - return NULL; + + if ((driverNode =3D virXPathNode("./plug/driver", ctxt))) { + if (virXMLPropEnum(driverNode, "name", + virNetworkForwardDriverNameTypeFromString, + VIR_XML_PROP_NONZERO, + &def->plug.hostdevpci.driver) < 0) { + return NULL; + } } + if (!(addressNode =3D virXPathNode("./plug/address", ctxt))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing network port PCI address")); @@ -319,6 +321,8 @@ virNetworkPortDefFormatBuf(virBuffer *buf, virTristateBoolTypeToString(def->trustGuestRxFil= ters)); =20 if (def->plugtype !=3D VIR_NETWORK_PORT_PLUG_TYPE_NONE) { + g_auto(virBuffer) driverAttrBuf =3D VIR_BUFFER_INITIALIZER; + virBufferAsprintf(buf, "plugtype)); =20 @@ -351,10 +355,13 @@ virNetworkPortDefFormatBuf(virBuffer *buf, } virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); - if (def->plug.hostdevpci.driver) - virBufferEscapeString(buf, "\n", - virNetworkForwardDriverNameTypeToStr= ing( - def->plug.hostdevpci.driver)); + + if (def->plug.hostdevpci.driver) { + virBufferEscapeString(&driverAttrBuf, " name=3D'%s'", + virNetworkForwardDriverNameTypeToStr= ing(def->plug.hostdevpci.driver)); + } + + virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL); =20 virPCIDeviceAddressFormat(buf, def->plug.hostdevpci.addr, fals= e); virBufferAdjustIndent(buf, -2); diff --git a/src/conf/virnetworkportdef.h b/src/conf/virnetworkportdef.h index 48e73dbefd..bfe1dae9ea 100644 --- a/src/conf/virnetworkportdef.h +++ b/src/conf/virnetworkportdef.h @@ -69,7 +69,7 @@ struct _virNetworkPortDef { } direct; struct { virPCIDeviceAddress addr; /* PCI Address of device */ - int driver; /* virNetworkForwardDriverNameType */ + unsigned int driver; /* virNetworkForwardDriverNameType */ virTristateBool managed; } hostdevpci; } plug; --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Thu May 9 08:52:40 2024 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 1704444275351881.6226099702527; Fri, 5 Jan 2024 00:44:35 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 401B019D3; Fri, 5 Jan 2024 03:44:34 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 74F3A188C; Fri, 5 Jan 2024 03:21:34 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id E191A17FB; 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.133.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 5B18A1815 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-518-9Xoxb7SgPkyXsG8nnGoDRg-1; Fri, 05 Jan 2024 03:20:18 -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 1971083BA85 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 F215A2026D6F; Fri, 5 Jan 2024 08:20:17 +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_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: 9Xoxb7SgPkyXsG8nnGoDRg-1 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH v3 05/13] conf: put hostdev PCI backend into a struct Date: Fri, 5 Jan 2024 03:20:08 -0500 Message-ID: <20240105082016.281442-6-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: MPJ6OBURCW3GZ6RC3OJM5VSCQC3GBSS3 X-Message-ID-Hash: MPJ6OBURCW3GZ6RC3OJM5VSCQC3GBSS3 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: 1704444275652100001 The new struct is virDeviceHostdevPCIDriverInfo, and the "backend" enum in the hostdevDef will be replaced with a virDeviceHostdevPCIDriverInfo named "driver'. Since the enum value in this new struct is called "name", it means that all references to "backend" will become "driver.name". This will allow easily adding other items for new attributes in the element / C struct, which will be useful once we are using this new struct in multiple places. Signed-off-by: Laine Stump Reviewed-by: Peter Krempa --- Change from V2: names have changed, extra line breaks removed src/conf/device_conf.h | 4 ++++ src/conf/domain_conf.c | 30 +++++++++++++----------------- src/conf/domain_conf.h | 2 +- src/conf/virconftypes.h | 2 ++ src/hypervisor/virhostdev.c | 6 +++--- src/libxl/libxl_domain.c | 6 +++--- src/libxl/libxl_driver.c | 6 +++--- src/qemu/qemu_command.c | 6 +++--- src/qemu/qemu_domain.c | 4 ++-- src/qemu/qemu_validate.c | 6 +++--- src/security/security_apparmor.c | 2 +- src/security/security_dac.c | 4 ++-- src/security/security_selinux.c | 4 ++-- src/security/virt-aa-helper.c | 2 +- src/test/test_driver.c | 6 +++--- tests/virhostdevtest.c | 2 +- 16 files changed, 47 insertions(+), 45 deletions(-) diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index 18aa4125fa..1f7e066142 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -43,6 +43,10 @@ typedef enum { =20 VIR_ENUM_DECL(virDeviceHostdevPCIDriverName); =20 +struct _virDeviceHostdevPCIDriverInfo { + virDeviceHostdevPCIDriverName name; +}; + typedef enum { VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE =3D 0, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI, diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 35a9138a95..887b871589 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6285,7 +6285,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, if (virXMLPropEnum(driver_node, "name", virDeviceHostdevPCIDriverNameTypeFromString, VIR_XML_PROP_NONZERO, - &pcisrc->backend) < 0) { + &pcisrc->driver.name) < 0) { return -1; } } @@ -23378,17 +23378,17 @@ virDomainHostdevDefFormatSubsysPCI(virBuffer *buf, g_auto(virBuffer) sourceChildBuf =3D VIR_BUFFER_INIT_CHILD(buf); virDomainHostdevSubsysPCI *pcisrc =3D &def->source.subsys.u.pci; =20 - if (pcisrc->backend !=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT) { - const char *backend =3D virDeviceHostdevPCIDriverNameTypeToString(= pcisrc->backend); + if (pcisrc->driver.name !=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAUL= T) { + const char *driverName =3D virDeviceHostdevPCIDriverNameTypeToStri= ng(pcisrc->driver.name); =20 - if (!backend) { + if (!driverName) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected pci hostdev driver name type %1$d= "), - pcisrc->backend); + _("unexpected pci hostdev driver type %1$d"), + pcisrc->driver.name); return -1; } =20 - virBufferAsprintf(&driverAttrBuf, " name=3D'%s'", backend); + virBufferAsprintf(&driverAttrBuf, " name=3D'%s'", driverName); } =20 virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL); @@ -29916,15 +29916,15 @@ virDomainNetDefActualFromNetworkPort(virDomainNet= Def *iface, actual->data.hostdev.def.source.subsys.u.pci.addr =3D port->plug.h= ostdevpci.addr; switch ((virNetworkForwardDriverNameType)port->plug.hostdevpci.dri= ver) { case VIR_NETWORK_FORWARD_DRIVER_NAME_DEFAULT: - actual->data.hostdev.def.source.subsys.u.pci.backend =3D VIR_D= EVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT; + actual->data.hostdev.def.source.subsys.u.pci.driver.name =3D V= IR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT; break; =20 case VIR_NETWORK_FORWARD_DRIVER_NAME_KVM: - actual->data.hostdev.def.source.subsys.u.pci.backend =3D VIR_D= EVICE_HOSTDEV_PCI_DRIVER_NAME_KVM; + actual->data.hostdev.def.source.subsys.u.pci.driver.name =3D V= IR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_KVM; break; =20 case VIR_NETWORK_FORWARD_DRIVER_NAME_VFIO: - actual->data.hostdev.def.source.subsys.u.pci.backend =3D VIR_D= EVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO; + actual->data.hostdev.def.source.subsys.u.pci.driver.name =3D V= IR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO; break; =20 case VIR_NETWORK_FORWARD_DRIVER_NAME_LAST: @@ -30034,7 +30034,7 @@ virDomainNetDefActualToNetworkPort(virDomainDef *do= m, } port->plug.hostdevpci.managed =3D virTristateBoolFromBool(actual->= data.hostdev.def.managed); port->plug.hostdevpci.addr =3D actual->data.hostdev.def.source.sub= sys.u.pci.addr; - switch (actual->data.hostdev.def.source.subsys.u.pci.backend) { + switch (actual->data.hostdev.def.source.subsys.u.pci.driver.name) { case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT: port->plug.hostdevpci.driver =3D VIR_NETWORK_FORWARD_DRIVER_NA= ME_DEFAULT; break; @@ -30048,14 +30048,10 @@ virDomainNetDefActualToNetworkPort(virDomainDef *= dom, break; =20 case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Unexpected PCI backend 'xen'")); - break; - case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_LAST: default: virReportEnumRangeError(virDeviceHostdevPCIDriverName, - actual->data.hostdev.def.source.subsys= .u.pci.backend); + actual->data.hostdev.def.source.subsys= .u.pci.driver.name); return NULL; } =20 @@ -30999,7 +30995,7 @@ virHostdevIsVFIODevice(const virDomainHostdevDef *h= ostdev) { 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.backend =3D=3D VIR_DEVICE_HOSTDEV_PCI= _DRIVER_NAME_VFIO; + hostdev->source.subsys.u.pci.driver.name =3D=3D VIR_DEVICE_HOSTDEV= _PCI_DRIVER_NAME_VFIO; } =20 =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 0582cc928d..ee8bcbc6b3 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -235,7 +235,7 @@ struct _virDomainHostdevSubsysUSB { =20 struct _virDomainHostdevSubsysPCI { virPCIDeviceAddress addr; /* host address */ - virDeviceHostdevPCIDriverName backend; + virDeviceHostdevPCIDriverInfo driver; =20 virBitmap *origstates; }; diff --git a/src/conf/virconftypes.h b/src/conf/virconftypes.h index 26cb966194..0779bc224b 100644 --- a/src/conf/virconftypes.h +++ b/src/conf/virconftypes.h @@ -66,6 +66,8 @@ typedef struct _virCapsHostSecModelLabel virCapsHostSecMo= delLabel; =20 typedef struct _virCapsStoragePool virCapsStoragePool; =20 +typedef struct _virDeviceHostdevPCIDriverInfo virDeviceHostdevPCIDriverInf= o; + typedef struct _virDomainABIStability virDomainABIStability; =20 typedef struct _virDomainActualNetDef virDomainActualNetDef; diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c index 26c9ac3c28..27b0acdc91 100644 --- a/src/hypervisor/virhostdev.c +++ b/src/hypervisor/virhostdev.c @@ -243,14 +243,14 @@ virHostdevGetPCIHostDevice(const virDomainHostdevDef = *hostdev, =20 virPCIDeviceSetManaged(actual, hostdev->managed); =20 - if (pcisrc->backend =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO) { + if (pcisrc->driver.name =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO= ) { virPCIDeviceSetStubDriverType(actual, VIR_PCI_STUB_DRIVER_VFIO); - } else if (pcisrc->backend =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_X= EN) { + } else if (pcisrc->driver.name =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NA= ME_XEN) { virPCIDeviceSetStubDriverType(actual, VIR_PCI_STUB_DRIVER_XEN); } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("pci backend driver type '%1$s' is not supported"= ), - virDeviceHostdevPCIDriverNameTypeToString(pcisrc->b= ackend)); + virDeviceHostdevPCIDriverNameTypeToString(pcisrc->d= river.name)); return -1; } =20 diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 88d977e79b..1a7de00704 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -160,8 +160,8 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDef *dev, =20 if (hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_T= YPE_PCI && - pcisrc->backend =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFA= ULT) - pcisrc->backend =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN; + pcisrc->driver.name =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_= DEFAULT) + pcisrc->driver.name =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN; } =20 if (dev->type =3D=3D VIR_DOMAIN_DEVICE_VIDEO) { @@ -997,7 +997,7 @@ libxlNetworkPrepareDevices(virDomainDef *def) =20 if (hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBS= YS_TYPE_PCI) - pcisrc->backend =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN; + pcisrc->driver.name =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME= _XEN; =20 if (virDomainHostdevInsert(def, hostdev) < 0) return -1; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index d7f79089c3..29fbc823dd 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -3397,13 +3397,13 @@ libxlDomainAttachNetDevice(libxlDriverPrivate *driv= er, virDomainHostdevDef *hostdev =3D virDomainNetGetActualHostdev(net); virDomainHostdevSubsysPCI *pcisrc =3D &hostdev->source.subsys.u.pc= i; =20 - /* For those just allocated from a network pool whose backend is + /* For those just allocated from a network pool whose driver type = is * still VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT, we need to set - * backend correctly. + * driver name correctly. */ if (hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_T= YPE_PCI) - pcisrc->backend =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN; + pcisrc->driver.name =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN; =20 /* This is really a "smart hostdev", so it should be attached * as a hostdev (the hostdev code will reach over into the diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 2f0b1d0acd..b3ebf711e5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4707,8 +4707,8 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def, g_autofree char *host =3D virPCIDeviceAddressAsString(&pcisrc->addr); const char *failover_pair_id =3D NULL; =20 - /* caller has to assign proper passthrough backend type */ - switch (pcisrc->backend) { + /* caller has to assign proper passthrough driver name */ + switch (pcisrc->driver.name) { case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO: break; =20 @@ -4718,7 +4718,7 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def, case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid PCI passthrough type '%1$s'"), - virDeviceHostdevPCIDriverNameTypeToString(pcisrc->b= ackend)); + virDeviceHostdevPCIDriverNameTypeToString(pcisrc->d= river.name)); return NULL; } =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 1e2b74af02..1aeeb74503 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -10531,7 +10531,7 @@ qemuDomainGetHostdevPath(virDomainHostdevDef *dev, case VIR_DOMAIN_HOSTDEV_MODE_SUBSYS: switch (dev->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: - if (pcisrc->backend =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_= VFIO) { + if (pcisrc->driver.name =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_N= AME_VFIO) { if (!(tmpPath =3D virPCIDeviceAddressGetIOMMUGroupDev(&pci= src->addr))) return -1; =20 @@ -11302,7 +11302,7 @@ qemuDomainPrepareHostdevPCI(virDomainHostdevDef *ho= stdev, virQEMUCaps *qemuCaps) { bool supportsPassthroughVFIO =3D qemuHostdevHostSupportsPassthroughVFI= O(); - virDeviceHostdevPCIDriverName *driverName =3D &hostdev->source.subsys.= u.pci.backend; + virDeviceHostdevPCIDriverName *driverName =3D &hostdev->source.subsys.= u.pci.driver.name; =20 /* assign defaults for hostdev passthrough */ switch (*driverName) { diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 2aab0d9db2..4d388bbcc4 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2437,7 +2437,7 @@ qemuValidateDomainDeviceDefHostdev(const virDomainHos= tdevDef *hostdev, const virDomainDef *def, virQEMUCaps *qemuCaps) { - int backend; + virDeviceHostdevPCIDriverName driverName; =20 /* forbid capabilities mode hostdev in this kind of hypervisor */ if (hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) { @@ -2462,9 +2462,9 @@ qemuValidateDomainDeviceDefHostdev(const virDomainHos= tdevDef *hostdev, break; =20 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: - backend =3D hostdev->source.subsys.u.pci.backend; + driverName =3D hostdev->source.subsys.u.pci.driver.name; =20 - if (backend =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO) { + if (driverName =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO)= { if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("VFIO PCI device assignment is not su= pported by this version of qemu")); diff --git a/src/security/security_apparmor.c b/src/security/security_appar= mor.c index a1cbbc77e9..c1dc859751 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -869,7 +869,7 @@ AppArmorSetSecurityHostdevLabel(virSecurityManager *mgr, if (!pci) goto done; =20 - if (pcisrc->backend =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO= ) { + if (pcisrc->driver.name =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_= VFIO) { char *vfioGroupDev =3D virPCIDeviceGetIOMMUGroupDev(pci); =20 if (!vfioGroupDev) { diff --git a/src/security/security_dac.c b/src/security/security_dac.c index cb8b72b289..4b8130630f 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -1257,7 +1257,7 @@ virSecurityDACSetHostdevLabel(virSecurityManager *mgr, if (!pci) return -1; =20 - if (pcisrc->backend =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO= ) { + if (pcisrc->driver.name =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_= VFIO) { g_autofree char *vfioGroupDev =3D virPCIDeviceGetIOMMUGroupDev= (pci); =20 if (!vfioGroupDev) @@ -1418,7 +1418,7 @@ virSecurityDACRestoreHostdevLabel(virSecurityManager = *mgr, if (!pci) return -1; =20 - if (pcisrc->backend =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO= ) { + if (pcisrc->driver.name =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_= VFIO) { g_autofree char *vfioGroupDev =3D virPCIDeviceGetIOMMUGroupDev= (pci); =20 if (!vfioGroupDev) diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index 2ee542f6a4..ffad058d9a 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -2201,7 +2201,7 @@ virSecuritySELinuxSetHostdevSubsysLabel(virSecurityMa= nager *mgr, if (!pci) return -1; =20 - if (pcisrc->backend =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO= ) { + if (pcisrc->driver.name =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_= VFIO) { g_autofree char *vfioGroupDev =3D virPCIDeviceGetIOMMUGroupDev= (pci); =20 if (!vfioGroupDev) @@ -2437,7 +2437,7 @@ virSecuritySELinuxRestoreHostdevSubsysLabel(virSecuri= tyManager *mgr, if (!pci) return -1; =20 - if (pcisrc->backend =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO= ) { + if (pcisrc->driver.name =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_= VFIO) { g_autofree char *vfioGroupDev =3D virPCIDeviceGetIOMMUGroupDev= (pci); =20 if (!vfioGroupDev) diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index d01df8710d..0374581f07 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -1092,7 +1092,7 @@ get_files(vahControl * ctl) case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: { virPCIDevice *pci =3D virPCIDeviceNew(&dev->source.subsys.= u.pci.addr); =20 - virDeviceHostdevPCIDriverName driverName =3D dev->source.s= ubsys.u.pci.backend; + virDeviceHostdevPCIDriverName driverName =3D dev->source.s= ubsys.u.pci.driver.name; =20 if (driverName =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_V= FIO || driverName =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_D= EFAULT) { diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 63e1f743c3..ed545848af 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -10042,9 +10042,9 @@ testDomainAttachHostPCIDevice(testDriver *driver G_= GNUC_UNUSED, virDomainObj *vm, virDomainHostdevDef *hostdev) { - int backend =3D hostdev->source.subsys.u.pci.backend; + int driverName =3D hostdev->source.subsys.u.pci.driver.name; =20 - switch (backend) { + switch (driverName) { case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO: case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT: case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_KVM: @@ -10054,7 +10054,7 @@ testDomainAttachHostPCIDevice(testDriver *driver G_= GNUC_UNUSED, case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_LAST: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("test hypervisor does not support device assignme= nt mode '%1$s'"), - virDeviceHostdevPCIDriverNameTypeToString(backend)); + virDeviceHostdevPCIDriverNameTypeToString(driverNam= e)); return -1; } =20 diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c index 89b4fb5e7c..aec474a148 100644 --- a/tests/virhostdevtest.c +++ b/tests/virhostdevtest.c @@ -134,7 +134,7 @@ myInit(void) subsys->u.pci.addr.bus =3D 0; subsys->u.pci.addr.slot =3D i + 1; subsys->u.pci.addr.function =3D 0; - subsys->u.pci.backend =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO; + subsys->u.pci.driver.name =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_V= FIO; } =20 for (i =3D 0; i < nhostdevs; i++) { --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Thu May 9 08:52:40 2024 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 1704443922745578.4234119638867; Fri, 5 Jan 2024 00:38:42 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id A38E618D3; Fri, 5 Jan 2024 03:38:41 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id E0E131877; Fri, 5 Jan 2024 03:21:16 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 91A951824; Fri, 5 Jan 2024 03:20:26 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 A19511826 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-518-GBCgY_ASPgmGMx8m-nNRcw-1; Fri, 05 Jan 2024 03:20:18 -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 3F4CF83BA86 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 23E5D2026D6F; 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_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: GBCgY_ASPgmGMx8m-nNRcw-1 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH v3 06/13] conf: use virDeviceHostdevPCIDriverInfo in network and networkport objects Date: Fri, 5 Jan 2024 03:20:09 -0500 Message-ID: <20240105082016.281442-7-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: OO27IBXFW3L746J6LDA3GB7ORVUQ5CGT X-Message-ID-Hash: OO27IBXFW3L746J6LDA3GB7ORVUQ5CGT 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: 1704443923911100001 The next step in consolidating parsing/formatting of the element of these objects using a common struct and common code. This eliminates the virNetworkForwardDriverNameType enum which is nearly identical to virDeviceHostdevPCIDriverName (the only non-identical bit was just because they'd gotten out of sync over time) and replaces its uses with a virDeviceHostdevPCIDriverInfo (which is a struct that contains a virDeviceHostdevPCIDriverName). Signed-off-by: Laine Stump Reviewed-by: Peter Krempa --- src/conf/domain_conf.c | 43 ++---------------------------------- src/conf/network_conf.c | 23 ++++++------------- src/conf/network_conf.h | 17 ++------------ src/conf/virnetworkportdef.c | 8 +++---- src/conf/virnetworkportdef.h | 4 +++- src/network/bridge_driver.c | 2 +- 6 files changed, 19 insertions(+), 78 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 887b871589..e19a2817c4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29914,26 +29914,7 @@ virDomainNetDefActualFromNetworkPort(virDomainNetD= ef *iface, } actual->data.hostdev.def.source.subsys.type =3D VIR_DOMAIN_HOSTDEV= _SUBSYS_TYPE_PCI; actual->data.hostdev.def.source.subsys.u.pci.addr =3D port->plug.h= ostdevpci.addr; - switch ((virNetworkForwardDriverNameType)port->plug.hostdevpci.dri= ver) { - case VIR_NETWORK_FORWARD_DRIVER_NAME_DEFAULT: - actual->data.hostdev.def.source.subsys.u.pci.driver.name =3D V= IR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT; - break; - - case VIR_NETWORK_FORWARD_DRIVER_NAME_KVM: - actual->data.hostdev.def.source.subsys.u.pci.driver.name =3D V= IR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_KVM; - break; - - case VIR_NETWORK_FORWARD_DRIVER_NAME_VFIO: - actual->data.hostdev.def.source.subsys.u.pci.driver.name =3D V= IR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO; - break; - - case VIR_NETWORK_FORWARD_DRIVER_NAME_LAST: - default: - virReportEnumRangeError(virNetworkForwardDriverNameType, - port->plug.hostdevpci.driver); - goto error; - } - + actual->data.hostdev.def.source.subsys.u.pci.driver.name =3D port-= >plug.hostdevpci.driver.name; break; =20 case VIR_NETWORK_PORT_PLUG_TYPE_LAST: @@ -30034,27 +30015,7 @@ virDomainNetDefActualToNetworkPort(virDomainDef *d= om, } port->plug.hostdevpci.managed =3D virTristateBoolFromBool(actual->= data.hostdev.def.managed); port->plug.hostdevpci.addr =3D actual->data.hostdev.def.source.sub= sys.u.pci.addr; - switch (actual->data.hostdev.def.source.subsys.u.pci.driver.name) { - case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT: - port->plug.hostdevpci.driver =3D VIR_NETWORK_FORWARD_DRIVER_NA= ME_DEFAULT; - break; - - case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_KVM: - port->plug.hostdevpci.driver =3D VIR_NETWORK_FORWARD_DRIVER_NA= ME_KVM; - break; - - case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO: - port->plug.hostdevpci.driver =3D VIR_NETWORK_FORWARD_DRIVER_NA= ME_VFIO; - break; - - case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN: - case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_LAST: - default: - virReportEnumRangeError(virDeviceHostdevPCIDriverName, - actual->data.hostdev.def.source.subsys= .u.pci.driver.name); - return NULL; - } - + port->plug.hostdevpci.driver.name =3D actual->data.hostdev.def.sou= rce.subsys.u.pci.driver.name; break; =20 case VIR_DOMAIN_NET_TYPE_CLIENT: diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 984ff564b2..d732e90b6d 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -56,13 +56,6 @@ VIR_ENUM_IMPL(virNetworkForwardHostdevDevice, "none", "pci", "netdev", ); =20 -VIR_ENUM_IMPL(virNetworkForwardDriverName, - VIR_NETWORK_FORWARD_DRIVER_NAME_LAST, - "default", - "kvm", - "vfio", -); - VIR_ENUM_IMPL(virNetworkTaint, VIR_NETWORK_TAINT_LAST, "hook-script", @@ -1358,9 +1351,9 @@ virNetworkForwardDefParseXML(const char *networkName, =20 if ((driverNode =3D virXPathNode("./driver", ctxt))) { if (virXMLPropEnum(driverNode, "name", - virNetworkForwardDriverNameTypeFromString, + virDeviceHostdevPCIDriverNameTypeFromString, VIR_XML_PROP_NONZERO, - &def->driverName) < 0) { + &def->driver.name) < 0) { return -1; } } @@ -2349,19 +2342,17 @@ virNetworkDefFormatBuf(virBuffer *buf, || VIR_SOCKET_ADDR_VALID(&def->forward.addr.end) || def->forward.port.start || def->forward.port.end - || (def->forward.driverName - !=3D VIR_NETWORK_FORWARD_DRIVER_NAME_DEFAULT) + || (def->forward.driver.name !=3D VIR_DEVICE_HOST= DEV_PCI_DRIVER_NAME_DEFAULT) || def->forward.natIPv6); virBufferAsprintf(buf, "%s>\n", shortforward ? "/" : ""); virBufferAdjustIndent(buf, 2); =20 - if (def->forward.driverName) { - const char *driverName - =3D virNetworkForwardDriverNameTypeToString(def->forward.d= riverName); + if (def->forward.driver.name) { + const char *driverName =3D virDeviceHostdevPCIDriverNameTypeTo= String(def->forward.driver.name); if (!driverName) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected hostdev driver name type %1$d= "), - def->forward.driverName); + _("unexpected hostdev driver name %1$d "), + def->forward.driver.name); return -1; } virBufferAsprintf(&driverAttrBuf, " name=3D'%s'", driverName); diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h index 497ae765f2..1d7fd3ab6a 100644 --- a/src/conf/network_conf.h +++ b/src/conf/network_conf.h @@ -24,6 +24,7 @@ #define DNS_RECORD_LENGTH_SRV (512 - 30) /* Limit minus overhead as ment= ioned in RFC-2782 */ =20 #include "internal.h" +#include "virconftypes.h" #include "virsocketaddr.h" #include "virnetdevbandwidth.h" #include "virnetdevvportprofile.h" @@ -88,20 +89,6 @@ typedef enum { =20 VIR_ENUM_DECL(virNetworkDHCPLeaseTimeUnit); =20 -/* The backend driver used for devices from the pool. Currently used - * only for PCI devices (vfio vs. kvm), but could be used for other - * device types in the future. - */ -typedef enum { - VIR_NETWORK_FORWARD_DRIVER_NAME_DEFAULT, /* kvm now, could change */ - VIR_NETWORK_FORWARD_DRIVER_NAME_KVM, /* force legacy kvm style */ - VIR_NETWORK_FORWARD_DRIVER_NAME_VFIO, /* force vfio */ - - VIR_NETWORK_FORWARD_DRIVER_NAME_LAST -} virNetworkForwardDriverNameType; - -VIR_ENUM_DECL(virNetworkForwardDriverName); - typedef struct _virNetworkDHCPLeaseTimeDef virNetworkDHCPLeaseTimeDef; struct _virNetworkDHCPLeaseTimeDef { unsigned long long expiry; @@ -216,7 +203,7 @@ typedef struct _virNetworkForwardDef virNetworkForwardD= ef; struct _virNetworkForwardDef { int type; /* One of virNetworkForwardType constants */ bool managed; /* managed attribute for hostdev mode */ - virNetworkForwardDriverNameType driverName; + virDeviceHostdevPCIDriverInfo driver; =20 /* If there are multiple forward devices (i.e. a pool of * interfaces), they will be listed here. diff --git a/src/conf/virnetworkportdef.c b/src/conf/virnetworkportdef.c index ac17313f83..c7902f0174 100644 --- a/src/conf/virnetworkportdef.c +++ b/src/conf/virnetworkportdef.c @@ -226,9 +226,9 @@ virNetworkPortDefParseXML(xmlXPathContextPtr ctxt) =20 if ((driverNode =3D virXPathNode("./plug/driver", ctxt))) { if (virXMLPropEnum(driverNode, "name", - virNetworkForwardDriverNameTypeFromString, + virDeviceHostdevPCIDriverNameTypeFromString, VIR_XML_PROP_NONZERO, - &def->plug.hostdevpci.driver) < 0) { + &def->plug.hostdevpci.driver.name) < 0) { return NULL; } } @@ -356,9 +356,9 @@ virNetworkPortDefFormatBuf(virBuffer *buf, virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); =20 - if (def->plug.hostdevpci.driver) { + if (def->plug.hostdevpci.driver.name) { virBufferEscapeString(&driverAttrBuf, " name=3D'%s'", - virNetworkForwardDriverNameTypeToStr= ing(def->plug.hostdevpci.driver)); + virDeviceHostdevPCIDriverNameTypeToS= tring(def->plug.hostdevpci.driver.name)); } =20 virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL); diff --git a/src/conf/virnetworkportdef.h b/src/conf/virnetworkportdef.h index bfe1dae9ea..9e51ab1a8b 100644 --- a/src/conf/virnetworkportdef.h +++ b/src/conf/virnetworkportdef.h @@ -22,6 +22,8 @@ #pragma once =20 #include "internal.h" +#include "virconftypes.h" +#include "device_conf.h" #include "virnetdevvlan.h" #include "virnetdevvportprofile.h" #include "virnetdevbandwidth.h" @@ -69,7 +71,7 @@ struct _virNetworkPortDef { } direct; struct { virPCIDeviceAddress addr; /* PCI Address of device */ - unsigned int driver; /* virNetworkForwardDriverNameType */ + virDeviceHostdevPCIDriverInfo driver; virTristateBool managed; } hostdevpci; } plug; diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 4be740de2c..d156333626 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -3930,7 +3930,7 @@ networkAllocatePort(virNetworkObj *obj, return -1; } port->plug.hostdevpci.addr =3D dev->device.pci; - port->plug.hostdevpci.driver =3D netdef->forward.driverName; + port->plug.hostdevpci.driver.name =3D netdef->forward.driver.name; port->plug.hostdevpci.managed =3D virTristateBoolFromBool(netdef->= forward.managed); =20 if (port->virtPortProfile) { --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Thu May 9 08:52:40 2024 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 1704443149969306.23277663649264; Fri, 5 Jan 2024 00:25:49 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id D9BB61891; Fri, 5 Jan 2024 03:25:48 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id E19B218C9; Fri, 5 Jan 2024 03:20:40 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 2D75D184D; Fri, 5 Jan 2024 03:20:24 -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 46D7B180C for ; Fri, 5 Jan 2024 03:20:20 -0500 (EST) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-685-al0MItJqP1SKGLj50iX4Tg-1; Fri, 05 Jan 2024 03:20:18 -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 65F24280640E 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 495802026D6F; 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: al0MItJqP1SKGLj50iX4Tg-1 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH v3 07/13] conf: split out hostdev parse/format to their own functions Date: Fri, 5 Jan 2024 03:20:10 -0500 Message-ID: <20240105082016.281442-8-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: 3IERAR4PUQIQAGLL2FF7UW7BPXJHV4OQ X-Message-ID-Hash: 3IERAR4PUQIQAGLL2FF7UW7BPXJHV4OQ 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: 1704443150610100001 This is done so that we can re-use the same parser/formatter for and Signed-off-by: Laine Stump Reviewed-by: Peter Krempa --- src/conf/device_conf.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/conf/device_conf.h | 7 +++++++ src/conf/domain_conf.c | 27 +++++---------------------- 3 files changed, 52 insertions(+), 22 deletions(-) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index a80b901214..68a8c7690a 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -55,6 +55,46 @@ VIR_ENUM_IMPL(virDomainDeviceAddress, "unassigned", ); =20 + +int +virDeviceHostdevPCIDriverInfoParseXML(xmlNodePtr node, + virDeviceHostdevPCIDriverInfo *drive= r) +{ + if (virXMLPropEnum(node, "name", + virDeviceHostdevPCIDriverNameTypeFromString, + VIR_XML_PROP_NONZERO, + &driver->name) < 0) { + return -1; + } + + return 0; +} + + +int +virDeviceHostdevPCIDriverInfoFormat(virBuffer *buf, + const virDeviceHostdevPCIDriverInfo *d= river) +{ + g_auto(virBuffer) driverAttrBuf =3D VIR_BUFFER_INITIALIZER; + + if (driver->name !=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT) { + const char *driverName =3D virDeviceHostdevPCIDriverNameTypeToStri= ng(driver->name); + + if (!driverName) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected pci hostdev driver name %1$d"), + driver->name); + return -1; + } + + virBufferAsprintf(&driverAttrBuf, " name=3D'%s'", driverName); + } + + virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL); + return 0; +} + + static int virZPCIDeviceAddressParseXML(xmlNodePtr node, virPCIDeviceAddress *addr) diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index 1f7e066142..0b3f17a3aa 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -25,6 +25,7 @@ #include =20 #include "internal.h" +#include "virconftypes.h" #include "virbuffer.h" #include "virccw.h" #include "virpci.h" @@ -185,6 +186,12 @@ struct _virDomainDeviceInfo { bool isolationGroupLocked; }; =20 +int virDeviceHostdevPCIDriverInfoParseXML(xmlNodePtr node, + virDeviceHostdevPCIDriverInfo *d= river); + +int virDeviceHostdevPCIDriverInfoFormat(virBuffer *buf, + const virDeviceHostdevPCIDriverInf= o *driver); + void virDomainDeviceInfoClear(virDomainDeviceInfo *info); void virDomainDeviceInfoFree(virDomainDeviceInfo *info); =20 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e19a2817c4..b3c7b50f97 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6281,13 +6281,9 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, if (virDomainHostdevSubsysPCIDefParseXML(sourcenode, ctxt, def, fl= ags) < 0) return -1; =20 - if ((driver_node =3D virXPathNode("./driver", ctxt))) { - if (virXMLPropEnum(driver_node, "name", - virDeviceHostdevPCIDriverNameTypeFromString, - VIR_XML_PROP_NONZERO, - &pcisrc->driver.name) < 0) { - return -1; - } + if ((driver_node =3D virXPathNode("./driver", ctxt)) && + virDeviceHostdevPCIDriverInfoParseXML(driver_node, &pcisrc->dr= iver) < 0) { + return -1; } break; =20 @@ -23373,25 +23369,12 @@ virDomainHostdevDefFormatSubsysPCI(virBuffer *buf, unsigned int flags, bool includeTypeInAddr) { - g_auto(virBuffer) driverAttrBuf =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) sourceAttrBuf =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) sourceChildBuf =3D VIR_BUFFER_INIT_CHILD(buf); virDomainHostdevSubsysPCI *pcisrc =3D &def->source.subsys.u.pci; =20 - if (pcisrc->driver.name !=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAUL= T) { - const char *driverName =3D virDeviceHostdevPCIDriverNameTypeToStri= ng(pcisrc->driver.name); - - if (!driverName) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected pci hostdev driver type %1$d"), - pcisrc->driver.name); - return -1; - } - - virBufferAsprintf(&driverAttrBuf, " name=3D'%s'", driverName); - } - - virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL); + if (virDeviceHostdevPCIDriverInfoFormat(buf, &pcisrc->driver) < 0) + return -1; =20 if (def->writeFiltering !=3D VIR_TRISTATE_BOOL_ABSENT) virBufferAsprintf(&sourceAttrBuf, " writeFiltering=3D'%s'", --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Thu May 9 08:52:40 2024 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 1704443562693120.08758290171443; Fri, 5 Jan 2024 00:32:42 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 9F40719CC; Fri, 5 Jan 2024 03:32:41 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 7B4C71855; Fri, 5 Jan 2024 03:20:59 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 7FC66180C; Fri, 5 Jan 2024 03:20:24 -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 525111810 for ; Fri, 5 Jan 2024 03:20:20 -0500 (EST) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-685-pTR2wIF9PZKRavW_crr5Xw-1; Fri, 05 Jan 2024 03:20:18 -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 8B3F3280640F 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 6F8302026D6F; 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: pTR2wIF9PZKRavW_crr5Xw-1 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH v3 08/13] conf: use new common parser/formatter for hostdev driver in network XML Date: Fri, 5 Jan 2024 03:20:11 -0500 Message-ID: <20240105082016.281442-9-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: 5MPM6LMYH4XCMIU5FIHRSSKBBYKKTRZQ X-Message-ID-Hash: 5MPM6LMYH4XCMIU5FIHRSSKBBYKKTRZQ 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: 1704443564244100001 Now if a new attribute is added to , we only need to update the formatting/parsing in one place. Signed-off-by: Laine Stump Reviewed-by: Peter Krempa --- src/conf/network_conf.c | 23 ++++------------------- src/conf/virnetworkportdef.c | 20 ++++++-------------- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index d732e90b6d..890c16b3b1 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -1349,13 +1349,9 @@ virNetworkForwardDefParseXML(const char *networkName, def->managed =3D true; } =20 - if ((driverNode =3D virXPathNode("./driver", ctxt))) { - if (virXMLPropEnum(driverNode, "name", - virDeviceHostdevPCIDriverNameTypeFromString, - VIR_XML_PROP_NONZERO, - &def->driver.name) < 0) { + if ((driverNode =3D virXPathNode("./driver", ctxt)) && + virDeviceHostdevPCIDriverInfoParseXML(driverNode, &def->driver) < = 0) { return -1; - } } =20 /* bridge and hostdev modes can use a pool of physical interfaces */ @@ -2317,7 +2313,6 @@ virNetworkDefFormatBuf(virBuffer *buf, if (def->forward.type !=3D VIR_NETWORK_FORWARD_NONE) { const char *dev =3D NULL; const char *mode =3D virNetworkForwardTypeToString(def->forward.ty= pe); - g_auto(virBuffer) driverAttrBuf =3D VIR_BUFFER_INITIALIZER; =20 if (!def->forward.npfs) dev =3D virNetworkDefForwardIf(def, 0); @@ -2347,18 +2342,8 @@ virNetworkDefFormatBuf(virBuffer *buf, virBufferAsprintf(buf, "%s>\n", shortforward ? "/" : ""); virBufferAdjustIndent(buf, 2); =20 - if (def->forward.driver.name) { - const char *driverName =3D virDeviceHostdevPCIDriverNameTypeTo= String(def->forward.driver.name); - if (!driverName) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected hostdev driver name %1$d "), - def->forward.driver.name); - return -1; - } - virBufferAsprintf(&driverAttrBuf, " name=3D'%s'", driverName); - } - - virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL); + if (virDeviceHostdevPCIDriverInfoFormat(buf, &def->forward.driver) = < 0) + return -1; =20 if (def->forward.type =3D=3D VIR_NETWORK_FORWARD_NAT) { if (virNetworkForwardNatDefFormat(buf, &def->forward) < 0) diff --git a/src/conf/virnetworkportdef.c b/src/conf/virnetworkportdef.c index c7902f0174..49d00b2ea6 100644 --- a/src/conf/virnetworkportdef.c +++ b/src/conf/virnetworkportdef.c @@ -224,13 +224,10 @@ virNetworkPortDefParseXML(xmlXPathContextPtr ctxt) &def->plug.hostdevpci.managed) < 0) return NULL; =20 - if ((driverNode =3D virXPathNode("./plug/driver", ctxt))) { - if (virXMLPropEnum(driverNode, "name", - virDeviceHostdevPCIDriverNameTypeFromString, - VIR_XML_PROP_NONZERO, - &def->plug.hostdevpci.driver.name) < 0) { - return NULL; - } + if ((driverNode =3D virXPathNode("./plug/driver", ctxt)) && + virDeviceHostdevPCIDriverInfoParseXML(driverNode, + &def->plug.hostdevpci.dr= iver) < 0) { + return NULL; } =20 if (!(addressNode =3D virXPathNode("./plug/address", ctxt))) { @@ -321,7 +318,6 @@ virNetworkPortDefFormatBuf(virBuffer *buf, virTristateBoolTypeToString(def->trustGuestRxFil= ters)); =20 if (def->plugtype !=3D VIR_NETWORK_PORT_PLUG_TYPE_NONE) { - g_auto(virBuffer) driverAttrBuf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAsprintf(buf, "plugtype)); @@ -356,12 +352,8 @@ virNetworkPortDefFormatBuf(virBuffer *buf, virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); =20 - if (def->plug.hostdevpci.driver.name) { - virBufferEscapeString(&driverAttrBuf, " name=3D'%s'", - virDeviceHostdevPCIDriverNameTypeToS= tring(def->plug.hostdevpci.driver.name)); - } - - virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL); + if (virDeviceHostdevPCIDriverInfoFormat(buf, &def->plug.hostde= vpci.driver) < 0) + return -1; =20 virPCIDeviceAddressFormat(buf, def->plug.hostdevpci.addr, fals= e); virBufferAdjustIndent(buf, -2); --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Thu May 9 08:52:40 2024 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 From nobody Thu May 9 08:52:40 2024 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 1704444563419655.9836214241619; Fri, 5 Jan 2024 00:49:23 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 4532E19B6; Fri, 5 Jan 2024 03:49:21 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 6914D1890; Fri, 5 Jan 2024 03:21:43 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id E9B5117FE; Fri, 5 Jan 2024 03:20:29 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 EEF911829 for ; Fri, 5 Jan 2024 03:20:20 -0500 (EST) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-520-w17edqRoMzKzmBRrjLn1ww-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 D72853C025B6 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 BB4D62026F95; 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_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: w17edqRoMzKzmBRrjLn1ww-1 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH v3 10/13] xen: explicitly set hostdev driver.name at runtime, not in postparse Date: Fri, 5 Jan 2024 03:20:13 -0500 Message-ID: <20240105082016.281442-11-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: XL4S4EWYQMCFFERAXXAYZW5TCI5FPO4G X-Message-ID-Hash: XL4S4EWYQMCFFERAXXAYZW5TCI5FPO4G 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: 1704444564933100001 Xen only supports a single type of PCI hostdev assignment, so it is superfluous to have peppered throughout the config. It *is* necessary to have the driver type explicitly set in the hostdev object before calling into the hypervisor-agnostic "hostdev manager" though (otherwise the hostdev manager doesn't know whether it should do Xen-specific setup, or VFIO-specific setup). Historically, the Xen driver has checked for "default" driver name (i.e. not set in the XML), and set it to "xen', during the XML postparse, thus guaranteeing that it will be set by the time the object is sent to the hostdev manager at runtime, but also setting it so early that a simple round-trip of parse-format results in the XML always containing an explicit , even if that wasn't specified in the original XML. The QEMU driver *doesn't* set driver.name during postparse though; instead, it waits until domain startup time (or device attach time for hotplug), and sets the driver.name then. The result is that a parse-format round trip of the XML in the QEMU driver *doesn't* add in the . This patch modifies the Xen driver to behave similarly to the QEMU driver - the PostParse just checks for a driver.name that isn't supported by the Xen driver, and any explicit setting to "xen" is deferred until domain runtime rather than during the postparse, thus Xen domain XML also doesn't get extraneous . This delayed setting of driver.name of course results in slightly different xml2xml parse-format results, so the unit test data is modified accordingly. Signed-off-by: Laine Stump Reviewed-by: Peter Krempa --- Change from V2: add note in source code that the default value set internally for driver name during libxlPrepareDevices should never change unless the new and old defaults are guest ABI compatible. (this will only have meaning if a 2nd type of device assignment for the Xen driver is ever introduced) src/libxl/libxl_domain.c | 73 ++++++++++++++++--- src/libxl/libxl_driver.c | 25 ++++--- tests/libxlxml2domconfigdata/moredevs-hvm.xml | 1 - tests/xlconfigdata/test-fullvirt-pci.xml | 2 - tests/xmconfigdata/test-pci-dev-syntax.xml | 2 - tests/xmconfigdata/test-pci-devs.xml | 2 - 6 files changed, 77 insertions(+), 28 deletions(-) diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 1a7de00704..670fd2881e 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -160,8 +160,15 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDef *dev, =20 if (hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_T= YPE_PCI && - pcisrc->driver.name =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_= DEFAULT) - pcisrc->driver.name =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN; + pcisrc->driver.name !=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DE= FAULT && + pcisrc->driver.name !=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XE= N) { + + /* Xen only supports "Xen" style of hostdev */ + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("XEN does not support device assignment mode = '%1$s'"), + virDeviceHostdevPCIDriverNameTypeToString(pcisr= c->driver.name)); + return -1; + } } =20 if (dev->type =3D=3D VIR_DOMAIN_DEVICE_VIDEO) { @@ -986,18 +993,9 @@ libxlNetworkPrepareDevices(virDomainDef *def) if (actualType =3D=3D VIR_DOMAIN_NET_TYPE_HOSTDEV && net->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { /* Each type=3D'hostdev' network device must also have a - * corresponding entry in the hostdevs array. For netdevs - * that are hardcoded as type=3D'hostdev', this is already - * done by the parser, but for those allocated from a - * network / determined at runtime, we need to do it - * separately. + * corresponding entry in the hostdevs array. */ virDomainHostdevDef *hostdev =3D virDomainNetGetActualHostdev(= net); - virDomainHostdevSubsysPCI *pcisrc =3D &hostdev->source.subsys.= u.pci; - - if (hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && - hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBS= YS_TYPE_PCI) - pcisrc->driver.name =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME= _XEN; =20 if (virDomainHostdevInsert(def, hostdev) < 0) return -1; @@ -1007,6 +1005,54 @@ libxlNetworkPrepareDevices(virDomainDef *def) return 0; } =20 + +static int +libxlHostdevPrepareDevices(virDomainDef *def) +{ + size_t i; + + for (i =3D 0; i < def->nhostdevs; i++) { + virDomainHostdevDef *hostdev =3D def->hostdevs[i]; + virDomainHostdevSubsysPCI *pcisrc =3D &hostdev->source.subsys.u.pc= i; + + if (hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && + hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_T= YPE_PCI && + pcisrc->driver.name =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_= DEFAULT) { + + + pcisrc->driver.name =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN; + + /* Q: Why do we set an explicit driver.name here even + * though Xen (currently) only supports one driver.name for + * PCI hostdev assignment? + * + * A: Setting the driver name *in the domain XML config* + * is optional (and actually pointless at the time of + * writing, since each hypervisor only supports a single + * type of PCI hostdev device assignment). But the + * hypervisor-agnostic virHostdevPrepareDomainDevices(), + * which is called immediately after this function in + * order to do any driver-related setup (e.g. bind the + * host device to a driver kernel driver), requires that + * the driver.name be explicitly set (otherwise it wouldn't + * know whether to bind to the Xen driver or VFIO driver, + * for example). + * + * NB: If there are ever multiple types of device + * assignment supported by Xen, DO NOT CHANGE the value of + * driver.name set above when the config is "default" to + * anything other than "xen", unless the guest ABI of the + * new type is compatible with that of current "xen" + * device assignment. + * + */ + } + } + + return 0; +} + + static void libxlConsoleCallback(libxl_ctx *ctx, libxl_event *ev, void *for_callback) { @@ -1174,6 +1220,9 @@ libxlDomainStartPrepare(libxlDriverPrivate *driver, if (libxlNetworkPrepareDevices(vm->def) < 0) goto error; =20 + if (libxlHostdevPrepareDevices(vm->def) < 0) + goto error; + if (virHostdevPrepareDomainDevices(hostdev_mgr, LIBXL_DRIVER_INTERNAL_= NAME, vm->def, hostdev_flags) < 0) goto error; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 29fbc823dd..6c843b9054 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -3087,6 +3087,22 @@ libxlDomainAttachHostPCIDevice(libxlDriverPrivate *d= river, =20 VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1); =20 + /* The only supported driverType for Xen is + * VIR_DOMAIN_HOSTDEV_PCI_DRIVER_TYPE_XEN, which normally isn't + * set in the config (because it doesn't need to be), but it does + * need to be set for the impending call to + * virHostdevPreparePCIDevices() + */ + if (pcisrc->driver.name =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFA= ULT) + pcisrc->driver.name =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN; + + if (pcisrc->driver.name !=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("XEN does not support device assignment mode '%1$= s'"), + virDeviceHostdevPCIDriverNameTypeToString(pcisrc->d= river.name)); + goto cleanup; + } + if (virHostdevPreparePCIDevices(hostdev_mgr, LIBXL_DRIVER_INTERNAL_NAM= E, vm->def->name, vm->def->uuid, &hostdev, 1, 0) < 0) @@ -3395,15 +3411,6 @@ libxlDomainAttachNetDevice(libxlDriverPrivate *drive= r, =20 if (actualType =3D=3D VIR_DOMAIN_NET_TYPE_HOSTDEV) { virDomainHostdevDef *hostdev =3D virDomainNetGetActualHostdev(net); - virDomainHostdevSubsysPCI *pcisrc =3D &hostdev->source.subsys.u.pc= i; - - /* For those just allocated from a network pool whose driver type = is - * still VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT, we need to set - * driver name correctly. - */ - if (hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && - hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_T= YPE_PCI) - pcisrc->driver.name =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN; =20 /* This is really a "smart hostdev", so it should be attached * as a hostdev (the hostdev code will reach over into the diff --git a/tests/libxlxml2domconfigdata/moredevs-hvm.xml b/tests/libxlxml= 2domconfigdata/moredevs-hvm.xml index 89ad80631d..64eeeff889 100644 --- a/tests/libxlxml2domconfigdata/moredevs-hvm.xml +++ b/tests/libxlxml2domconfigdata/moredevs-hvm.xml @@ -43,7 +43,6 @@ -
diff --git a/tests/xlconfigdata/test-fullvirt-pci.xml b/tests/xlconfigdata/= test-fullvirt-pci.xml index 75aa6ac25b..6826d14b9e 100644 --- a/tests/xlconfigdata/test-fullvirt-pci.xml +++ b/tests/xlconfigdata/test-fullvirt-pci.xml @@ -37,13 +37,11 @@ -
-
diff --git a/tests/xmconfigdata/test-pci-dev-syntax.xml b/tests/xmconfigdat= a/test-pci-dev-syntax.xml index 5d5d29c61c..1d5d857072 100644 --- a/tests/xmconfigdata/test-pci-dev-syntax.xml +++ b/tests/xmconfigdata/test-pci-dev-syntax.xml @@ -55,13 +55,11 @@ -
-
diff --git a/tests/xmconfigdata/test-pci-devs.xml b/tests/xmconfigdata/test= -pci-devs.xml index 5d5d29c61c..1d5d857072 100644 --- a/tests/xmconfigdata/test-pci-devs.xml +++ b/tests/xmconfigdata/test-pci-devs.xml @@ -55,13 +55,11 @@ -
-
--=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Thu May 9 08:52:40 2024 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 1704445682870873.4369617976336; Fri, 5 Jan 2024 01:08:02 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 875BC190A; Fri, 5 Jan 2024 04:08:01 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id D553A186B; Fri, 5 Jan 2024 03:22:42 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id A896D188E; Fri, 5 Jan 2024 03:20:37 -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 C8D3B182B for ; Fri, 5 Jan 2024 03:20:21 -0500 (EST) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-215-hObGcVelPSmPhYoP3thG0w-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 0FA213C29A6B for ; Fri, 5 Jan 2024 08:20:19 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.16.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id E1CC22026D6F; 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: hObGcVelPSmPhYoP3thG0w-1 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH v3 11/13] tests: remove explicit from hostdev test cases Date: Fri, 5 Jan 2024 03:20:14 -0500 Message-ID: <20240105082016.281442-12-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: 3ASEARNTDSGIH66TPW5YHHFIEFBFXWWP X-Message-ID-Hash: 3ASEARNTDSGIH66TPW5YHHFIEFBFXWWP 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: 1704445683549100001 The long-deprecated use of in domain xml for devices was only ever necessary during the period when libvirt (and the Linux kernel) supported both VFIO and "legacy KVM" styles of hostdev device assignment for QEMU. This became pointless many years ago when legacy KVM device assignment was removed from the kernel, and support for that style of device assignment was completely disabled in the libvirt source in 2019 (commit v5.6.0-316-g2e7225ea8c). Nevertheless, there were instances of in the unit test data that were then (unnecessarily) propagated to several more tests over the years. This patch cleans out those unnecessary explicit settings of driver name=3D'vfio' in all QEMU unit test data, proving that the attribute is no longer (externally) needed. (A later patch which adds a 2nd attribute to the element will include a test case that explicitly exercises the driver name attribute). Signed-off-by: Laine Stump Reviewed-by: Peter Krempa --- Change from V2: eliminated more occurences in test XML, made possible by moving the "replace virHostdevisVFIODevice ..." patch in front of this one. docs/formatdomain.rst | 1 - docs/formatnetwork.rst | 1 - docs/formatnetworkport.rst | 1 - docs/pci-addresses.rst | 1 - tests/networkxml2xmlin/hostdev-pf.xml | 1 - tests/networkxml2xmlout/hostdev-pf.xml | 1 - .../qemuhotplug-hostdev-pci.xml | 1 - .../qemumemlock-pc-hardlimit+hostdev.xml | 1 - ...emumemlock-pc-hardlimit+locked+hostdev.xml | 1 - .../qemumemlock-pc-hostdev-nvme.xml | 1 - .../qemumemlock-pc-hostdev.xml | 1 - .../qemumemlock-pc-locked+hostdev.xml | 1 - .../qemumemlock-pseries-hardlimit+hostdev.xml | 1 - ...mlock-pseries-hardlimit+locked+hostdev.xml | 1 - .../qemumemlock-pseries-hostdev.xml | 1 - .../qemumemlock-pseries-locked+hostdev.xml | 1 - tests/qemustatusxml2xmldata/modern-in.xml | 1 - .../hostdev-pci-address-unassigned.xml | 4 -- .../hostdev-pci-multifunction.xml | 7 --- .../hostdev-vfio-multidomain.xml | 1 - .../hostdev-vfio-zpci-autogenerate-fids.xml | 2 - .../hostdev-vfio-zpci-autogenerate-uids.xml | 2 - .../hostdev-vfio-zpci-autogenerate.xml | 1 - .../hostdev-vfio-zpci-boundaries.xml | 2 - .../hostdev-vfio-zpci-ccw-memballoon.xml | 1 - .../hostdev-vfio-zpci-duplicate.xml | 2 - ...ostdev-vfio-zpci-invalid-uid-valid-fid.xml | 1 - .../hostdev-vfio-zpci-multidomain-many.xml | 8 ---- .../hostdev-vfio-zpci-set-zero.xml | 1 - .../hostdev-vfio-zpci-uid-set-zero.xml | 1 - .../hostdev-vfio-zpci-wrong-arch.xml | 1 - tests/qemuxml2argvdata/hostdev-vfio-zpci.xml | 1 - tests/qemuxml2argvdata/hostdev-vfio.xml | 1 - .../net-hostdev-vfio-multidomain.xml | 1 - tests/qemuxml2argvdata/net-hostdev-vfio.xml | 1 - tests/qemuxml2argvdata/pseries-hostdevs-1.xml | 3 -- tests/qemuxml2argvdata/pseries-hostdevs-2.xml | 2 - tests/qemuxml2argvdata/pseries-hostdevs-3.xml | 2 - ...v-pci-address-unassigned.x86_64-latest.xml | 4 -- ...ostdev-pci-multifunction.x86_64-latest.xml | 7 --- ...dev-vfio-old-driver-name.x86_64-latest.xml | 46 +++++++++++++++++++ ...io-zpci-autogenerate-fids.s390x-latest.xml | 2 - ...io-zpci-autogenerate-uids.s390x-latest.xml | 2 - ...ev-vfio-zpci-autogenerate.s390x-latest.xml | 1 - ...tdev-vfio-zpci-boundaries.s390x-latest.xml | 2 - ...-vfio-zpci-ccw-memballoon.s390x-latest.xml | 1 - ...fio-zpci-multidomain-many.s390x-latest.xml | 8 ---- .../hostdev-vfio-zpci.s390x-latest.xml | 1 - .../hostdev-vfio.x86_64-latest.xml | 1 - .../net-hostdev-vfio.x86_64-latest.xml | 1 - .../pseries-hostdevs-1.ppc64-latest.xml | 3 -- .../pseries-hostdevs-2.ppc64-latest.xml | 2 - .../pseries-hostdevs-3.ppc64-latest.xml | 2 - 53 files changed, 46 insertions(+), 99 deletions(-) create mode 100644 tests/qemuxml2xmloutdata/hostdev-vfio-old-driver-name.x= 86_64-latest.xml diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 310d2bc427..c08033f940 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -5224,7 +5224,6 @@ or stopping the guest. ... -
diff --git a/docs/formatnetwork.rst b/docs/formatnetwork.rst index c54d53070a..5d300a035e 100644 --- a/docs/formatnetwork.rst +++ b/docs/formatnetwork.rst @@ -392,7 +392,6 @@ to the physical LAN (if at all). =20 ... -
diff --git a/docs/formatnetworkport.rst b/docs/formatnetworkport.rst index 40a4f0e85b..e60445b3b4 100644 --- a/docs/formatnetworkport.rst +++ b/docs/formatnetworkport.rst @@ -163,7 +163,6 @@ rather than emulation. =20 ... -
... diff --git a/docs/pci-addresses.rst b/docs/pci-addresses.rst index eb4945f169..bfc0bbccc3 100644 --- a/docs/pci-addresses.rst +++ b/docs/pci-addresses.rst @@ -223,7 +223,6 @@ For example, the domain XML snippet :: =20 -
diff --git a/tests/networkxml2xmlin/hostdev-pf.xml b/tests/networkxml2xmlin= /hostdev-pf.xml index 5b8f59858c..7bf857d3a1 100644 --- a/tests/networkxml2xmlin/hostdev-pf.xml +++ b/tests/networkxml2xmlin/hostdev-pf.xml @@ -2,7 +2,6 @@ hostdev 81ff0d90-c91e-6742-64da-4a736edb9a9b - diff --git a/tests/networkxml2xmlout/hostdev-pf.xml b/tests/networkxml2xmlo= ut/hostdev-pf.xml index 5b8f59858c..7bf857d3a1 100644 --- a/tests/networkxml2xmlout/hostdev-pf.xml +++ b/tests/networkxml2xmlout/hostdev-pf.xml @@ -2,7 +2,6 @@ hostdev 81ff0d90-c91e-6742-64da-4a736edb9a9b - diff --git a/tests/qemuhotplugtestdevices/qemuhotplug-hostdev-pci.xml b/tes= ts/qemuhotplugtestdevices/qemuhotplug-hostdev-pci.xml index 6f7c99c943..0d6dec9d26 100644 --- a/tests/qemuhotplugtestdevices/qemuhotplug-hostdev-pci.xml +++ b/tests/qemuhotplugtestdevices/qemuhotplug-hostdev-pci.xml @@ -1,5 +1,4 @@ -
diff --git a/tests/qemumemlockdata/qemumemlock-pc-hardlimit+hostdev.xml b/t= ests/qemumemlockdata/qemumemlock-pc-hardlimit+hostdev.xml index e03f5a585d..18bafaa355 100644 --- a/tests/qemumemlockdata/qemumemlock-pc-hardlimit+hostdev.xml +++ b/tests/qemumemlockdata/qemumemlock-pc-hardlimit+hostdev.xml @@ -11,7 +11,6 @@ /usr/bin/qemu-system-x86_64 -
diff --git a/tests/qemumemlockdata/qemumemlock-pc-hardlimit+locked+hostdev.= xml b/tests/qemumemlockdata/qemumemlock-pc-hardlimit+locked+hostdev.xml index 7070e5a12c..34a3960e8b 100644 --- a/tests/qemumemlockdata/qemumemlock-pc-hardlimit+locked+hostdev.xml +++ b/tests/qemumemlockdata/qemumemlock-pc-hardlimit+locked+hostdev.xml @@ -14,7 +14,6 @@ /usr/bin/qemu-system-x86_64 -
diff --git a/tests/qemumemlockdata/qemumemlock-pc-hostdev-nvme.xml b/tests/= qemumemlockdata/qemumemlock-pc-hostdev-nvme.xml index 06f1496970..ac20d2b3a0 100644 --- a/tests/qemumemlockdata/qemumemlock-pc-hostdev-nvme.xml +++ b/tests/qemumemlockdata/qemumemlock-pc-hostdev-nvme.xml @@ -15,7 +15,6 @@ -
diff --git a/tests/qemumemlockdata/qemumemlock-pc-hostdev.xml b/tests/qemum= emlockdata/qemumemlock-pc-hostdev.xml index cd517ee226..cc8b6b00ab 100644 --- a/tests/qemumemlockdata/qemumemlock-pc-hostdev.xml +++ b/tests/qemumemlockdata/qemumemlock-pc-hostdev.xml @@ -8,7 +8,6 @@ /usr/bin/qemu-system-x86_64 -
diff --git a/tests/qemumemlockdata/qemumemlock-pc-locked+hostdev.xml b/test= s/qemumemlockdata/qemumemlock-pc-locked+hostdev.xml index da79cb5277..3cbe4a17b3 100644 --- a/tests/qemumemlockdata/qemumemlock-pc-locked+hostdev.xml +++ b/tests/qemumemlockdata/qemumemlock-pc-locked+hostdev.xml @@ -11,7 +11,6 @@ /usr/bin/qemu-system-x86_64 -
diff --git a/tests/qemumemlockdata/qemumemlock-pseries-hardlimit+hostdev.xm= l b/tests/qemumemlockdata/qemumemlock-pseries-hardlimit+hostdev.xml index baf0649db7..b9c2aefc28 100644 --- a/tests/qemumemlockdata/qemumemlock-pseries-hardlimit+hostdev.xml +++ b/tests/qemumemlockdata/qemumemlock-pseries-hardlimit+hostdev.xml @@ -11,7 +11,6 @@ /usr/bin/qemu-system-ppc64 -
diff --git a/tests/qemumemlockdata/qemumemlock-pseries-hardlimit+locked+hos= tdev.xml b/tests/qemumemlockdata/qemumemlock-pseries-hardlimit+locked+hostd= ev.xml index 04ae4e93bf..731d4a5392 100644 --- a/tests/qemumemlockdata/qemumemlock-pseries-hardlimit+locked+hostdev.xml +++ b/tests/qemumemlockdata/qemumemlock-pseries-hardlimit+locked+hostdev.xml @@ -14,7 +14,6 @@ /usr/bin/qemu-system-ppc64 -
diff --git a/tests/qemumemlockdata/qemumemlock-pseries-hostdev.xml b/tests/= qemumemlockdata/qemumemlock-pseries-hostdev.xml index a52768cb31..3d016928af 100644 --- a/tests/qemumemlockdata/qemumemlock-pseries-hostdev.xml +++ b/tests/qemumemlockdata/qemumemlock-pseries-hostdev.xml @@ -8,7 +8,6 @@ /usr/bin/qemu-system-ppc64 -
diff --git a/tests/qemumemlockdata/qemumemlock-pseries-locked+hostdev.xml b= /tests/qemumemlockdata/qemumemlock-pseries-locked+hostdev.xml index f5abef0b06..b942fa4834 100644 --- a/tests/qemumemlockdata/qemumemlock-pseries-locked+hostdev.xml +++ b/tests/qemumemlockdata/qemumemlock-pseries-locked+hostdev.xml @@ -11,7 +11,6 @@ /usr/bin/qemu-system-ppc64 -
diff --git a/tests/qemustatusxml2xmldata/modern-in.xml b/tests/qemustatusxm= l2xmldata/modern-in.xml index 67e0aa4952..f0f5df84ab 100644 --- a/tests/qemustatusxml2xmldata/modern-in.xml +++ b/tests/qemustatusxml2xmldata/modern-in.xml @@ -502,7 +502,6 @@
-
diff --git a/tests/qemuxml2argvdata/hostdev-pci-address-unassigned.xml b/te= sts/qemuxml2argvdata/hostdev-pci-address-unassigned.xml index 9a2685ca0e..864ef303c0 100644 --- a/tests/qemuxml2argvdata/hostdev-pci-address-unassigned.xml +++ b/tests/qemuxml2argvdata/hostdev-pci-address-unassigned.xml @@ -14,26 +14,22 @@ -
-
-
-
diff --git a/tests/qemuxml2argvdata/hostdev-pci-multifunction.xml b/tests/q= emuxml2argvdata/hostdev-pci-multifunction.xml index 06c889c64d..ba0a593628 100644 --- a/tests/qemuxml2argvdata/hostdev-pci-multifunction.xml +++ b/tests/qemuxml2argvdata/hostdev-pci-multifunction.xml @@ -14,43 +14,36 @@ -
-
-
-
-
-
-
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-multidomain.xml b/tests/qe= muxml2argvdata/hostdev-vfio-multidomain.xml index b720883913..7afe18b24e 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio-multidomain.xml +++ b/tests/qemuxml2argvdata/hostdev-vfio-multidomain.xml @@ -23,7 +23,6 @@ -
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-zpci-autogenerate-fids.xml= b/tests/qemuxml2argvdata/hostdev-vfio-zpci-autogenerate-fids.xml index 49c26e2434..e72c524a98 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio-zpci-autogenerate-fids.xml +++ b/tests/qemuxml2argvdata/hostdev-vfio-zpci-autogenerate-fids.xml @@ -8,7 +8,6 @@ /usr/bin/qemu-system-s390x -
@@ -17,7 +16,6 @@
-
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-zpci-autogenerate-uids.xml= b/tests/qemuxml2argvdata/hostdev-vfio-zpci-autogenerate-uids.xml index e74e0116c7..1ed75aae48 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio-zpci-autogenerate-uids.xml +++ b/tests/qemuxml2argvdata/hostdev-vfio-zpci-autogenerate-uids.xml @@ -8,7 +8,6 @@ /usr/bin/qemu-system-s390x -
@@ -17,7 +16,6 @@
-
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-zpci-autogenerate.xml b/te= sts/qemuxml2argvdata/hostdev-vfio-zpci-autogenerate.xml index 36161006ab..b4b1ce315f 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio-zpci-autogenerate.xml +++ b/tests/qemuxml2argvdata/hostdev-vfio-zpci-autogenerate.xml @@ -8,7 +8,6 @@ /usr/bin/qemu-system-s390x -
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-zpci-boundaries.xml b/test= s/qemuxml2argvdata/hostdev-vfio-zpci-boundaries.xml index 1e6060345b..fe005af488 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio-zpci-boundaries.xml +++ b/tests/qemuxml2argvdata/hostdev-vfio-zpci-boundaries.xml @@ -9,7 +9,6 @@ /usr/bin/qemu-system-s390x -
@@ -18,7 +17,6 @@
-
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-zpci-ccw-memballoon.xml b/= tests/qemuxml2argvdata/hostdev-vfio-zpci-ccw-memballoon.xml index ef5e97fc9c..bb6861f103 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio-zpci-ccw-memballoon.xml +++ b/tests/qemuxml2argvdata/hostdev-vfio-zpci-ccw-memballoon.xml @@ -8,7 +8,6 @@ /usr/bin/qemu-system-s390x -
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-zpci-duplicate.xml b/tests= /qemuxml2argvdata/hostdev-vfio-zpci-duplicate.xml index 6062ae4940..53cf48ea6a 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio-zpci-duplicate.xml +++ b/tests/qemuxml2argvdata/hostdev-vfio-zpci-duplicate.xml @@ -9,7 +9,6 @@ /usr/bin/qemu-system-s390x -
@@ -18,7 +17,6 @@
-
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-zpci-invalid-uid-valid-fid= .xml b/tests/qemuxml2argvdata/hostdev-vfio-zpci-invalid-uid-valid-fid.xml index 6e7101489e..1026661730 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio-zpci-invalid-uid-valid-fid.xml +++ b/tests/qemuxml2argvdata/hostdev-vfio-zpci-invalid-uid-valid-fid.xml @@ -9,7 +9,6 @@ /usr/bin/qemu-system-s390x -
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-zpci-multidomain-many.xml = b/tests/qemuxml2argvdata/hostdev-vfio-zpci-multidomain-many.xml index da8305dd6d..36c11a8311 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio-zpci-multidomain-many.xml +++ b/tests/qemuxml2argvdata/hostdev-vfio-zpci-multidomain-many.xml @@ -9,7 +9,6 @@ /usr/bin/qemu-system-s390x -
@@ -18,7 +17,6 @@
-
@@ -27,20 +25,17 @@
-
-
-
@@ -49,7 +44,6 @@
-
@@ -58,7 +52,6 @@
-
@@ -67,7 +60,6 @@
-
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-zpci-set-zero.xml b/tests/= qemuxml2argvdata/hostdev-vfio-zpci-set-zero.xml index fd3d1193f1..eefe05de39 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio-zpci-set-zero.xml +++ b/tests/qemuxml2argvdata/hostdev-vfio-zpci-set-zero.xml @@ -9,7 +9,6 @@ /usr/bin/qemu-system-s390x -
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-zpci-uid-set-zero.xml b/te= sts/qemuxml2argvdata/hostdev-vfio-zpci-uid-set-zero.xml index 6bfbfe611b..fb0e680b55 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio-zpci-uid-set-zero.xml +++ b/tests/qemuxml2argvdata/hostdev-vfio-zpci-uid-set-zero.xml @@ -8,7 +8,6 @@ /usr/bin/qemu-system-s390x -
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-zpci-wrong-arch.xml b/test= s/qemuxml2argvdata/hostdev-vfio-zpci-wrong-arch.xml index a9a5afd6dd..8b3cc45ddf 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio-zpci-wrong-arch.xml +++ b/tests/qemuxml2argvdata/hostdev-vfio-zpci-wrong-arch.xml @@ -21,7 +21,6 @@ -
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-zpci.xml b/tests/qemuxml2a= rgvdata/hostdev-vfio-zpci.xml index 002b99c52d..5f439eff73 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio-zpci.xml +++ b/tests/qemuxml2argvdata/hostdev-vfio-zpci.xml @@ -9,7 +9,6 @@ /usr/bin/qemu-system-s390x -
diff --git a/tests/qemuxml2argvdata/hostdev-vfio.xml b/tests/qemuxml2argvda= ta/hostdev-vfio.xml index 1b438a2eef..a03870f6e0 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio.xml +++ b/tests/qemuxml2argvdata/hostdev-vfio.xml @@ -25,7 +25,6 @@ -
diff --git a/tests/qemuxml2argvdata/net-hostdev-vfio-multidomain.xml b/test= s/qemuxml2argvdata/net-hostdev-vfio-multidomain.xml index ae8c4e7e80..cdadf4f2cb 100644 --- a/tests/qemuxml2argvdata/net-hostdev-vfio-multidomain.xml +++ b/tests/qemuxml2argvdata/net-hostdev-vfio-multidomain.xml @@ -24,7 +24,6 @@ -
diff --git a/tests/qemuxml2argvdata/net-hostdev-vfio.xml b/tests/qemuxml2ar= gvdata/net-hostdev-vfio.xml index e6e6b6e5d3..9cdb8a602d 100644 --- a/tests/qemuxml2argvdata/net-hostdev-vfio.xml +++ b/tests/qemuxml2argvdata/net-hostdev-vfio.xml @@ -24,7 +24,6 @@ -
diff --git a/tests/qemuxml2argvdata/pseries-hostdevs-1.xml b/tests/qemuxml2= argvdata/pseries-hostdevs-1.xml index 04f3ec4759..5d09413a98 100644 --- a/tests/qemuxml2argvdata/pseries-hostdevs-1.xml +++ b/tests/qemuxml2argvdata/pseries-hostdevs-1.xml @@ -11,7 +11,6 @@ -
@@ -19,7 +18,6 @@ -
@@ -28,7 +26,6 @@ -
diff --git a/tests/qemuxml2argvdata/pseries-hostdevs-2.xml b/tests/qemuxml2= argvdata/pseries-hostdevs-2.xml index 6568475c72..00d4228499 100644 --- a/tests/qemuxml2argvdata/pseries-hostdevs-2.xml +++ b/tests/qemuxml2argvdata/pseries-hostdevs-2.xml @@ -17,7 +17,6 @@ despite being in the separate isolation group 1 (IOMMU group 0), because the address has been requested explicitly by the user --> -
@@ -26,7 +25,6 @@ -
diff --git a/tests/qemuxml2argvdata/pseries-hostdevs-3.xml b/tests/qemuxml2= argvdata/pseries-hostdevs-3.xml index 4f51f48c90..64ba95ca30 100644 --- a/tests/qemuxml2argvdata/pseries-hostdevs-3.xml +++ b/tests/qemuxml2argvdata/pseries-hostdevs-3.xml @@ -11,7 +11,6 @@ -
diff --git a/tests/qemuxml2xmloutdata/hostdev-pci-address-unassigned.x86_64= -latest.xml b/tests/qemuxml2xmloutdata/hostdev-pci-address-unassigned.x86_6= 4-latest.xml index 480d2f8363..9da9a8a07e 100644 --- a/tests/qemuxml2xmloutdata/hostdev-pci-address-unassigned.x86_64-latest= .xml +++ b/tests/qemuxml2xmloutdata/hostdev-pci-address-unassigned.x86_64-latest= .xml @@ -28,28 +28,24 @@