From nobody Fri May 10 21:18:24 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 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 Reviewed-by: Michal Privoznik --- 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 From nobody Fri May 10 21:18:24 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1710887245741976.0692661910929; Tue, 19 Mar 2024 15:27:25 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 967921B3B; Tue, 19 Mar 2024 18:27:24 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A49B61C89; Tue, 19 Mar 2024 18:26:09 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 076811A83; Tue, 19 Mar 2024 18:26:03 -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 EE80C1A86 for ; Tue, 19 Mar 2024 18:26:02 -0400 (EDT) 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-205-j2YcxyQLNleLrZ_mR9TUSA-1; Tue, 19 Mar 2024 18:26:01 -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 DB11A101A526 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 B590E492BD0 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: j2YcxyQLNleLrZ_mR9TUSA-1 From: Jonathon Jongsma To: devel@lists.libvirt.org Subject: [PATCH 2/2] qemu: enable display/ramfb for vfio pci hostdevs Date: Tue, 19 Mar 2024 17:25:55 -0500 Message-ID: <20240319222555.2086423-3-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: A3SD47EZR4WKVBHCZNYGSUIY7IPIASOO X-Message-ID-Hash: A3SD47EZR4WKVBHCZNYGSUIY7IPIASOO 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: 1710887246587100001 Implement display=3D"on" and ramfb=3D"on" for vfio PCI host devices in qemu. This enables passthrough PCI devices for display just like we did for mdevs. Resolves: https://issues.redhat.com/browse/RHEL-28808 Signed-off-by: Jonathon Jongsma Reviewed-by: Michal Privoznik --- src/qemu/qemu_command.c | 10 ++++- src/qemu/qemu_validate.c | 8 ++++ ...stdev-pci-display-ramfb.x86_64-latest.args | 33 ++++++++++++++ ...ostdev-pci-display-ramfb.x86_64-latest.xml | 44 +++++++++++++++++++ .../hostdev-pci-display-ramfb.xml | 33 ++++++++++++++ tests/qemuxmlconftest.c | 1 + 6 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxmlconfdata/hostdev-pci-display-ramfb.x86_64-= latest.args create mode 100644 tests/qemuxmlconfdata/hostdev-pci-display-ramfb.x86_64-= latest.xml create mode 100644 tests/qemuxmlconfdata/hostdev-pci-display-ramfb.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 2bb1b6a0e7..62df609884 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4735,10 +4735,16 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def, virDomainNetTeamingInfo *teaming; g_autofree char *host =3D virPCIDeviceAddressAsString(&pcisrc->addr); const char *failover_pair_id =3D NULL; + const char *driver =3D NULL; =20 /* caller has to assign proper passthrough driver name */ switch (pcisrc->driver.name) { case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO: + /* ramfb support requires the nohotplug variant */ + if (pcisrc->ramfb =3D=3D VIR_TRISTATE_SWITCH_ON) + driver =3D "vfio-pci-nohotplug"; + else + driver =3D "vfio-pci"; break; =20 case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_KVM: @@ -4762,11 +4768,13 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def, failover_pair_id =3D teaming->persistent; =20 if (virJSONValueObjectAdd(&props, - "s:driver", "vfio-pci", + "s:driver", driver, "s:host", host, "s:id", dev->info->alias, "p:bootindex", dev->info->effectiveBootIndex, "S:failover_pair_id", failover_pair_id, + "S:display", qemuOnOffAuto(pcisrc->display), + "B:ramfb", pcisrc->ramfb, NULL) < 0) return NULL; =20 diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 6a73d02050..edc7169a30 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2477,6 +2477,14 @@ qemuValidateDomainDeviceDefHostdev(const virDomainHo= stdevDef *hostdev, _("Write filtering of PCI device configurat= ion space is not supported by qemu")); return -1; } + + if (hostdev->source.subsys.u.pci.display =3D=3D VIR_TRISTATE_S= WITCH_ON) { + if (def->ngraphics =3D=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("graphics device is needed for attrib= ute value 'display=3Don' in ")); + return -1; + } + } break; =20 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST: diff --git a/tests/qemuxmlconfdata/hostdev-pci-display-ramfb.x86_64-latest.= args b/tests/qemuxmlconfdata/hostdev-pci-display-ramfb.x86_64-latest.args new file mode 100644 index 0000000000..6a3bfbe6fb --- /dev/null +++ b/tests/qemuxmlconfdata/hostdev-pci-display-ramfb.x86_64-latest.args @@ -0,0 +1,33 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest2 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest2/.local/share \ +XDG_CACHE_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest2/.cache \ +XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest2/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3DQEMUGuest2,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/va= r/lib/libvirt/qemu/domain--1-QEMUGuest2/master-key.aes"}' \ +-machine pc,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dpc.ram,acpi= =3Doff \ +-accel tcg \ +-cpu qemu64 \ +-m size=3D219136k \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}'= \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-boot strict=3Don \ +-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-vnc 127.0.0.1:0,audiodev=3Daudio1 \ +-device '{"driver":"vfio-pci-nohotplug","host":"0000:06:12.5","id":"hostde= v0","display":"on","ramfb":true,"bus":"pci.0","addr":"0x2"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxmlconfdata/hostdev-pci-display-ramfb.x86_64-latest.= xml b/tests/qemuxmlconfdata/hostdev-pci-display-ramfb.x86_64-latest.xml new file mode 100644 index 0000000000..16e8a1dee2 --- /dev/null +++ b/tests/qemuxmlconfdata/hostdev-pci-display-ramfb.x86_64-latest.xml @@ -0,0 +1,44 @@ + + QEMUGuest2 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + + +
+ + + + + + +