From nobody Fri May 10 18:54:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1698036902; cv=none; d=zohomail.com; s=zohoarc; b=Js+DGa4+otg7TC1tyYYWwG+wHepOG+q5E+a/iKCekz4iZi/WjitM2vGQ9B/VmIHc4JAkl9cUqS6FswRF9dXE/2IJEO4Qi9kQT9Pzv9u8Vq4I6HvX+Jym/tUAjVuYoimaGvuh4C3xY9GjtSK0jK2YM1pM/TV5wlfASGpCJBhYX5w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698036902; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CjT2xpegkwBVRr+9NsBn/oF4pkHlm8eA1EA3cMAZcqo=; b=j6smQAWYFLyQIoL4u7GHFugMtvbIwhS4QSPSMpdjxloQuyGw/EU0vkFV9NGZxzaLfcxp0ILtruHKHs8dk+BrDuZk2FiVUY/Vo69vUd8ZRK7IdMXebwd3ar7aFVDJaq3L+8sDO5uB2cAquT8JAMPDJQWHlzc1i1RLtoi4QXKqcnU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 169803690267118.973950766008898; Sun, 22 Oct 2023 21:55:02 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-599-u-aAlHPrMaqOJjRFtKT5YA-1; Mon, 23 Oct 2023 00:54:58 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 65E0F87AA09; Mon, 23 Oct 2023 04:54:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 056A325C3; Mon, 23 Oct 2023 04:54:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AB39A19466EA; Mon, 23 Oct 2023 04:54:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 709BD1946587 for ; Mon, 23 Oct 2023 04:54:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4C4ECC15978; Mon, 23 Oct 2023 04:54:52 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.8.125]) by smtp.corp.redhat.com (Postfix) with ESMTP id 147E8C1596D; Mon, 23 Oct 2023 04:54:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698036901; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=CjT2xpegkwBVRr+9NsBn/oF4pkHlm8eA1EA3cMAZcqo=; b=aOOsdLERJA1Xvs18E1NjYGMMgExH4RQh3dGMjinatg04do9/boZWez5VcRfp3q3N2beKwU 8f2CzSmBuMjFScZjKkefoeubgavszMg+LFGZ8HW/VyUw4YxkeoibdWgozf8QlEw3SxUIDk iHIi88T/8oqLK5nI1dGvMJv1+wzPIA8= X-MC-Unique: u-aAlHPrMaqOJjRFtKT5YA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 01/15] util: properly deal with module vs. driver when binding device to driver Date: Mon, 23 Oct 2023 00:54:37 -0400 Message-ID: <20231023045451.210711-2-laine@redhat.com> In-Reply-To: <20231023045451.210711-1-laine@redhat.com> References: <20231023045451.210711-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joao Martins , Cedric Le Goater , Jason Gunthorpe Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1698036903403100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Historically libvirt has treated the concept of "loadable kernel module" and "device driver" as being effectively the same (at least in the case of the vfio-pci driver used for VFIO device assignment). The code assumed that a module named "vfio-pci" implemented a driver named "vfio-pci". In reality, the module is named "vfio_pci", and it implements a device driver named "vfio-pci" (note the difference in separator characters), and our code worked only because the modprobe utility we use to load the module will always "normalize" the module name it's given by replacing all "-" (dash) with "_" (underscore) (this has been verified in the modprobe source, which is in the kmod package - there are 3 separate functions that perform this same operation!). So even though we asked modprobe to load the "vfio-pci" module, it would actually load the "vfio_pci" module. After loading the module with modprobe, libvirt then looks for the desired *driver* to be present in sysfs, by looking for the directory /sys/bus/pci/drivers/${driverName}, which would succeed because we were still looking for the original "dash version" of the name ("vfio-pci"). When we recently gained the ability to manually specify a driver to bind to with virsh nodedev-detach, the fragility of this system became apparent - if a user gives the driver name as "vfio_pci", then we would modprobe the module, 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, this could be dealt with by telling the user "always use the correct name for the driver, don't assume that it is the same as the modulename", 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). More more importantly, when we begin looking in the modules.alias file for the "best" VFIO variant driver for a particular device (in an upcoming patch), that lookup will provide us with the name of a *module*, not a driver, and 3 of the 4 examples of vfio-pci/variant drivers I have access to use underscore in the module name and dash in the driver, while the 4th uses underscore in both, so 3 out of 4 fail with the current code. To make the current code more forgiving (and yet more correct!), as well as to make the upcoming variant auto-selection actually useful, this patch follows the following steps: 1) if the requested driver (${driverName}) is present in sysfs drivers list (/sys/bus/pci/drivers/${driverName}) then use ${driverName} - DONE 2) if underscored(${driverName}) (call it ${underName} for short) is in sysfs drivers list then use ${underName} - DONE 3) if ${underName} *isn't* in the sysfs modules list (/sys/module/${underName}) then "modprobe ${underName}" to load it. 4) look for the PCI driver implemented by this module, it will be at /sys/module/${underName}/driver/pci:${newName}. 5) use ${newName} - DONE. A few notes: a) This will *always* replace dash with underscore in the name used to load the module, which seems it could be problematic, but I have verified this is what modprobe itself does, so I don't think there will ever be a module with "-" in its name as modprobe would be unable to load it (the same can't be said for drivers though!) b) The one case where the above steps wouldn't work would be if someone implemented a driver within a module where the driver and module had names that differed other than dash vs. underscore. I haven't seen an example of this, so the convention seems to be that they will "match" (modulo - & _). If this mismatch were to ever occur, though, it could be worked around by simply loading the module out-of-band during the host system startup, and then using the driver's name in the config. c) All of this is conveniently ignoring the possibility of a VFIO variant driver that is statically linked in the kernel. The entire design of variant driver auto-detection is based on doing a lookup in modules.alias, and that only lists *loadable modules* (not drivers), so unless I'm missing something, it would be impossible to auto-detect a VFIO variant driver that was statically linked. This is beyond libvirt's ability to fix; the best that could be done would be to manually specify the driver name in the libvirt config, which I suppose is better than nothing :-) Signed-off-by: Laine Stump --- src/util/virpci.c | 195 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 165 insertions(+), 30 deletions(-) diff --git a/src/util/virpci.c b/src/util/virpci.c index baacde4c14..513ae948c0 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -221,6 +221,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) { @@ -1153,44 +1160,168 @@ 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 *errbuf =3D NULL; + 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) { @@ -1290,7 +1421,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 @@ -1302,30 +1432,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.41.0 From nobody Fri May 10 18:54:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1698036976; cv=none; d=zohomail.com; s=zohoarc; b=a8bdQWJ9X6RDugSQxPYiD79lu3W58Jwaw4450tEP/sZI1dXvcjUewYav1ie8l7tbUICrOL5MUsluViX4KV8iD/9lgAS0OoEw5RcNbEgnKo7QHFwqn4eQGnGBGwvMYSRxmTqETj5hfphwAjYZ9uIINsokYlAkx8oDYKawfcAtr3s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698036976; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qM0xNyDA/J2mtTQw/CYFmW11pILZdvxilawdb0ufdjI=; b=NUH+5D6SOKOy0z1GgajgNdFQN5Dn9sDgnIQVYhN6NGVOIkp7Zie2eYFwjqqkLt3RQFxEXRXrGSye7moNeKFjd1/wSv7a6pSJ1VHJR8KsZaqEJrDbK+5M/CndxYXVXM4Yb7pmHrB4jpzk+6ktU2cDUf5wsrCO6mcwtwsOMaHC66Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 169803697617624.216065202232585; Sun, 22 Oct 2023 21:56:16 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-404-8wICa2yXM2OfSlp4kS2T6A-1; Mon, 23 Oct 2023 00:54:59 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 62E3B87AA0A; Mon, 23 Oct 2023 04:54:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3EFF1C15BB8; Mon, 23 Oct 2023 04:54:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BAA7419466EF; Mon, 23 Oct 2023 04:54:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9FBA31946587 for ; Mon, 23 Oct 2023 04:54:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8F628C15978; Mon, 23 Oct 2023 04:54:52 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.8.125]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58572C15BB8; Mon, 23 Oct 2023 04:54:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698036975; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=qM0xNyDA/J2mtTQw/CYFmW11pILZdvxilawdb0ufdjI=; b=BBu0iAKWF+b5Wlx3ObzCfOnLlhbu7PV01q2F31r29v871zdT7NlHlxuGEbss6/FI6hjgO9 zaE5dRhxk6dX2FD1+hgdOzLYtXCGOtInn79lzlB/A4uxeWMwSNzEq+njg1BM8ii1UnQ3g0 yv43WPf8aU74r1dIV82e7jE3YpcySPI= X-MC-Unique: 8wICa2yXM2OfSlp4kS2T6A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 02/15] schema: consolidate RNG for all hostdev elements Date: Mon, 23 Oct 2023 00:54:38 -0400 Message-ID: <20231023045451.210711-3-laine@redhat.com> In-Reply-To: <20231023045451.210711-1-laine@redhat.com> References: <20231023045451.210711-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joao Martins , Cedric Le Goater , Jason Gunthorpe Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1698036977497100003 Content-Type: text/plain; charset="utf-8"; x-default="true" 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 --- 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 a26986b5ce..002587db58 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -3759,18 +3759,12 @@ - - - - - - kvm - vfio - xen - - - - + + + + + + @@ -3808,90 +3802,90 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - + + + + @@ -6182,16 +6176,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.41.0 From nobody Fri May 10 18:54:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1698036979; cv=none; d=zohomail.com; s=zohoarc; b=nR3hWimWYf9As29TvjV9Cb3WVur5Ork2W6WRP5wom/9UWs2CnVtiOalKkRqcLGr5K1gxkwSJWUSD3QNyksG43yumWyxWs2bhB1Q1+A+LwNGGEnBo+DxLMq7UogRc0g49KjlfaGoES0xudEegRh4ELTbNk91JhBq6EReTn9hL85A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698036979; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zr7j1Aij+p1CEw9OTpp9w6PVPKn/+KHwf3go3IC6Hdo=; b=U6tvv/6X18hdJsBmxshMldUDwQqJ/fWdbnqb8+3WqtEmuFiBnb+ZTcB4XAx/xoKIJzbaSdgE8GbPZxfxt7auZu5lR+QARm3zPTBGAeDbanQw25qdsjq0h95TvillLfWzx/1Kie8LJogpdiv0sSN77dWR+Pv1DVDAG7dQVm+YT6c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 16980369794641021.0160990479475; Sun, 22 Oct 2023 21:56:19 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-404-lmf0pro0NzWxuT21zjffUw-1; Mon, 23 Oct 2023 00:54:59 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 660E288B793; Mon, 23 Oct 2023 04:54:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id EDF972166B26; Mon, 23 Oct 2023 04:54:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6C15B1946589; Mon, 23 Oct 2023 04:54:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0430B1946587 for ; Mon, 23 Oct 2023 04:54:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DA376C15978; Mon, 23 Oct 2023 04:54:52 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.8.125]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C4FDC15BB8; Mon, 23 Oct 2023 04:54:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698036978; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=zr7j1Aij+p1CEw9OTpp9w6PVPKn/+KHwf3go3IC6Hdo=; b=TEdCqQphSJgdumUCpV8uks/TvyATuc6w1GPHpRwI3RXmJf93SCJKFn9JME63MNSltsMmEe DrX5ppc52C/G49JPoAVF25DppbsqeN/UFCHaMCXLYkv/NLyZ7shq0f7zVgYi9Eor8NbxcF bkTOdULCIf83OKUbk02xog8JLE2zRXU= X-MC-Unique: lmf0pro0NzWxuT21zjffUw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 03/15] conf: move/rename hostdev PCI driver type enum to device_conf.h Date: Mon, 23 Oct 2023 00:54:39 -0400 Message-ID: <20231023045451.210711-4-laine@redhat.com> In-Reply-To: <20231023045451.210711-1-laine@redhat.com> References: <20231023045451.210711-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joao Martins , Cedric Le Goater , Jason Gunthorpe Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1698036981569100001 Content-Type: text/plain; charset="utf-8"; x-default="true" 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 be less specific to its old usage (all the other parts still apply, at least functionally, to the new usage). The name change (which includes enum values) does cause a lot of churn, but it's all mechanical. Signed-off-by: Laine Stump --- 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 | 34 +++++++++++++------------------- src/conf/domain_conf.h | 14 +------------ src/hypervisor/virhostdev.c | 8 ++++---- src/libvirt_private.syms | 2 +- src/libxl/libxl_capabilities.c | 2 +- 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 | 23 ++++++++++----------- 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 | 8 +++++--- tests/domaincapstest.c | 4 ++-- tests/virhostdevtest.c | 2 +- tools/virsh-completer-nodedev.c | 4 ++-- 22 files changed, 85 insertions(+), 79 deletions(-) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index f3d977f2b7..25a522671e 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(virDeviceHostdevPCIDriver, + VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_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..7513beb5e1 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_TYPE_DEFAULT =3D 0, /* detect automatica= lly, prefer VFIO */ + VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_KVM, /* force legacy kvm style */ + VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_VFIO, /* force vfio */ + VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_XEN, /* force legacy xen style, = use pciback */ + + VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_LAST +} virDeviceHostdevPCIDriverType; + +VIR_ENUM_DECL(virDeviceHostdevPCIDriver); + 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 2fa5756184..7915eb443e 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, virDeviceHostdevPCIDriverTypeToStrin= g); =20 FORMAT_EPILOGUE(hostdev); } diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index 01bcfa2e39..25d3672b18 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_TYPE_LAST); typedef struct _virDomainCapsDeviceHostdev virDomainCapsDeviceHostdev; struct _virDomainCapsDeviceHostdev { virTristateBool supported; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 80f467ae7a..523481c92c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1053,13 +1053,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, @@ -6276,7 +6269,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, =20 driver_node =3D virXPathNode("./driver", ctxt); if (virXMLPropEnum(driver_node, "name", - virDomainHostdevSubsysPCIBackendTypeFromString, + virDeviceHostdevPCIDriverTypeFromString, VIR_XML_PROP_NONZERO, &pcisrc->backend) < 0) return -1; @@ -23342,8 +23335,9 @@ 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_TYPE_DEFAULT) { + const char *backend + =3D virDeviceHostdevPCIDriverTypeToString(pcisrc->backend); =20 if (!backend) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -29841,17 +29835,17 @@ virDomainNetDefActualFromNetworkPort(virDomainNet= Def *iface, 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; + VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_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; + VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_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; + VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_VFIO; break; =20 case VIR_NETWORK_FORWARD_DRIVER_NAME_LAST: @@ -29962,26 +29956,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_TYPE_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_TYPE_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_TYPE_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_TYPE_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_TYPE_LAST: default: - virReportEnumRangeError(virDomainHostdevSubsysPCIBackendType, + virReportEnumRangeError(virDeviceHostdevPCIDriverType, actual->data.hostdev.def.source.subsys= .u.pci.backend); return NULL; } @@ -30926,7 +30920,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_TYPE_VFIO; } =20 =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9e6dd930fa..d56ed32a69 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; + virDeviceHostdevPCIDriverType backend; =20 virBitmap *origstates; }; diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c index 4672bd8785..ce7189ffcd 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_TYPE_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_TYPE_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"= ), + virDeviceHostdevPCIDriverTypeToString(pcisrc->backe= nd)); return -1; } =20 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 553b01b8c0..479a69ed0b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -126,6 +126,7 @@ virCPUModeTypeToString; =20 # conf/device_conf.h virCCWDeviceAddressParseXML; +virDeviceHostdevPCIDriverTypeToString; 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..28330c4d36 100644 --- a/src/libxl/libxl_capabilities.c +++ b/src/libxl/libxl_capabilities.c @@ -631,7 +631,7 @@ libxlMakeDomainDeviceHostdevCaps(virDomainCapsDeviceHos= tdev *dev) =20 virDomainCapsEnumClear(&dev->pciBackend); VIR_DOMAIN_CAPS_ENUM_SET(dev->pciBackend, - VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN); + VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_XEN); return 0; } =20 diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 0c4beffd6a..904f40914c 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_TYPE_DEFA= ULT) + pcisrc->backend =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_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_TYPE_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..d04ec7f6ea 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_TYPE_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_TYPE_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..a5e2681ea1 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_TYPE_DEFAUL= T, + VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_VFIO); } } =20 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d40d3a4e13..fcb4e31502 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4732,16 +4732,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_TYPE_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_TYPE_KVM: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_DEFAULT: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_XEN: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid PCI passthrough type '%1$s'"), - virDomainHostdevSubsysPCIBackendTypeToString(pcisrc= ->backend)); + virDeviceHostdevPCIDriverTypeToString(pcisrc->backe= nd)); return NULL; } =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 995aa3f79c..d57932b681 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -10568,7 +10568,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_TYPE_= VFIO) { if (!(tmpPath =3D virPCIDeviceAddressGetIOMMUGroupDev(&pci= src->addr))) return -1; =20 @@ -11332,14 +11332,15 @@ qemuDomainPrepareHostdevPCI(virDomainHostdevDef *= hostdev, virQEMUCaps *qemuCaps) { bool supportsPassthroughVFIO =3D qemuHostdevHostSupportsPassthroughVFI= O(); - virDomainHostdevSubsysPCIBackendType *backend =3D &hostdev->source.sub= sys.u.pci.backend; + virDeviceHostdevPCIDriverType *driverType + =3D &hostdev->source.subsys.u.pci.backend; =20 /* assign defaults for hostdev passthrough */ - switch (*backend) { - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT: + switch (*driverType) { + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_DEFAULT: if (supportsPassthroughVFIO) { if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) { - *backend =3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO; + *driverType =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_VFIO; } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("VFIO PCI device assignment is not suppor= ted by this version of QEMU")); @@ -11352,7 +11353,7 @@ qemuDomainPrepareHostdevPCI(virDomainHostdevDef *ho= stdev, } break; =20 - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_VFIO: if (!supportsPassthroughVFIO) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("host doesn't support VFIO PCI passthrough")); @@ -11360,20 +11361,20 @@ qemuDomainPrepareHostdevPCI(virDomainHostdevDef *= hostdev, } break; =20 - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_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_TYPE_XEN: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("QEMU does not support device assignment mode '%1= $s'"), - virDomainHostdevSubsysPCIBackendTypeToString(*backe= nd)); + virDeviceHostdevPCIDriverTypeToString(*driverType)); return false; =20 default: - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST: - virReportEnumRangeError(virDomainHostdevSubsysPCIBackendType, *bac= kend); + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_LAST: + virReportEnumRangeError(virDeviceHostdevPCIDriverType, *driverType= ); break; } =20 diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 93df9e4c8e..83365f6685 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_TYPE_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..515d68ec6b 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_TYPE_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..ff28e17136 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_TYPE_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_TYPE_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..89ceaf48d7 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_TYPE_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_TYPE_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..ac4225a783 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -1092,9 +1092,11 @@ 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) { + virDeviceHostdevPCIDriverType driverType + =3D dev->source.subsys.u.pci.backend; + + if (driverType =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_V= FIO || + driverType =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_D= EFAULT) { needsVfio =3D true; } =20 diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index c4a4508430..3d86bdb9c7 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_TYPE_DEFAULT, + VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_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..d9ff992e91 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_TYPE_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..1518395a1e 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_TYPE_LAST, + virDeviceHostdevPCIDriverTypeToString); } --=20 2.41.0 From nobody Fri May 10 18:54:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1698037149; cv=none; d=zohomail.com; s=zohoarc; b=j6KC1fiY1AcMdALrkIpJDsjW4JWgrzDDXJLtVByzmER9osbIczJdB3wQipqXFoY1m7aIWboIAOieWfdw/RBL9W4cIZKst5+EIzC5yXTHvyqOD3oyb9r828lia9WStNdvekTg9c0fkAM5Mrk5vQ1lzSwIZSeRx/xvbqtdEwaFtcw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698037149; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gjLucopN5f2AsL/F534WGjpuuRC0wBVQigonsFH5JzA=; b=dSdpKtsVDJDuczSEQgfCEQCydNkEoVkDa9xp4ZF1pRC4o5JVRuB+pCnC04EvuvKb47wcTfHnJHu3Wahu193j/rk6ellFCKrJ/9NI+gJn2pyH+lxSIO5/Xl/LUpkefkoF6keOOuuC8zN7ZpxMJBJO+McHS++g4Z6X5QvGdoA3an8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1698037148993536.3590642754227; Sun, 22 Oct 2023 21:59:08 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-103-CA_yJ43bPGGjOO2iQp_xQw-1; Mon, 23 Oct 2023 00:55:06 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 178733C1CC21; Mon, 23 Oct 2023 04:55:02 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id F05AD492BD9; Mon, 23 Oct 2023 04:55:01 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DE3171946597; Mon, 23 Oct 2023 04:55:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 60D061946587 for ; Mon, 23 Oct 2023 04:54:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 290D5C15975; Mon, 23 Oct 2023 04:54:53 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.8.125]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5902C15BB8; Mon, 23 Oct 2023 04:54:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698037148; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=gjLucopN5f2AsL/F534WGjpuuRC0wBVQigonsFH5JzA=; b=IowZRsRoYBYuTuZqH5xPiV/H46Fc4ARA34UWvqaJKTyp8vIkQM/R0ZSPC8leQ1NZMv95aW TAetvLqnCcdIadHkaJLLkNYGvWg5gUwl04x6TYaWQyh0LIriggJ314wLtVeo7+bUJPnz0G TC6f6+H8NMLAOMWJC9iXcq7OLVlbqbM= X-MC-Unique: CA_yJ43bPGGjOO2iQp_xQw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 04/15] conf: normalize hostdev parsing to simplify adding new attr Date: Mon, 23 Oct 2023 00:54:40 -0400 Message-ID: <20231023045451.210711-5-laine@redhat.com> In-Reply-To: <20231023045451.210711-1-laine@redhat.com> References: <20231023045451.210711-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joao Martins , Cedric Le Goater , Jason Gunthorpe Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1698037150066100001 Content-Type: text/plain; charset="utf-8"; x-default="true" 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 --- src/conf/domain_conf.c | 28 ++++++++++++++++------------ src/conf/network_conf.c | 26 ++++++++++++-------------- src/conf/network_conf.h | 2 +- src/conf/virnetworkportdef.c | 28 ++++++++++++++++++---------- src/conf/virnetworkportdef.h | 2 +- 5 files changed, 48 insertions(+), 38 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 523481c92c..6dde17ded3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6267,13 +6267,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", - virDeviceHostdevPCIDriverTypeFromString, - VIR_XML_PROP_NONZERO, - &pcisrc->backend) < 0) - return -1; - + if ((driver_node =3D virXPathNode("./driver", ctxt))) { + if (virXMLPropEnum(driver_node, "name", + virDeviceHostdevPCIDriverTypeFromString, + VIR_XML_PROP_NONZERO, + &pcisrc->backend) < 0) { + return -1; + } + } break; =20 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: @@ -23327,14 +23328,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_TYPE_DEFAULT) { const char *backend =3D virDeviceHostdevPCIDriverTypeToString(pcisrc->backend); @@ -23346,9 +23344,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 1a6fd86180..b9601cb307 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 */ @@ -2331,6 +2326,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); @@ -2361,8 +2357,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) { @@ -2371,8 +2366,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..402c0051ec 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,14 @@ virNetworkPortDefFormatBuf(virBuffer *buf, } virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); - if (def->plug.hostdevpci.driver) - virBufferEscapeString(buf, "\n", + + 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.41.0 From nobody Fri May 10 18:54:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1698036974; cv=none; d=zohomail.com; s=zohoarc; b=Wplh/zMj77ijOuSik8HgX5QkbYOGxD1agjRCMgf9U2jLkjb9OHLgvV8bWaQMKF3ARXyaa/xYu4Jb2i42SxwFqJnhuMGH48egfuYwaskViLYI9JDbwmjv24TqBOGiE/VF4vlHsvGDYzUy4demOufTRO9QvdW4UBjKrpDv7g74Cgg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698036974; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Kx4A1JjIwwVIdWY9imvsrDqmddsinPkWb1K1qsEtHLQ=; b=gOptOryEBl7/+ibhFqpPAtYZ07WhyhRy80GEQd+KcscFKEesPg5iQAaeH/YmwDNyK4qiV69lFSSVGqh8nQjw5gPavtVilPh5dJfUrcr6A2EQxymayIjutJaZ7cacIPJcMGg7DHqnuo3XRUzoP2wbKqXZq18hJjmQ1CKPTGl5pEE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1698036974383317.00146385588243; Sun, 22 Oct 2023 21:56:14 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-696-dpCTGdkLNkSpG3m9e68OzQ-1; Mon, 23 Oct 2023 00:55:06 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1C7A5382333F; Mon, 23 Oct 2023 04:55:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC4A9111D7A1; Mon, 23 Oct 2023 04:54:59 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D4CD419466E6; Mon, 23 Oct 2023 04:54:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8BBEF1946597 for ; Mon, 23 Oct 2023 04:54:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6C361C1596D; Mon, 23 Oct 2023 04:54:53 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.8.125]) by smtp.corp.redhat.com (Postfix) with ESMTP id 359EBC15BB8; Mon, 23 Oct 2023 04:54:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698036973; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Kx4A1JjIwwVIdWY9imvsrDqmddsinPkWb1K1qsEtHLQ=; b=Y9VBINq2Qh67lpV9kyXGjomc49M3JIqL3w1oRbluUzC//sLXPb9GDQZpZXId2aZdZTpsYC PAsjQ7YNxCa0gLEwTn3jCHLKQEJSrpPCAVnIbubzEGqSxUTXz7oPE+AQukcLzKhczpY6w0 Ly4yFyXdrmqVBr0DMCKzZ3d1grgM2JU= X-MC-Unique: dpCTGdkLNkSpG3m9e68OzQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 05/15] conf: put hostdev PCI backend into a struct Date: Mon, 23 Oct 2023 00:54:41 -0400 Message-ID: <20231023045451.210711-6-laine@redhat.com> In-Reply-To: <20231023045451.210711-1-laine@redhat.com> References: <20231023045451.210711-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joao Martins , Cedric Le Goater , Jason Gunthorpe Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1698036975525100001 Content-Type: text/plain; charset="utf-8"; x-default="true" 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 "type", it means that all references to "backend" will become "driver.type". 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 --- src/conf/device_conf.h | 4 ++++ src/conf/domain_conf.c | 32 ++++++++++++++------------------ 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 | 4 ++-- 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 +- tests/virhostdevtest.c | 2 +- 15 files changed, 44 insertions(+), 42 deletions(-) diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index 7513beb5e1..3a7a6c3f99 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -43,6 +43,10 @@ typedef enum { =20 VIR_ENUM_DECL(virDeviceHostdevPCIDriver); =20 +struct _virDeviceHostdevPCIDriverInfo { + virDeviceHostdevPCIDriverType type; +}; + 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 6dde17ded3..e840244a7d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6271,7 +6271,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, if (virXMLPropEnum(driver_node, "name", virDeviceHostdevPCIDriverTypeFromString, VIR_XML_PROP_NONZERO, - &pcisrc->backend) < 0) { + &pcisrc->driver.type) < 0) { return -1; } } @@ -23333,18 +23333,18 @@ 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_TYPE_DEFAULT) { - const char *backend - =3D virDeviceHostdevPCIDriverTypeToString(pcisrc->backend); + if (pcisrc->driver.type !=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_DEFAUL= T) { + const char *driverType + =3D virDeviceHostdevPCIDriverTypeToString(pcisrc->driver.type); =20 - if (!backend) { + if (!driverType) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected pci hostdev driver name type %1$d= "), - pcisrc->backend); + _("unexpected pci hostdev driver type %1$d"), + pcisrc->driver.type); return -1; } =20 - virBufferAsprintf(&driverAttrBuf, " name=3D'%s'", backend); + virBufferAsprintf(&driverAttrBuf, " name=3D'%s'", driverType); } =20 virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL); @@ -29838,17 +29838,17 @@ 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 + actual->data.hostdev.def.source.subsys.u.pci.driver.type =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_DEFAULT; break; =20 case VIR_NETWORK_FORWARD_DRIVER_NAME_KVM: - actual->data.hostdev.def.source.subsys.u.pci.backend =3D + actual->data.hostdev.def.source.subsys.u.pci.driver.type =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_KVM; break; =20 case VIR_NETWORK_FORWARD_DRIVER_NAME_VFIO: - actual->data.hostdev.def.source.subsys.u.pci.backend =3D + actual->data.hostdev.def.source.subsys.u.pci.driver.type =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_VFIO; break; =20 @@ -29959,7 +29959,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.type) { case VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_DEFAULT: port->plug.hostdevpci.driver =3D VIR_NETWORK_FORWARD_DRIVER_NA= ME_DEFAULT; break; @@ -29973,14 +29973,10 @@ virDomainNetDefActualToNetworkPort(virDomainDef *= dom, break; =20 case VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_XEN: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Unexpected PCI backend 'xen'")); - break; - case VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_LAST: default: virReportEnumRangeError(virDeviceHostdevPCIDriverType, - actual->data.hostdev.def.source.subsys= .u.pci.backend); + actual->data.hostdev.def.source.subsys= .u.pci.driver.type); return NULL; } =20 @@ -30924,7 +30920,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_TYPE_VFIO; + hostdev->source.subsys.u.pci.driver.type =3D=3D VIR_DEVICE_HOSTDEV= _PCI_DRIVER_TYPE_VFIO; } =20 =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index d56ed32a69..cb37fc9888 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 */ - virDeviceHostdevPCIDriverType backend; + virDeviceHostdevPCIDriverInfo driver; =20 virBitmap *origstates; }; diff --git a/src/conf/virconftypes.h b/src/conf/virconftypes.h index e07f967814..d151dd134a 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 ce7189ffcd..a33b3b604f 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_TYPE_VFIO) { + if (pcisrc->driver.type =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_VFIO= ) { virPCIDeviceSetStubDriverType(actual, VIR_PCI_STUB_DRIVER_VFIO); - } else if (pcisrc->backend =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_X= EN) { + } else if (pcisrc->driver.type =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TY= PE_XEN) { virPCIDeviceSetStubDriverType(actual, VIR_PCI_STUB_DRIVER_XEN); } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("pci backend driver type '%1$s' is not supported"= ), - virDeviceHostdevPCIDriverTypeToString(pcisrc->backe= nd)); + virDeviceHostdevPCIDriverTypeToString(pcisrc->drive= r.type)); return -1; } =20 diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 904f40914c..22482adfa6 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_TYPE_DEFA= ULT) - pcisrc->backend =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_XEN; + pcisrc->driver.type =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_= DEFAULT) + pcisrc->driver.type =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_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_TYPE_XEN; + pcisrc->driver.type =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE= _XEN; =20 if (virDomainHostdevInsert(def, hostdev) < 0) return -1; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index d04ec7f6ea..7f12b11b8d 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_TYPE_DEFAULT, we need to set - * backend correctly. + * driver type 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_TYPE_XEN; + pcisrc->driver.type =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_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 fcb4e31502..b23720922a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4731,7 +4731,7 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def, const char *failover_pair_id =3D NULL; =20 /* caller has to assign proper passthrough backend type */ - switch (pcisrc->backend) { + switch (pcisrc->driver.type) { case VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_VFIO: break; =20 @@ -4741,7 +4741,7 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def, case VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid PCI passthrough type '%1$s'"), - virDeviceHostdevPCIDriverTypeToString(pcisrc->backe= nd)); + virDeviceHostdevPCIDriverTypeToString(pcisrc->drive= r.type)); return NULL; } =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d57932b681..b74e48d6f3 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -10568,7 +10568,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_TYPE_= VFIO) { + if (pcisrc->driver.type =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_T= YPE_VFIO) { if (!(tmpPath =3D virPCIDeviceAddressGetIOMMUGroupDev(&pci= src->addr))) return -1; =20 @@ -11333,7 +11333,7 @@ qemuDomainPrepareHostdevPCI(virDomainHostdevDef *ho= stdev, { bool supportsPassthroughVFIO =3D qemuHostdevHostSupportsPassthroughVFI= O(); virDeviceHostdevPCIDriverType *driverType - =3D &hostdev->source.subsys.u.pci.backend; + =3D &hostdev->source.subsys.u.pci.driver.type; =20 /* assign defaults for hostdev passthrough */ switch (*driverType) { diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 83365f6685..d958d01638 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; + virDeviceHostdevPCIDriverType driverType; =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; + driverType =3D hostdev->source.subsys.u.pci.driver.type; =20 - if (backend =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_VFIO) { + if (driverType =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_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 515d68ec6b..9e1adcee69 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_TYPE_VFIO= ) { + if (pcisrc->driverType =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_V= FIO) { char *vfioGroupDev =3D virPCIDeviceGetIOMMUGroupDev(pci); =20 if (!vfioGroupDev) { diff --git a/src/security/security_dac.c b/src/security/security_dac.c index ff28e17136..31997474a4 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_TYPE_VFIO= ) { + if (pcisrc->driver.type =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_= 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_TYPE_VFIO= ) { + if (pcisrc->driver.type =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_= 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 89ceaf48d7..9a65c3a9f1 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_TYPE_VFIO= ) { + if (pcisrc->driver.type =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_= 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_TYPE_VFIO= ) { + if (pcisrc->driver.type =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_= 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 ac4225a783..1964380e47 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -1093,7 +1093,7 @@ get_files(vahControl * ctl) virPCIDevice *pci =3D virPCIDeviceNew(&dev->source.subsys.= u.pci.addr); =20 virDeviceHostdevPCIDriverType driverType - =3D dev->source.subsys.u.pci.backend; + =3D dev->source.subsys.u.pci.driverType; =20 if (driverType =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_V= FIO || driverType =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_D= EFAULT) { diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c index d9ff992e91..e375fb2833 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_TYPE_VFIO; + subsys->u.pci.driver.type =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_V= FIO; } =20 for (i =3D 0; i < nhostdevs; i++) { --=20 2.41.0 From nobody Fri May 10 18:54:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1698036907; cv=none; d=zohomail.com; s=zohoarc; b=RU2p//00GBUeyx9eGY8SnR7uIwC2UWt8FfMDtWBB+s1S1Wtpd3oPHAfazKPaIN8noVNX2wcSlBIeCsyNCVaLy5/DMH7gWcJTkFZHeZdzf8yo5bpgSVwUvxKSJCTo7N5wf5vjGvK/V/8xYOwfEvR/EYIDOX28uEDRMIIhJ/hZxsQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698036907; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=T0x+IR5ONWTG2pf7Bqbyp81PyyTscrEk97gkQMKfQPw=; b=jlI+NXMx6UCJxAQ3yOtamtzv+nNybOIUwQYQmDEFdL9mK6ARO0PCMMl24Fpfx3aj+kNMVHMEqzMofWNBAm69N3aduVCbFvVWJw6xbgcxAdX/ESmnDo84NgZv2W2rzshj6uoh4qI4pSGjEfIxXu9z3Ul0ENn1BP0odoan/sMdkuk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1698036907616119.6048533864049; Sun, 22 Oct 2023 21:55:07 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-80-DGaFcVb2OpKzSpaTIHVvkg-1; Mon, 23 Oct 2023 00:55:01 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2C8072825E83; Mon, 23 Oct 2023 04:54:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10991111D784; Mon, 23 Oct 2023 04:54:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 092AC1946588; Mon, 23 Oct 2023 04:54:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DA3AB19465B7 for ; Mon, 23 Oct 2023 04:54:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AED60C15975; Mon, 23 Oct 2023 04:54:53 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.8.125]) by smtp.corp.redhat.com (Postfix) with ESMTP id 79539C15BB8; Mon, 23 Oct 2023 04:54:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698036906; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=T0x+IR5ONWTG2pf7Bqbyp81PyyTscrEk97gkQMKfQPw=; b=iiepkU2BFSsUrddcxOh24bo31bIUqtBVMSMsZJNTYSZ26G1ZImf9gUTUIlaJXt2PGnprm3 fUOf5zV+iU+W6oWisrT+4fH/eDbd5WWcrRSXV5E1MYubTRZP1E8SKWmulMwMjWiuHa0R0P WLt37auvGMKHMrGafrCETj4TwCLFhXI= X-MC-Unique: DGaFcVb2OpKzSpaTIHVvkg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 06/15] conf: use virDeviceHostdevPCIDriverInfo in network and networkport objects Date: Mon, 23 Oct 2023 00:54:42 -0400 Message-ID: <20231023045451.210711-7-laine@redhat.com> In-Reply-To: <20231023045451.210711-1-laine@redhat.com> References: <20231023045451.210711-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joao Martins , Cedric Le Goater , Jason Gunthorpe Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1698036909265100001 Content-Type: text/plain; charset="utf-8"; x-default="true" 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 virDeviceHostdevPCIDriverType (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 virDeviceHostdevPCIDriverType). Signed-off-by: Laine Stump --- src/conf/domain_conf.c | 48 +++--------------------------------- src/conf/network_conf.c | 21 ++++++---------- src/conf/network_conf.h | 17 ++----------- src/conf/virnetworkportdef.c | 10 ++++---- src/conf/virnetworkportdef.h | 4 ++- src/network/bridge_driver.c | 2 +- 6 files changed, 22 insertions(+), 80 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e840244a7d..1d083c97ec 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29836,29 +29836,8 @@ 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.type =3D - VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_DEFAULT; - break; - - case VIR_NETWORK_FORWARD_DRIVER_NAME_KVM: - actual->data.hostdev.def.source.subsys.u.pci.driver.type =3D - VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_KVM; - break; - - case VIR_NETWORK_FORWARD_DRIVER_NAME_VFIO: - actual->data.hostdev.def.source.subsys.u.pci.driver.type =3D - VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_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.type + =3D port->plug.hostdevpci.driver.type; break; =20 case VIR_NETWORK_PORT_PLUG_TYPE_LAST: @@ -29959,27 +29938,8 @@ 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.type) { - case VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_DEFAULT: - port->plug.hostdevpci.driver =3D VIR_NETWORK_FORWARD_DRIVER_NA= ME_DEFAULT; - break; - - case VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_KVM: - port->plug.hostdevpci.driver =3D VIR_NETWORK_FORWARD_DRIVER_NA= ME_KVM; - break; - - case VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_VFIO: - port->plug.hostdevpci.driver =3D VIR_NETWORK_FORWARD_DRIVER_NA= ME_VFIO; - break; - - case VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_XEN: - case VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_LAST: - default: - virReportEnumRangeError(virDeviceHostdevPCIDriverType, - actual->data.hostdev.def.source.subsys= .u.pci.driver.type); - return NULL; - } - + port->plug.hostdevpci.driver.type + =3D actual->data.hostdev.def.source.subsys.u.pci.driver.type; break; =20 case VIR_DOMAIN_NET_TYPE_CLIENT: diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index b9601cb307..e3ad4c7340 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, + virDeviceHostdevPCIDriverTypeFromString, VIR_XML_PROP_NONZERO, - &def->driverName) < 0) { + &def->driver.type) < 0) { return -1; } } @@ -2351,19 +2344,19 @@ 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.type + !=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_DEFAU= LT) || def->forward.natIPv6); virBufferAsprintf(buf, "%s>\n", shortforward ? "/" : ""); virBufferAdjustIndent(buf, 2); =20 - if (def->forward.driverName) { + if (def->forward.driver.type) { const char *driverName - =3D virNetworkForwardDriverNameTypeToString(def->forward.d= riverName); + =3D virDeviceHostdevPCIDriverTypeToString(def->forward.dri= ver.type); if (!driverName) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected hostdev driver name type %1$d= "), - def->forward.driverName); + def->forward.driver.type); 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 402c0051ec..77ef705e18 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, + virDeviceHostdevPCIDriverTypeFromString, VIR_XML_PROP_NONZERO, - &def->plug.hostdevpci.driver) < 0) { + &def->plug.hostdevpci.driver.type) < 0) { return NULL; } } @@ -356,10 +356,10 @@ virNetworkPortDefFormatBuf(virBuffer *buf, virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); =20 - if (def->plug.hostdevpci.driver) { + if (def->plug.hostdevpci.driver.type) { virBufferEscapeString(&driverAttrBuf, " name=3D'%s'", - virNetworkForwardDriverNameTypeToStr= ing( - def->plug.hostdevpci.driver)); + virDeviceHostdevPCIDriverTypeToStrin= g( + def->plug.hostdevpci.driver.type= )); } =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..a9188c2436 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.type =3D netdef->forward.driver.type; port->plug.hostdevpci.managed =3D virTristateBoolFromBool(netdef->= forward.managed); =20 if (port->virtPortProfile) { --=20 2.41.0 From nobody Fri May 10 18:54:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1698036967; cv=none; d=zohomail.com; s=zohoarc; b=CgC6ND1jwa7IHsFUjeCcyg1SJZYVaOWLGLfM2RixcaCx6W2I5lmRS0nxnfC01WuHH6/20Pu0NaJ2eU8p27ycnNl3q1sJLqkkmavqlgdMlayaow0fv4rtMPVyKFl3t0kP4N6axYE0SfA8ShTTw312kt/nIM//Ng5WhNo0TfxsAA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698036967; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sB4u7cUhnwd0zM0e+JMNeuxrtQ2zszAp7K6QDZOtuqM=; b=exkC0IEDsVATI6Cc5jaHWnjDpvGzXHwRufCYzkCSChw1evFLvFFwU6o9AcyhIQuvyLmIWZwHWqUIvOfDhbSoFpq6YLFGPXWGDjsSyN6u373F5RM0WDvLfiKZztY4ADLJLfLCf+jjXfpJqzGYzEkjysczgSmgxVE6L179Uw0To80= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 16980369676961013.6755044781796; Sun, 22 Oct 2023 21:56:07 -0700 (PDT) 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-686-9SC7Cpf3Mz-GsfsuDlkqfg-1; Mon, 23 Oct 2023 00:55:04 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 CFBAA8164E5; Mon, 23 Oct 2023 04:54:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE90B492BE2; Mon, 23 Oct 2023 04:54:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1121519466F5; Mon, 23 Oct 2023 04:54:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1CD391946588 for ; Mon, 23 Oct 2023 04:54:54 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id F292AC15978; Mon, 23 Oct 2023 04:54:53 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.8.125]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB356C15BB8; Mon, 23 Oct 2023 04:54:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698036966; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=sB4u7cUhnwd0zM0e+JMNeuxrtQ2zszAp7K6QDZOtuqM=; b=DIi7S7sIO6g/CYTT6mnctqeGZiBA0zo3WVh/YHRLmJ2uSvNeX7Qyx11WrDu3FJllcCb9UR YagheadBB9qS+0BNqSH6QjZGEvJKiBPGQvD+fjPqP9QsFbRtau9UKLWz2rcrut2F1RftL2 sY+/MJ8fuY1zMAelFfFQc5C/Yq6WIrU= X-MC-Unique: 9SC7Cpf3Mz-GsfsuDlkqfg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 07/15] conf: split out hostdev parse/format to their own functions Date: Mon, 23 Oct 2023 00:54:43 -0400 Message-ID: <20231023045451.210711-8-laine@redhat.com> In-Reply-To: <20231023045451.210711-1-laine@redhat.com> References: <20231023045451.210711-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joao Martins , Cedric Le Goater , Jason Gunthorpe Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1698036969451100003 Content-Type: text/plain; charset="utf-8"; x-default="true" This is done so that we can re-use the same parser/formatter for and Signed-off-by: Laine Stump --- src/conf/device_conf.c | 41 +++++++++++++++++++++++++++++++++++++++++ src/conf/device_conf.h | 7 +++++++ src/conf/domain_conf.c | 28 +++++----------------------- 3 files changed, 53 insertions(+), 23 deletions(-) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index 25a522671e..e022783816 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -55,6 +55,47 @@ VIR_ENUM_IMPL(virDomainDeviceAddress, "unassigned", ); =20 + +int +virDeviceHostdevPCIDriverInfoParseXML(xmlNodePtr node, + virDeviceHostdevPCIDriverInfo *drive= r) +{ + if (virXMLPropEnum(node, "name", + virDeviceHostdevPCIDriverTypeFromString, + VIR_XML_PROP_NONZERO, + &driver->type) < 0) { + return -1; + } + + return 0; +} + + +int +virDeviceHostdevPCIDriverInfoFormat(virBuffer *buf, + const virDeviceHostdevPCIDriverInfo *d= river) +{ + g_auto(virBuffer) driverAttrBuf =3D VIR_BUFFER_INITIALIZER; + + if (driver->type !=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_DEFAULT) { + const char *driverType + =3D virDeviceHostdevPCIDriverTypeToString(driver->type); + + if (!driverType) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected pci hostdev driver type %1$d"), + driver->type); + return -1; + } + + virBufferAsprintf(&driverAttrBuf, " name=3D'%s'", driverType); + } + + 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 3a7a6c3f99..9f4b9f5375 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 1d083c97ec..ea1348da5f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6267,13 +6267,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", - virDeviceHostdevPCIDriverTypeFromString, - VIR_XML_PROP_NONZERO, - &pcisrc->driver.type) < 0) { - return -1; - } + if ((driver_node =3D virXPathNode("./driver", ctxt)) && + virDeviceHostdevPCIDriverInfoParseXML(driver_node, &pcisrc->dr= iver) < 0) { + return -1; } break; =20 @@ -23328,26 +23324,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.type !=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_DEFAUL= T) { - const char *driverType - =3D virDeviceHostdevPCIDriverTypeToString(pcisrc->driver.type); - - if (!driverType) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected pci hostdev driver type %1$d"), - pcisrc->driver.type); - return -1; - } - - virBufferAsprintf(&driverAttrBuf, " name=3D'%s'", driverType); - } - - 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.41.0 From nobody Fri May 10 18:54:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1698036912; cv=none; d=zohomail.com; s=zohoarc; b=IgUINOW75OelkP/zVf3rRT5ZrsQGFVAB8Q9SZwxuhBEuh9iekZCrpIHsMedJKruVedcWO4uxGoVR3icvL+Dr9VZ7WZnJzVCZQFIKIEaw525SsW71s/vCMBFCQe3nFuZXganyFTYW89JM4p/4kKxZ0m1aWG3xeBr5+gjSbuPKDyY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698036912; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JkX0ttAmLdvDofBM9RJ7ZyfbKZxw6v2l/TI5aZjphho=; b=njEimcsd2QMxkXHNRq0mqxHlt636wsyWc58eMS+Ox8IVJ8CJxVGSy14cNqU7Om3xL4c1HfFjVQ/I4DFQq+fMA0hxHmKhZ85r/U0yJ4ASWYpJmdz+ccw907h8Tg6hqG4Y1kp2ffv6JPO+s0LTNsQ+zTUEndEHnIyeFr/UYova5xk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1698036912217532.9911811627943; Sun, 22 Oct 2023 21:55:12 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-56-VQ_qGdOyOj2kiNaOksdknw-1; Mon, 23 Oct 2023 00:55:05 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AE5C288B7BA; Mon, 23 Oct 2023 04:54:59 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 85BC640C6F7E; Mon, 23 Oct 2023 04:54:59 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8515F19465B7; Mon, 23 Oct 2023 04:54:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5160E1946588 for ; Mon, 23 Oct 2023 04:54:54 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 41503C15975; Mon, 23 Oct 2023 04:54:54 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.8.125]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0AB49C15BB8; Mon, 23 Oct 2023 04:54:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698036911; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=JkX0ttAmLdvDofBM9RJ7ZyfbKZxw6v2l/TI5aZjphho=; b=ZV3ZNFQyzBRzBf4JmNxFBizhio7jqrlmcmF8QJZhkU01cQLNyqtqmrC1y9q62vNPkHURVR 0CwS5jqqMgkGTYLm+iobKUGHUY0lPJPoDXrt85mPnnByI4Np33sV6fS/Xhz9N+ofGiUeCC SF4iSUZvxCQMNRfCvaFSmfwlESfwiZc= X-MC-Unique: VQ_qGdOyOj2kiNaOksdknw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 08/15] conf: use new common parser/formatter for hostdev driver in network XML Date: Mon, 23 Oct 2023 00:54:44 -0400 Message-ID: <20231023045451.210711-9-laine@redhat.com> In-Reply-To: <20231023045451.210711-1-laine@redhat.com> References: <20231023045451.210711-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joao Martins , Cedric Le Goater , Jason Gunthorpe Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1698036913292100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Now if a new attribute is added to , we only need to update the formatting/parsing in one place. Signed-off-by: Laine Stump --- 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 e3ad4c7340..43e7c78e95 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", - virDeviceHostdevPCIDriverTypeFromString, - VIR_XML_PROP_NONZERO, - &def->driver.type) < 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 */ @@ -2350,19 +2346,8 @@ virNetworkDefFormatBuf(virBuffer *buf, virBufferAsprintf(buf, "%s>\n", shortforward ? "/" : ""); virBufferAdjustIndent(buf, 2); =20 - if (def->forward.driver.type) { - const char *driverName - =3D virDeviceHostdevPCIDriverTypeToString(def->forward.dri= ver.type); - if (!driverName) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected hostdev driver name type %1$d= "), - def->forward.driver.type); - 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 77ef705e18..67911e498e 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", - virDeviceHostdevPCIDriverTypeFromString, - VIR_XML_PROP_NONZERO, - &def->plug.hostdevpci.driver.type) < 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))) { @@ -356,13 +353,8 @@ virNetworkPortDefFormatBuf(virBuffer *buf, virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); =20 - if (def->plug.hostdevpci.driver.type) { - virBufferEscapeString(&driverAttrBuf, " name=3D'%s'", - virDeviceHostdevPCIDriverTypeToStrin= g( - def->plug.hostdevpci.driver.type= )); - } - - 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.41.0 From nobody Fri May 10 18:54:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1698036907; cv=none; d=zohomail.com; s=zohoarc; b=jU483Yt1iIn/8Dw5Ex0DY5ZGnyeha8pyGJre2mx2naPCHxf1EUd4bkyKmFORT4h8+M9dLmZdO9Hw5H0bAqL1fVov3SAC5Tq+Hwq3Z0hWw0IPhbw3B+D3FPRw8L56q2cpAqTZ08QtxIobNXflDaMfjCP5y+WFoteMh5z4w7kjaZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698036907; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0OMCoq7tUqkvkSON9YP+BfgikJxL/PAslrcOaGw88B4=; b=lsGAvOxXvBFcVCfR+YH1b1I+iydtCN1erabPaRRoILCGyjrqAYK7G78woW40uiKWGU4/ckKgXR9rnn1W7vi2lihx6PKVv7cDF2LnPWhCrXHPh7h1dyZjhPEgsVmGOLQ8Q21akiSgOX17/dsvhnbR6rS0LDDJgAjXDMzaPSf18LM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1698036907713177.24899673043512; Sun, 22 Oct 2023 21:55:07 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-654-0LRh4MNvOJuWlfaGj6vR0w-1; Mon, 23 Oct 2023 00:55:02 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D56DD3C170A1; Mon, 23 Oct 2023 04:54:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B9BFE1120F; Mon, 23 Oct 2023 04:54:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5A27619466E7; Mon, 23 Oct 2023 04:54:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A7C4F194658F for ; Mon, 23 Oct 2023 04:54:54 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8758FC15975; Mon, 23 Oct 2023 04:54:54 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.8.125]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4EAA6C15BB8; Mon, 23 Oct 2023 04:54:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698036906; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=0OMCoq7tUqkvkSON9YP+BfgikJxL/PAslrcOaGw88B4=; b=FqC+icBR3ZHi01ab/96C/Y+5ulIEhuwfz1/eGlluc5z5ZbBmDYMVHGGI2vtg9/+f/vZHi5 uh/qR4QoKs2aEsXc52aCmQkslLfYAUEC8Jh+vfe4evBxF3obSVgedWEsPkUTXRXQXsY2Z3 kGIUsrcNtoQSJWeV3vpqsscSf4eGnkk= X-MC-Unique: 0LRh4MNvOJuWlfaGj6vR0w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 09/15] tests: remove explicit from hostdev test cases Date: Mon, 23 Oct 2023 00:54:45 -0400 Message-ID: <20231023045451.210711-10-laine@redhat.com> In-Reply-To: <20231023045451.210711-1-laine@redhat.com> References: <20231023045451.210711-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joao Martins , Cedric Le Goater , Jason Gunthorpe Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1698036909377100003 Content-Type: text/plain; charset="utf-8"; x-default="true" The long-deprecated use of in domain xml for devices was only ever necessary during the period when libvirt supported both VFIO and "legacy KVM" styles of hostdev device assignment in the QEMU driver. This became unnecessary many years ago (circa RHEL6!) 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 while also making it simpler to properly test when a later patch "re-animates" the driver name attribute for a slightly different (but related) use. Signed-off-by: Laine Stump --- tests/qemuxml2argvdata/hostdev-pci-address-unassigned.xml | 4 ---- tests/qemuxml2argvdata/hostdev-pci-multifunction.xml | 7 ------- tests/qemuxml2argvdata/hostdev-vfio-multidomain.xml | 1 - .../hostdev-vfio-zpci-autogenerate-fids.xml | 2 -- .../hostdev-vfio-zpci-autogenerate-uids.xml | 2 -- tests/qemuxml2argvdata/hostdev-vfio-zpci-autogenerate.xml | 1 - tests/qemuxml2argvdata/hostdev-vfio-zpci-boundaries.xml | 2 -- .../qemuxml2argvdata/hostdev-vfio-zpci-ccw-memballoon.xml | 1 - tests/qemuxml2argvdata/hostdev-vfio-zpci-duplicate.xml | 2 -- .../hostdev-vfio-zpci-invalid-uid-valid-fid.xml | 1 - .../hostdev-vfio-zpci-multidomain-many.xml | 8 -------- tests/qemuxml2argvdata/hostdev-vfio-zpci-set-zero.xml | 1 - tests/qemuxml2argvdata/hostdev-vfio-zpci-uid-set-zero.xml | 1 - tests/qemuxml2argvdata/hostdev-vfio-zpci-wrong-arch.xml | 1 - tests/qemuxml2argvdata/hostdev-vfio-zpci.xml | 1 - tests/qemuxml2argvdata/hostdev-vfio.xml | 1 - tests/qemuxml2argvdata/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 -- .../hostdev-pci-address-unassigned.x86_64-latest.xml | 4 ---- .../hostdev-pci-multifunction.x86_64-latest.xml | 7 ------- .../hostdev-vfio-zpci-autogenerate-fids.s390x-latest.xml | 2 -- .../hostdev-vfio-zpci-autogenerate-uids.s390x-latest.xml | 2 -- .../hostdev-vfio-zpci-autogenerate.s390x-latest.xml | 1 - .../hostdev-vfio-zpci-boundaries.s390x-latest.xml | 2 -- .../hostdev-vfio-zpci-ccw-memballoon.s390x-latest.xml | 1 - .../hostdev-vfio-zpci-multidomain-many.s390x-latest.xml | 8 -------- .../qemuxml2xmloutdata/hostdev-vfio-zpci.s390x-latest.xml | 1 - tests/qemuxml2xmloutdata/hostdev-vfio.x86_64-latest.xml | 1 - .../qemuxml2xmloutdata/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 -- 35 files changed, 82 deletions(-) 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 @@