From nobody Tue Sep 9 03:32:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1747056648; cv=none; d=zohomail.com; s=zohoarc; b=HOARpEMagi7fnb3xhT+ZPWfqhFkN72i3pDYOoM3Xi1yaI+CE5J1Or5WP4cwo1p3zqCM6WUbc3jLlAeBw/pM8dQGK8LJ2ZgsBCoTmOQwSZL9FvA0mE/hCVCAPFdgnlQ/Q934Hjliq+S37+1Q414nJ/XIbf3oLuoyhfsQkKlm5w44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747056648; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=X6WqH5zhkikmr4Cisv8V7FZmN+w9vmtvT7J6kW+zss8=; b=n50/1jQUrg6weNOM468MDBa5x+UM0uxU4j9pSxOErKcD2TVdp5P0AeUh4lYkpgIz8tRo+158GUFZMP4vz7z3MLWlPVAXXQ3w8eD+Z6cqiuzcfOe8YycsTVtG9hdQFzOe13xEZ08MUCm444WjR5yfQobJyPfKW5/oGEDOwGdnSm0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1747056648313887.8088989652457; Mon, 12 May 2025 06:30:48 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 69FB915EF; Mon, 12 May 2025 09:30:47 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id BADF112BD; Mon, 12 May 2025 09:30:15 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 80A5E128C; Mon, 12 May 2025 09:30:09 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id DFA29128A for ; Mon, 12 May 2025 09:30:08 -0400 (EDT) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-365-D2sD_nHNPwe4HUuKjFrxcA-1; Mon, 12 May 2025 09:30:07 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 717BC18004A7 for ; Mon, 12 May 2025 13:30:06 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.14]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A686C1801482 for ; Mon, 12 May 2025 13:30:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747056608; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cjtFaVCYrgnOjl2Oh205cO0vmOyMv1j/CDjxbYddY6k=; b=LqFFmkcGIk8eenaZGp2lwUHYwe+k7hISVbF9yLmuqbB8vc4Eu1r7ybD0Mu13SbLevATai4 DdCmR99RQ0x8W6l4haW0C3MQavPAcBT+7+lv4TDqwxcvncMD+u5Hdtcz70gpOpHTitrx+G Ig2eu+jEd4X3RfbGjjHHaeQRHoL9zvQ= X-MC-Unique: D2sD_nHNPwe4HUuKjFrxcA-1 X-Mimecast-MFC-AGG-ID: D2sD_nHNPwe4HUuKjFrxcA_1747056606 To: devel@lists.libvirt.org Subject: [PATCH 1/2] qemuDomainPrepareHostdevPCI: Fix return values after conversion from bool to int Date: Mon, 12 May 2025 15:30:01 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 47MZ4zBfhQwDqtvRVB7p7QvJarF0VjcvCemGCNlQ5nA_1747056606 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: LB52MPXJDUQHZ46IBPAWRJZJD2RY4RTW X-Message-ID-Hash: LB52MPXJDUQHZ46IBPAWRJZJD2RY4RTW X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1747056658196116600 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Historically when the code was in 'qemuHostdevPreparePCIDevicesCheckSupport' the function returned bools. Later it was refactored and moved to 'qemuDomainPrepareHostdevPCI' the return values were not changed. Thus the function now returned '-1', 'false', and 'true'. Callers checked for '-1' only so the few cases forbidding legacy device passthrough were no longer causing fatal errors. Fixes: 3b87709c768480e085556e06bd8d08f62270d42d Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_domain.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 52da234343..73869fcfac 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9945,28 +9945,28 @@ qemuDomainPrepareHostdevPCI(virDomainHostdevDef *ho= stdev, if (!supportsPassthroughVFIO) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("host doesn't support VFIO PCI passthrough")); - return false; + return -1; } break; case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_KVM: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("host doesn't support legacy PCI passthrough")); - return false; + return -1; case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("QEMU does not support device assignment mode '%1= $s'"), virDeviceHostdevPCIDriverNameTypeToString(*driverNa= me)); - return false; + return -1; default: case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_LAST: virReportEnumRangeError(virDeviceHostdevPCIDriverName, *driverName= ); - break; + return -1; } - return true; + return 0; } --=20 2.49.0 From nobody Tue Sep 9 03:32:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1747056667; cv=none; d=zohomail.com; s=zohoarc; b=i6OO51I30ibJDySJTSDb2cPeJUCjVsKyDvBYV+zPbQPuzyUKpxUjEJO1ftZz/N+RS/MnmAvifb76TsqHSdQEZzmHHMmRwwsn+Uo7tESvyc0HOPpHtpId78Q/WyG9vhIuMCatlGSVIU7tfw9IWZTopwjURFjZucqYf4MbDX5b1Z0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747056667; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=tJdaMTRSBaGQVDubYzLQ1F8kT64qNbPIZSrIM9Bfdfg=; b=dUJASstKkooMhB7HTkZ9bNxuKkcbRiBhKfmMtRgWc0hlBq5mBQFjc4T1bLyE5N1Uu1TnpuDUCy5pq2OPV/djXwyBARho+5VDmo9vV/aEPb1IhDeFnglpzteJeWzl9Jihnofj427/0yfX5YoMgGbpJRir/fJOYYB2zh7TXgAAdDY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1747056667797123.07275754484328; Mon, 12 May 2025 06:31:07 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id BB849A32; Mon, 12 May 2025 09:31:06 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 5D03614E1; Mon, 12 May 2025 09:30:17 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id A28F4128C; Mon, 12 May 2025 09:30:11 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 9F697127B for ; Mon, 12 May 2025 09:30:10 -0400 (EDT) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-314-I6HNQXelMdmCNBKjGhLk2Q-1; Mon, 12 May 2025 09:30:08 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B72BA1956096 for ; Mon, 12 May 2025 13:30:07 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.14]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EFCF81801482 for ; Mon, 12 May 2025 13:30:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747056610; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HeRHO2EuKdBx5CUyYU+Q8WkJv37oEBBRSUO+L7wvY6E=; b=H8/0s4LPFG2FMZlm9zpAPdW1/mQqJNI1QEGkbU+ffcaOUSApXW39G6JRbXcM4pTFBysnop TlXyRF16ze3UZunXiZSiMUsOTj5156815IJ+7ONif2v5QWNdf+ZagPu5kpByxb1Xjthlbs 2Th+AWHdLdQO1H7iDukB86RFW6X2VJg= X-MC-Unique: I6HNQXelMdmCNBKjGhLk2Q-1 X-Mimecast-MFC-AGG-ID: I6HNQXelMdmCNBKjGhLk2Q_1747056607 To: devel@lists.libvirt.org Subject: [PATCH 2/2] qemuDomainPrepareHostdevPCI: Simplify error messages Date: Mon, 12 May 2025 15:30:02 +0200 Message-ID: <1dd8eedb34843be6f666991d6ec5d05384240ce9.1747056552.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: r2rHTgv9W7BsqpZJpjeCO7mVZTDuhRvpNRb1XnKVIpE_1747056607 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: X6M3KYFNYVFLZXOQCCJQ6OM27P2UEMTL X-Message-ID-Hash: X6M3KYFNYVFLZXOQCCJQ6OM27P2UEMTL X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1747056668503116600 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Rework the error reporting. Unify on one message about device assignment modes not supported by the qemu driver and move and reword the messages for VFIO device assignment. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_domain.c | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 73869fcfac..5603feaa05 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9920,40 +9920,19 @@ static int qemuDomainPrepareHostdevPCI(virDomainHostdevDef *hostdev, virQEMUCaps *qemuCaps) { - bool supportsPassthroughVFIO =3D virHostdevHostSupportsPassthroughVFIO= (); virDeviceHostdevPCIDriverName *driverName =3D &hostdev->source.subsys.= u.pci.driver.name; /* assign defaults for hostdev passthrough */ switch (*driverName) { case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT: - if (supportsPassthroughVFIO) { - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) { - *driverName =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO; - } else { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("VFIO PCI device assignment is not suppor= ted by this version of QEMU")); - return -1; - } - } else { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("host doesn't support passthrough of host PCI= devices")); - return -1; - } + /* Since nowadays only VFIO is supported default to it */ + *driverName =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO; break; case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO: - if (!supportsPassthroughVFIO) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("host doesn't support VFIO PCI passthrough")); - return -1; - } break; case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_KVM: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("host doesn't support legacy PCI passthrough")); - return -1; - case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("QEMU does not support device assignment mode '%1= $s'"), @@ -9966,6 +9945,18 @@ qemuDomainPrepareHostdevPCI(virDomainHostdevDef *hos= tdev, return -1; } + if (!virHostdevHostSupportsPassthroughVFIO()) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("VFIO PCI device assignment is not supported by t= he host")); + return -1; + } + + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("VFIO PCI device assignment is not supported by t= his QEMU binary")); + return -1; + } + return 0; } --=20 2.49.0