From nobody Sun Feb 8 12:20:32 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1531317545944738.8262891046153; Wed, 11 Jul 2018 06:59:05 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 72AD230832EB; Wed, 11 Jul 2018 13:59:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3544C308BDB2; Wed, 11 Jul 2018 13:59:02 +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 C5D114A46E; Wed, 11 Jul 2018 13:59:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6BDwgex015216 for ; Wed, 11 Jul 2018 09:58:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id ACF0A10FFE4E; Wed, 11 Jul 2018 13:58:42 +0000 (UTC) Received: from beluga.usersys.redhat.com (unknown [10.43.2.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DFBC10FFE4C; Wed, 11 Jul 2018 13:58:42 +0000 (UTC) From: Erik Skultety To: libvir-list@redhat.com Date: Wed, 11 Jul 2018 15:58:26 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH v3 6/8] conf: Introduce new attribute 'display' 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: , MIME-Version: 1.0 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.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 11 Jul 2018 13:59:05 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" QEMU 2.12 introduced a new type of display for mediated devices using vfio-pci backend which allows a mediated device to be used as a VGA compatible device as an alternative to an emulated video device. QEMU exposes this feature via a vfio device property 'display' with supported values 'on/off/auto' (default is 'off'). This patch adds the necessary bits to domain config handling in order to expose this feature. Since there's no convenient way for libvirt to come up with usable defaults for the display setting, simply because libvirt is not able to figure out which of the display implementations - dma-buf which requires OpenGL support vs vfio regions which doesn't need OpenGL (works with OpenGL enabled too) - the underlying mdev uses. Signed-off-by: Erik Skultety Reviewed-by: J=EF=BF=BDn Tomko --- docs/formatdomain.html.in | 20 ++++++-- docs/schemas/domaincommon.rng | 5 ++ src/conf/domain_conf.c | 19 +++++++- src/conf/domain_conf.h | 1 + src/qemu/qemu_domain.c | 55 ++++++++++++++++++= ++++ tests/qemuxml2argvdata/hostdev-mdev-display.xml | 39 +++++++++++++++ .../hostdev-mdev-display-active.xml | 47 ++++++++++++++++++ tests/qemuxml2xmltest.c | 2 + 8 files changed, 184 insertions(+), 4 deletions(-) create mode 100644 tests/qemuxml2argvdata/hostdev-mdev-display.xml create mode 100644 tests/qemuxml2xmloutdata/hostdev-mdev-display-active.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 9dd22554ad..3554c3dc30 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4510,9 +4510,23 @@ guest. Currently, model=3D'vfio-pci' and model=3D'vfio-ccw' (Since 4.4= .0) is supported. Refer MDEV to= create - a mediated device on the host. There are also some implications = on the - usage of guest's address type depending on the model - attribute, see the address element below. + a mediated device on the host. + Since 4.6.0 (QEMU 2.12) an optional + display attribute may be used to enable or disable + support for an accelerated remote desktop backed by a mediated + device (such as NVIDIA vGPU or Intel GVT-g) as an alternative to + emulated video devices. This attr= ibute + is limited to model=3D'vfio-pci' only. Supported va= lues + are either on or off (default is 'off'= ). + It is required to use a + graphical framebuffer in order= to + use this attribute, currently only supported with VNC, Spice and + egl-headless graphics devices. +

+ Note: There are also some implications on the usage of guest's + address type depending on the model attribute, + see the address element below. +

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 8f7d273d9f..b8ec9c758a 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4576,6 +4576,11 @@ vfio-ccw + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8deff5442f..bd1dc0780d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7646,6 +7646,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, char *rawio =3D NULL; char *backendStr =3D NULL; char *model =3D NULL; + char *display =3D NULL; int backend; int ret =3D -1; virDomainHostdevSubsysPCIPtr pcisrc =3D &def->source.subsys.u.pci; @@ -7665,6 +7666,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, sgio =3D virXMLPropString(node, "sgio"); rawio =3D virXMLPropString(node, "rawio"); model =3D virXMLPropString(node, "model"); + display =3D virXMLPropString(node, "display"); =20 /* @type is passed in from the caller rather than read from the * xml document, because it is specified in different places for @@ -7752,6 +7754,15 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, model); goto cleanup; } + + if (display && + (mdevsrc->display =3D virTristateSwitchTypeFromString(display)= ) <=3D 0) { + virReportError(VIR_ERR_XML_ERROR, + _("unknown value '%s' for attribute " + "'display'"), + display); + goto cleanup; + } } =20 switch (def->source.subsys.type) { @@ -7805,6 +7816,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, VIR_FREE(rawio); VIR_FREE(backendStr); VIR_FREE(model); + VIR_FREE(display); return ret; } =20 @@ -26558,9 +26570,14 @@ virDomainHostdevDefFormat(virBufferPtr buf, virTristateBoolTypeToString(scsisrc->rawio)); } =20 - if (def->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_= MDEV) + if (def->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_= MDEV) { virBufferAsprintf(buf, " model=3D'%s'", virMediatedDeviceModelTypeToString(mdevsrc->= model)); + if (mdevsrc->display !=3D VIR_TRISTATE_SWITCH_ABSENT) + virBufferAsprintf(buf, " display=3D'%s'", + virTristateSwitchTypeToString(mdevsrc->d= isplay)); + } + } virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 3deda1d978..8ca9558ceb 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -382,6 +382,7 @@ typedef struct _virDomainHostdevSubsysMediatedDev virDo= mainHostdevSubsysMediated typedef virDomainHostdevSubsysMediatedDev *virDomainHostdevSubsysMediatedD= evPtr; struct _virDomainHostdevSubsysMediatedDev { int model; /* enum virMediatedDeviceModelType= */ + int display; /* virTristateSwitch */ char uuidstr[VIR_UUID_STRING_BUFLEN]; /* mediated device's uuid stri= ng */ }; =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 5da8c8bfcc..a03b1fb029 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4450,10 +4450,47 @@ qemuDomainDeviceDefValidateNetwork(const virDomainN= etDef *net) } =20 =20 +static int +qemuDomainMdevDefValidate(const virDomainHostdevSubsysMediatedDev *mdevsrc, + const virDomainDef *def) +{ + if (mdevsrc->display !=3D VIR_TRISTATE_SWITCH_ABSENT && + mdevsrc->model !=3D VIR_MDEV_MODEL_TYPE_VFIO_PCI) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _(" attribute 'display' is only supported" + " with model=3D'vfio-pci'")); + + return -1; + } + + if (mdevsrc->display =3D=3D VIR_TRISTATE_SWITCH_ON) { + if (def->ngraphics =3D=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("graphics device is needed for attribute valu= e " + "'display=3Don' in ")); + return -1; + } + + /* We're not able to tell whether an mdev needs OpenGL or not at t= he + * moment, so print a warning that an extra element or + * ' might be necessary to be adde= d, + * depending on whether we're running with SPICE or VNC respective= ly. + */ + if (!virDomainGraphicsDefHasOpenGL(def)) + VIR_WARN(" attribute 'display' may need the OpenGL to= " + "be enabled"); + } + + return 0; +} + + static int qemuDomainDeviceDefValidateHostdev(const virDomainHostdevDef *hostdev, const virDomainDef *def) { + const virDomainHostdevSubsysMediatedDev *mdevsrc; + /* forbid capabilities mode hostdev in this kind of hypervisor */ if (hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -4463,6 +4500,24 @@ qemuDomainDeviceDefValidateHostdev(const virDomainHo= stdevDef *hostdev, return -1; } =20 + if (hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) { + switch ((virDomainHostdevSubsysType) hostdev->source.subsys.type) { + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST: + break; + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: + mdevsrc =3D &hostdev->source.subsys.u.mdev; + return qemuDomainMdevDefValidate(mdevsrc, def); + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST: + default: + virReportEnumRangeError(virDomainHostdevSubsysType, + hostdev->source.subsys.type); + return -1; + } + } + return 0; } =20 diff --git a/tests/qemuxml2argvdata/hostdev-mdev-display.xml b/tests/qemuxm= l2argvdata/hostdev-mdev-display.xml new file mode 100644 index 0000000000..f5b3575c04 --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-mdev-display.xml @@ -0,0 +1,39 @@ + + QEMUGuest2 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + +

+ + + + + + + + + +
+ + + + + + diff --git a/tests/qemuxml2xmloutdata/hostdev-mdev-display-active.xml b/tes= ts/qemuxml2xmloutdata/hostdev-mdev-display-active.xml new file mode 100644 index 0000000000..63a1a00278 --- /dev/null +++ b/tests/qemuxml2xmloutdata/hostdev-mdev-display-active.xml @@ -0,0 +1,47 @@ + + QEMUGuest2 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + +
+ + +
+ + + +
+ + + + + + +