From nobody Sat Feb 7 06:45:07 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 1527687812317187.61085208885834; Wed, 30 May 2018 06:43:32 -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 CFF1031168E9; Wed, 30 May 2018 13:43:30 +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 9911116D41; Wed, 30 May 2018 13:43:30 +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 482614BB78; Wed, 30 May 2018 13:43:30 +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 w4UDhDBB006612 for ; Wed, 30 May 2018 09:43:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3BC4710EE6C4; Wed, 30 May 2018 13:43:13 +0000 (UTC) Received: from beluga.usersys.redhat.com (unknown [10.43.2.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 97ED410EE6C1; Wed, 30 May 2018 13:43:12 +0000 (UTC) From: Erik Skultety To: libvir-list@redhat.com Date: Wed, 30 May 2018 15:42:58 +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] [RFC PATCH 4/7] 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 30 May 2018 13:43:31 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" QEMU introduced a new type of display for mediated devices using vfio-pci backend which controls whether a mediated device can be used as a native rendering device as an alternative to an emulated video device. This patch adds the necessary bits to domain config handling in order to expose this feature. It's worth noting that even though QEMU supports and defaults to the value 'auto', this patch only introduces values 'on' and 'off' defaulting to 'off' (for safety), since there's no convenient way for libvirt to come up with relevant defaults based on the fact, that libvirt doesn't know whether the underlying device uses dma-buf or vfio region mapping. Signed-off-by: Erik Skultety --- docs/formatdomain.html.in | 16 ++++++-- docs/schemas/domaincommon.rng | 5 +++ src/conf/domain_conf.c | 18 +++++++- src/conf/domain_conf.h | 1 + src/qemu/qemu_domain.c | 43 +++++++++++++++++++ .../hostdev-mdev-display-missing-graphics.xml | 35 ++++++++++++++++ .../hostdev-mdev-display-spice-no-opengl.xml | 41 ++++++++++++++++++ .../hostdev-mdev-display-spice-opengl.xml | 41 ++++++++++++++++++ .../qemuxml2argvdata/hostdev-mdev-display-vnc.xml | 39 ++++++++++++++++++ .../hostdev-mdev-display-spice-no-opengl.xml | 47 ++++++++++++++++++= +++ .../hostdev-mdev-display-spice-opengl.xml | 48 ++++++++++++++++++= ++++ .../hostdev-mdev-display-vnc.xml | 47 ++++++++++++++++++= +++ tests/qemuxml2xmltest.c | 3 ++ 13 files changed, 380 insertions(+), 4 deletions(-) create mode 100644 tests/qemuxml2argvdata/hostdev-mdev-display-missing-gra= phics.xml create mode 100644 tests/qemuxml2argvdata/hostdev-mdev-display-spice-no-op= engl.xml create mode 100644 tests/qemuxml2argvdata/hostdev-mdev-display-spice-openg= l.xml create mode 100644 tests/qemuxml2argvdata/hostdev-mdev-display-vnc.xml create mode 100644 tests/qemuxml2xmloutdata/hostdev-mdev-display-spice-no-= opengl.xml create mode 100644 tests/qemuxml2xmloutdata/hostdev-mdev-display-spice-ope= ngl.xml create mode 100644 tests/qemuxml2xmloutdata/hostdev-mdev-display-vnc.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index b5a6e33bfe..deecc3166a 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4437,9 +4437,19 @@ 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.4.0 (QEMU 2.12) libvirt add= ed + a new optional display attribute to enable or disab= le + 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'). +

+ 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 703a1bb6f8..345bd3c757 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4507,6 +4507,11 @@ vfio-ccw + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c868d8de08..7844b6d272 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7606,6 +7606,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; @@ -7625,6 +7626,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 @@ -7712,6 +7714,15 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, model); goto error; } + + if (display && + (mdevsrc->display =3D virTristateSwitchTypeFromString(display)= ) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("unknown value '%s' for attribute " + "'display'"), + display); + goto error; + } } =20 switch (def->source.subsys.type) { @@ -26297,9 +26308,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) + 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 8493dfdd76..123a676ab9 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; /* virTristateSwitchType */ 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 2c51e4c0d8..27088d4456 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4277,10 +4277,35 @@ qemuDomainDeviceDefValidateNetwork(const virDomainN= etDef *net) } =20 =20 +static int +qemuDomainDeviceDefValidateHostdevMdev(const virDomainHostdevSubsysMediate= dDev *mdevsrc, + const virDomainDef *def) +{ + if (mdevsrc->display) { + if (mdevsrc->model !=3D VIR_MDEV_MODEL_TYPE_VFIO_PCI) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _(" attribute 'display' is only suppor= ted" + " with model=3D'vfio-pci'")); + + return -1; + } else 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; + } + } + + 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, @@ -4290,6 +4315,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 qemuDomainDeviceDefValidateHostdevMdev(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-missing-graphics.x= ml b/tests/qemuxml2argvdata/hostdev-mdev-display-missing-graphics.xml new file mode 100644 index 0000000000..ea559a6444 --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-mdev-display-missing-graphics.xml @@ -0,0 +1,35 @@ + + QEMUGuest2 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + +

+ + + + + + + + +
+ + + + + diff --git a/tests/qemuxml2argvdata/hostdev-mdev-display-spice-no-opengl.xm= l b/tests/qemuxml2argvdata/hostdev-mdev-display-spice-no-opengl.xml new file mode 100644 index 0000000000..64a9d7b70c --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-mdev-display-spice-no-opengl.xml @@ -0,0 +1,41 @@ + + QEMUGuest2 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + +
+ + + + + + + + + + + +
+ + + + + + diff --git a/tests/qemuxml2argvdata/hostdev-mdev-display-spice-opengl.xml b= /tests/qemuxml2argvdata/hostdev-mdev-display-spice-opengl.xml new file mode 100644 index 0000000000..b7f2fdf63e --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-mdev-display-spice-opengl.xml @@ -0,0 +1,41 @@ + + QEMUGuest2 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + +
+ + + + + + + + + + + +
+ + + + + + diff --git a/tests/qemuxml2argvdata/hostdev-mdev-display-vnc.xml b/tests/qe= muxml2argvdata/hostdev-mdev-display-vnc.xml new file mode 100644 index 0000000000..f37e08e1b9 --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-mdev-display-vnc.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-spice-no-opengl.= xml b/tests/qemuxml2xmloutdata/hostdev-mdev-display-spice-no-opengl.xml new file mode 100644 index 0000000000..ce56724629 --- /dev/null +++ b/tests/qemuxml2xmloutdata/hostdev-mdev-display-spice-no-opengl.xml @@ -0,0 +1,47 @@ + + QEMUGuest2 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + +
+ + +
+ + + +
+ + + + + + +