From nobody Tue Feb 10 23:00:40 2026 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=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1681451221; cv=none; d=zohomail.com; s=zohoarc; b=j6sEThoRP2AyLMY5I8JNKJFc5XGPag0EGe2PYx0t3TvQIAIxM3ijLPJ3X/KnZJ/w45EHumi1S82yqyEu6lb7O1JIeJb58UXUL18qZdENumWnoOXT7AReqpwos9fpWvLLp6+LMw6lWUp8EG/JttV1UULW+x7fbvj+77r6liKjqAE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681451221; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=xx083oZPVjdn7igQbOQezQMMg+DJwyV5w3xgnOHO5Bo=; b=XQFWHBamS+iGbJyvoMPjTJIriMEbPUgM1pnAF6HlEn7PXQ6qGI0s10N4J/fJnyNFu5exLjWZVgU381LiwQKkgg1tcw5F/svoGALx9uAfvmUWwW7lLZaHCDkRgelnG26hIu/VNZu4uuEu0OyS5BdUspAz9a6s2rO1KblxxXvyJm0= 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=fail 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 1681451221013566.5425189961444; Thu, 13 Apr 2023 22:47:01 -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-633-zIZu_eCFPYiBdXUQnlpM0g-1; Fri, 14 Apr 2023 01:46:49 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CA37910504AB; Fri, 14 Apr 2023 05:46:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBD661121320; Fri, 14 Apr 2023 05:46:43 +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 AD9B519465B7; Fri, 14 Apr 2023 05:46:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B7FCB19465B6 for ; Fri, 14 Apr 2023 05:46:41 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 98E952027045; Fri, 14 Apr 2023 05:46:41 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 917302027043 for ; Fri, 14 Apr 2023 05:46:41 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 733558996E8 for ; Fri, 14 Apr 2023 05:46:41 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-329-LMFX2CscPyOZ60vrOtO_Eg-1; Fri, 14 Apr 2023 01:46:37 -0400 Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2023 22:46:36 -0700 Received: from duan-server-s2600bt.bj.intel.com ([10.240.192.143]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2023 22:46:34 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681451220; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=xx083oZPVjdn7igQbOQezQMMg+DJwyV5w3xgnOHO5Bo=; b=YKcTkDScY2w0eioNDuZ+pW87qjVfPO6A3mIIj6R48oFfIzPdkqd4KACiVby4kE2rRzsTWm KnQIy3hmIVudQG2JJq19sNmDZuwYD3/ZquiFg9wj4BthhHzTM8uBe3PmJ3j3DaLmeU9Dsf Ar8+KPpOUD8wxbj2vcLTWaNyRUM0r1U= X-MC-Unique: zIZu_eCFPYiBdXUQnlpM0g-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: LMFX2CscPyOZ60vrOtO_Eg-1 X-IronPort-AV: E=McAfee;i="6600,9927,10679"; a="346219683" X-IronPort-AV: E=Sophos;i="5.99,195,1677571200"; d="scan'208";a="346219683" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10679"; a="754321820" X-IronPort-AV: E=Sophos;i="5.99,195,1677571200"; d="scan'208";a="754321820" From: Zhenzhong Duan To: libvir-list@redhat.com Subject: [PATCH v2] qemu: Fix domxml-to-native command failure Date: Fri, 14 Apr 2023 13:34:58 +0800 Message-Id: <20230414053458.17966-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: mprivozn@redhat.com, chao.p.peng@intel.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: intel.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1681451221865100001 Content-Type: text/plain; charset="utf-8"; x-default="true" virsh command domxml-to-native failed with below error but start command succeed for same domain xml. "internal error: invalid PCI passthrough type 'default'" If host PCI device's driver attribute isn't defined in domain xml, qemu driver will choose a proper value based on host environment before starting qemu process. But this is missed in domxml-to-native command, add the same logic so domxml-to-native could pass and replace the relevant code in qemuHostdevPreparePCIDevicesCheckSupport() with an error report. Signed-off-by: Zhenzhong Duan --- v2: replace setting with an error report, suggested by Michal src/qemu/qemu_domain.c | 11 +++++++++++ src/qemu/qemu_hostdev.c | 8 ++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 63b13b6875c9..517c90f93f0a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11274,6 +11274,17 @@ qemuDomainPrepareHostdev(virDomainHostdevDef *host= dev, } } } + if (hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && + hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_= PCI) { + bool supportsPassthroughVFIO =3D qemuHostdevHostSupportsPassthroug= hVFIO(); + virDomainHostdevSubsysPCIBackendType *backend =3D &hostdev->source= .subsys.u.pci.backend; + + if (*backend =3D=3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT && + supportsPassthroughVFIO && + virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) { + *backend =3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO; + } + } =20 return 0; } diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index 45cd1066f0a5..305a323a0769 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -175,15 +175,15 @@ qemuHostdevPreparePCIDevicesCheckSupport(virDomainHos= tdevDef **hostdevs, case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT: if (supportsPassthroughVFIO && virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) { - *backend =3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO; + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("qemuDomainPrepareHostdev() should have s= et backend " + "to VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO")= ); } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("host doesn't support passthrough of " "host PCI devices")); - return false; } - - break; + return false; =20 case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO: if (!supportsPassthroughVFIO) { --=20 2.25.1