From nobody Mon Feb 9 21:37:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1571412636; cv=none; d=zoho.com; s=zohoarc; b=iKSuUdFWhvCNKigZgI9uHLjpUA8tSxSO/nm5E+zcUT/N/rgaKEhJe0RIDsugfDl/uOtKiZKOh73lNZBmHWK/ViSFn0/tl/ZxLua8k+c5msQ9ftUvh7xK6R9tjzc7LANPgVeCKNvAWVKIStQ9zzrTbxfdTlzZL/14i/+AKmXWBmc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571412636; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QvF9r4WSbSolT03Groj+YBQepGQHb2fgwirPyP+mgqE=; b=QQY8q8Rdwb+p4yttWUNGLBQg0lIrwLgKV7BoPOdx8DTqOX4adiJOqIfCWwXmD345OqvxdrwqBmEpBHW1l7dtW7dB2Q9ccel+avWfHhIH1ojzchHoELJO9qedCfJgmT0dMYJyVExDdlhIEFgONQxSg0fHFHD8/FtOqn2IqCUVBnU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1571412636107550.2765030731073; Fri, 18 Oct 2019 08:30:36 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 53A2E65F2D; Fri, 18 Oct 2019 15:30:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1544479A0; Fri, 18 Oct 2019 15:30:34 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C2FA71803517; Fri, 18 Oct 2019 15:30:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IFUOZr001414 for ; Fri, 18 Oct 2019 11:30:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4DECC5D71C; Fri, 18 Oct 2019 15:30:24 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-116-193.phx2.redhat.com [10.3.116.193]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 110765D70E; Fri, 18 Oct 2019 15:30:23 +0000 (UTC) From: Jonathon Jongsma To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 10:30:17 -0500 Message-Id: <20191018153017.4819-10-jjongsma@redhat.com> In-Reply-To: <20191018153017.4819-1-jjongsma@redhat.com> References: <20191018153017.4819-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: crobinso@redhat.com Subject: [libvirt] [PATCH v3 9/9] qemu: add 'ramfb' attribute for mediated devices X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 18 Oct 2019 15:30:34 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The 'ramfb' attribute provides a framebuffer to the guest that can be used as a boot display for the vgpu For example, the following configuration can be used to provide a vgpu with a boot display:
Signed-off-by: Jonathon Jongsma --- docs/formatdomain.html.in | 8 ++++ docs/schemas/domaincommon.rng | 5 +++ src/conf/domain_conf.c | 11 ++++++ src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 17 ++++++++- ...tdev-mdev-display-ramfb.x86_64-latest.args | 37 +++++++++++++++++++ .../hostdev-mdev-display-ramfb.xml | 33 +++++++++++++++++ tests/qemuxml2argvtest.c | 1 + 8 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.x86_6= 4-latest.args create mode 100644 tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 500f114f41..50f9ff9618 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4847,6 +4847,14 @@ graphical framebuffer in order= to use this attribute, currently only supported with VNC, Spice and egl-headless graphics devices. + + Since version 5.9.0, there is an op= tional + ramfb attribute for devices with + model=3D'vfio-pci'. Supported values are either + on or off (default is 'off'). When + enabled, this attribute provides a memory framebuffer device to = the + guest. This framebuffer will be used as a boot display when a v= gpu + device is the primary display.

Note: There are also some implications on the usage of guest's address type depending on the model attribute, diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index ead5a25068..57e0dcf6ed 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4769,6 +4769,11 @@ vfio-ap + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2e6a113de3..ab75f13eec 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8130,6 +8130,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, g_autofree char *backendStr =3D NULL; g_autofree char *model =3D NULL; g_autofree char *display =3D NULL; + g_autofree char *ramfb =3D NULL; =20 /* @managed can be read from the xml document - it is always an * attribute of the toplevel element, no matter what type of @@ -8145,6 +8146,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, rawio =3D virXMLPropString(node, "rawio"); model =3D virXMLPropString(node, "model"); display =3D virXMLPropString(node, "display"); + ramfb =3D virXMLPropString(node, "ramfb"); =20 /* @type is passed in from the caller rather than read from the * xml document, because it is specified in different places for @@ -8253,6 +8255,15 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, display); return -1; } + + if (ramfb && + (mdevsrc->ramfb =3D virTristateSwitchTypeFromString(ramfb)) <= =3D 0) { + virReportError(VIR_ERR_XML_ERROR, + _("unknown value '%s' for attribute " + "'ramfb'"), + ramfb); + return -1; + } } =20 switch (def->source.subsys.type) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index edac6250e4..72b2a8c482 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -262,6 +262,7 @@ struct _virDomainHostdevSubsysMediatedDev { int model; /* enum virMediatedDeviceModelType= */ int display; /* virTristateSwitch */ char uuidstr[VIR_UUID_STRING_BUFLEN]; /* mediated device's uuid stri= ng */ + int ramfb; /* virTristateSwitch */ }; =20 typedef enum { diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e98195b1d7..1a2d0c173d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5416,6 +5416,17 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager, return virBufferContentAndReset(&buf); } =20 +static const char * +qemuBuildHostdevMdevModelTypeString(virDomainHostdevSubsysMediatedDevPtr m= dev) +{ + /* when the 'ramfb' attribute is set, we must use the nohotplug variant + * rather than 'vfio-pci' */ + if (mdev->model =3D=3D VIR_MDEV_MODEL_TYPE_VFIO_PCI && + mdev->ramfb =3D=3D VIR_TRISTATE_SWITCH_ON) + return "vfio-pci-nohotplug"; + + return virMediatedDeviceModelTypeToString(mdev->model); +} =20 char * qemuBuildHostdevMediatedDevStr(const virDomainDef *def, @@ -5430,7 +5441,7 @@ qemuBuildHostdevMediatedDevStr(const virDomainDef *de= f, if (!(mdevPath =3D virMediatedDeviceGetSysfsPath(mdevsrc->uuidstr))) return NULL; =20 - dev_str =3D virMediatedDeviceModelTypeToString(mdevsrc->model); + dev_str =3D qemuBuildHostdevMdevModelTypeString(mdevsrc); =20 if (!dev_str) return NULL; @@ -5448,6 +5459,10 @@ qemuBuildHostdevMediatedDevStr(const virDomainDef *d= ef, if (dev->info->bootIndex) virBufferAsprintf(&buf, ",bootindex=3D%u", dev->info->bootIndex); =20 + if (mdevsrc->ramfb =3D=3D VIR_TRISTATE_SWITCH_ON) + virBufferAsprintf(&buf, ",ramfb=3D%s", + virTristateSwitchTypeToString(mdevsrc->ramfb)); + if (virBufferCheckError(&buf) < 0) return NULL; =20 diff --git a/tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.x86_64-lates= t.args b/tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.x86_64-latest.ar= gs new file mode 100644 index 0000000000..30d2f83318 --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.x86_64-latest.args @@ -0,0 +1,37 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-QEMUGuest2 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-QEMUGuest2/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-QEMUGuest2/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest2/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-i686 \ +-name guest=3DQEMUGuest2,debug-threads=3Don \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,\ +file=3D/tmp/lib/domain--1-QEMUGuest2/master-key.aes \ +-machine pc,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \ +-m 214 \ +-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,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot strict=3Don \ +-device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ +-vnc 127.0.0.1:0 \ +-device qxl-vga,id=3Dvideo0,ram_size=3D67108864,vram_size=3D67108864,\ +vram64_size_mb=3D0,vgamem_mb=3D16,max_outputs=3D1,bus=3Dpci.0,addr=3D0x2 \ +-device vfio-pci-nohotplug,id=3Dhostdev0,\ +sysfsdev=3D/sys/bus/mdev/devices/53764d0e-85a0-42b4-af5c-2046b460b1dc,disp= lay=3Don,\ +bus=3Dpci.0,addr=3D0x3,ramfb=3Don \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ +resourcecontrol=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.xml b/tests/= qemuxml2argvdata/hostdev-mdev-display-ramfb.xml new file mode 100644 index 0000000000..2e7851b2b0 --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.xml @@ -0,0 +1,33 @@ + + QEMUGuest2 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + + +

+ + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 7c314050f6..56fb6f00a9 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1638,6 +1638,7 @@ mymain(void) DO_TEST_PARSE_ERROR("hostdev-mdev-display-missing-graphics", QEMU_CAPS_DEVICE_VFIO_PCI, QEMU_CAPS_VFIO_PCI_DISPLAY); + DO_TEST_CAPS_LATEST("hostdev-mdev-display-ramfb"); DO_TEST_PARSE_ERROR("hostdev-vfio-zpci-wrong-arch", QEMU_CAPS_DEVICE_VFIO_PCI); DO_TEST("hostdev-vfio-zpci", --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list