From nobody Tue Feb 10 07:40:56 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 171088733108040.528204363542045; Tue, 19 Mar 2024 15:28:51 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E6B6B1CCF; Tue, 19 Mar 2024 18:28:49 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id C59CE1E81; Tue, 19 Mar 2024 18:26:14 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D51AC1A96; Tue, 19 Mar 2024 18:26:04 -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 3ABE219D1 for ; Tue, 19 Mar 2024 18:26:04 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-441-7I_y_6upP3SiWNg5EdCwAQ-1; Tue, 19 Mar 2024 18:26:00 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (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 A0EF31C05196 for ; Tue, 19 Mar 2024 22:26:00 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.16.114]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7AF08492BD0 for ; Tue, 19 Mar 2024 22:26:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: 7I_y_6upP3SiWNg5EdCwAQ-1 From: Jonathon Jongsma To: devel@lists.libvirt.org Subject: [PATCH 1/2] conf: allow display and ramfb for vfio pci hostdevs Date: Tue, 19 Mar 2024 17:25:54 -0500 Message-ID: <20240319222555.2086423-2-jjongsma@redhat.com> In-Reply-To: <20240319222555.2086423-1-jjongsma@redhat.com> References: <20240319222555.2086423-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: SFM7VHW7FMCSOIE7WYVEGJ6RSMHDRJWC X-Message-ID-Hash: SFM7VHW7FMCSOIE7WYVEGJ6RSMHDRJWC X-MailFrom: jjongsma@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: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1710887332825100001 We already allow the user to specify display=3D"on" and ramfb=3D"on" for mdev host devices. But newer GPU models will no longer use the mdev framework, so we should enable this same functionality for other non-mdev passthrough PCI devices. Resolves: https://issues.redhat.com/browse/RHEL-28808 Signed-off-by: Jonathon Jongsma --- docs/formatdomain.rst | 8 ++++++++ src/conf/domain_conf.c | 20 +++++++++++++++++++- src/conf/domain_conf.h | 2 ++ src/conf/domain_validate.c | 21 +++++++++++++-------- src/conf/schemas/domaincommon.rng | 25 +++++++++++++++---------- 5 files changed, 57 insertions(+), 19 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 2adc2ff968..ab44ed58a6 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -4390,6 +4390,14 @@ or: starting the guest or hot-plugging the device and ``virNodeDeviceReAttach`` (or ``virsh nodedev-reattach``) after hot-= unplug or stopping the guest. + :since:`Since 10.2.0` an optional ``display`` attribute may be used = to + enable using a vgpu device as a display device for the guest. Suppor= ted + values are either ``on`` or ``off`` (default). There is also an opti= onal + ``ramfb`` attribute with values of either ``on`` or ``off`` (default= ). + When enabled, the ``ramfb`` attribute provides a memory framebuffer = device + to the guest. This framebuffer allows the vgpu to be used as a boot = display + before the gpu driver is loaded within the guest. ``ramfb`` requires= the + ``display`` attribute to be set to ``on``. ``scsi`` For SCSI devices, user is responsible to make sure the device is not= used by host. If supported by the hypervisor and OS, the optional ``sgio`= ` ( diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 770b5fbbff..11a0b0ecda 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6306,6 +6306,16 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, VIR_XML_PROP_NONE, &mdevsrc->ramfb) < 0) return -1; + } else if (def->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TY= PE_PCI) { + if (virXMLPropTristateSwitch(node, "display", + VIR_XML_PROP_NONE, + &pcisrc->display) < 0) + return -1; + + if (virXMLPropTristateSwitch(node, "ramfb", + VIR_XML_PROP_NONE, + &pcisrc->ramfb) < 0) + return -1; } =20 switch (def->source.subsys.type) { @@ -26251,6 +26261,7 @@ virDomainHostdevDefFormat(virBuffer *buf, const char *mode =3D virDomainHostdevModeTypeToString(def->mode); virDomainHostdevSubsysSCSI *scsisrc =3D &def->source.subsys.u.scsi; virDomainHostdevSubsysMediatedDev *mdevsrc =3D &def->source.subsys.u.m= dev; + virDomainHostdevSubsysPCI *pcisrc =3D &def->source.subsys.u.pci; virDomainHostdevSubsysSCSIVHost *scsihostsrc =3D &def->source.subsys.u= .scsi_host; const char *type; =20 @@ -26319,7 +26330,14 @@ virDomainHostdevDefFormat(virBuffer *buf, virBufferAsprintf(buf, " ramfb=3D'%s'", virTristateSwitchTypeToString(mdevsrc->r= amfb)); } - + if (def->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_= PCI) { + if (pcisrc->display !=3D VIR_TRISTATE_SWITCH_ABSENT) + virBufferAsprintf(buf, " display=3D'%s'", + virTristateSwitchTypeToString(pcisrc->di= splay)); + if (pcisrc->ramfb !=3D VIR_TRISTATE_SWITCH_ABSENT) + virBufferAsprintf(buf, " ramfb=3D'%s'", + virTristateSwitchTypeToString(pcisrc->ra= mfb)); + } } virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 76251938b8..5925faaf1a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -236,6 +236,8 @@ struct _virDomainHostdevSubsysUSB { struct _virDomainHostdevSubsysPCI { virPCIDeviceAddress addr; /* host address */ virDeviceHostdevPCIDriverInfo driver; + virTristateSwitch display; + virTristateSwitch ramfb; =20 virBitmap *origstates; }; diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index faa7659f07..395e036e8f 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -1291,15 +1291,20 @@ virDomainDefHostdevValidate(const virDomainDef *def) } } =20 - if (dev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && - dev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_= MDEV && - dev->source.subsys.u.mdev.ramfb =3D=3D VIR_TRISTATE_SWITCH_ON)= { - if (ramfbEnabled) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Only one vgpu device can have 'ramfb' en= abled")); - return -1; + if (dev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) { + virTristateSwitch *ramfbsetting =3D NULL; + if (dev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_T= YPE_MDEV) + ramfbsetting =3D &dev->source.subsys.u.mdev.ramfb; + else if (dev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUB= SYS_TYPE_PCI) + ramfbsetting =3D &dev->source.subsys.u.pci.ramfb; + if (ramfbsetting && *ramfbsetting =3D=3D VIR_TRISTATE_SWITCH_O= N) { + if (ramfbEnabled) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Only one vgpu device can have 'ramfb' enabled")= ); + return -1; + } + ramfbEnabled =3D true; } - ramfbEnabled =3D true; } } =20 diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index c992956280..f386e46fae 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -6267,6 +6267,7 @@ + =20 @@ -6386,6 +6387,19 @@ =20 + + + + + + + + + + + + + mdev @@ -6397,16 +6411,7 @@ vfio-ap - - - - - - - - - - + --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org