From nobody Sat Jul 5 00:48:24 2025
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 15301065388981020.301075080865;
Wed, 27 Jun 2018 06:35:38 -0700 (PDT)
Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com
[10.5.11.25])
(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id A887730BF569;
Wed, 27 Jun 2018 13:35:36 +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 537942010D76;
Wed, 27 Jun 2018 13:35:36 +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 F238018037F1;
Wed, 27 Jun 2018 13:35:35 +0000 (UTC)
Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com
[10.11.54.4])
by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP
id w5RDZ5P1001547 for ;
Wed, 27 Jun 2018 09:35:05 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 86B6A20180EB; Wed, 27 Jun 2018 13:35:05 +0000 (UTC)
Received: from beluga.usersys.redhat.com (unknown [10.43.2.166])
by smtp.corp.redhat.com (Postfix) with ESMTP id A65D92026D5B;
Wed, 27 Jun 2018 13:35:01 +0000 (UTC)
From: Erik Skultety
To: libvir-list@redhat.com
Date: Wed, 27 Jun 2018 15:34:45 +0200
Message-Id:
In-Reply-To:
References:
In-Reply-To:
References:
X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4
X-loop: libvir-list@redhat.com
Cc: Erik Skultety
Subject: [libvirt] [PATCH v1 08/11] conf: Introduce new attribute
'native' for SPICE
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.25
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]);
Wed, 27 Jun 2018 13:35:38 +0000 (UTC)
X-ZohoMail: RSF_0 Z_629925259 SPT_0
Content-Type: text/plain; charset="utf-8"
Since QEMU 2.10, there's a new cmdline option '-display egl-headless'
which enables OpenGL support for cases where we can't render on a local
display (i.e. is set to either 'address' or 'network').
This is to work around the current restriction on the local node with
native OpenGL SPICE support. However, compared to native support,
egl-headless has overhead, because the rendered framebuffer has to be
copied back to QEMU's display area which is then accessed by either
SPICE or VNC and sent to the remote side.
This patch enables this configuration feature by introducing a new
SPICE-only attribute 'native' which helps libvirt to determine whether
to use '-spice gl=3Don' or '-display egl-headless' on the cmdline. If the
attribute wasn't specified but OpenGL is to be enabled, then given the
nature of the element, libvirt will determine the default
value.
Signed-off-by: Erik Skultety
---
docs/formatdomain.html.in | 8 ++++
docs/schemas/domaincommon.rng | 16 +++++--
src/conf/domain_conf.c | 49 ++++++++++++++++++=
++--
src/conf/domain_conf.h | 1 +
src/qemu/qemu_command.c | 43 ++++++++++++-------
.../qemuxml2argvdata/graphics-spice-gl-native.args | 26 ++++++++++++
.../qemuxml2argvdata/graphics-spice-gl-native.xml | 25 +++++++++++
.../graphics-spice-gl-non-native.args | 27 ++++++++++++
.../graphics-spice-gl-non-native.xml | 24 +++++++++++
tests/qemuxml2argvtest.c | 8 ++++
.../video-virtio-gpu-spice-gl.xml | 2 +-
11 files changed, 206 insertions(+), 23 deletions(-)
create mode 100644 tests/qemuxml2argvdata/graphics-spice-gl-native.args
create mode 100644 tests/qemuxml2argvdata/graphics-spice-gl-native.xml
create mode 100644 tests/qemuxml2argvdata/graphics-spice-gl-non-native.args
create mode 100644 tests/qemuxml2argvdata/graphics-spice-gl-non-native.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index aa0d6b26df..c6ebd39bd9 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -6461,6 +6461,14 @@ qemu-kvm -net nic,model=3D? /dev/null
You can enable or disable OpenGL support explicitly with
the gl element, by setting the enable
property. (QEMU only, since 1.3.3).
+ Additionally, attribute native
+ (Since 4.6.0) can be used to sp=
ecify
+ whether native OpenGL support should be used with SPICE or
+ egl-headless should be used instead. Note that the native Op=
enGL
+ support is only limited to the local setup (listen is
+ either 'none' or 'socket') and for remote access egl-headless
+ needs to be used. The supported values for this attribute ar=
e 'on'
+ and 'off'.
By default, QEMU will pick the first available GPU DRM rende=
r node.
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 20649c5f6f..4ad53d976b 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3066,6 +3066,11 @@
+
+
+
+
+
@@ -3322,9 +3327,14 @@
-
-
-
+
+
+
+
+
+
+
+
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 2ccd9e124f..6d399a198e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4280,6 +4280,7 @@ virDomainDefPostParseGraphics(virDomainDef *def)
* same. */
if (graphics->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
virDomainGraphicsListenDefPtr glisten =3D &graphics->listens[0=
];
+ virDomainGraphicsGLDefPtr gl =3D graphics->gl;
=20
if (glisten->type =3D=3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRE=
SS &&
graphics->data.spice.port =3D=3D 0 &&
@@ -4288,6 +4289,28 @@ virDomainDefPostParseGraphics(virDomainDef *def)
VIR_FREE(glisten->address);
glisten->type =3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE;
}
+
+ /* Next we need to figure out how to properly configure the Op=
enGL
+ * if that is enabled and the 'native' attribute is missing.
+ * The cases are:
+ * 1) Listen type is either 'socket' or 'none' - SPICE na=
tive
+ * OpenGL support (,gl=3Don) should be used because we're
+ * rendering on a local display.
+ *
+ * 2) Listen is either network or address - SPICE can't u=
se
+ * the native OpenGL support remotely yet, so we use
+ * native=3D'no' and format '-display egl-headless' onto =
the
+ * cmdline.
+ */
+ if (graphics->gl &&
+ graphics->gl->enable =3D=3D VIR_TRISTATE_BOOL_YES &&
+ graphics->gl->native =3D=3D VIR_TRISTATE_BOOL_ABSENT) {
+ gl->native =3D VIR_TRISTATE_BOOL_NO;
+
+ if (glisten->type =3D=3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_N=
ONE ||
+ glisten->type =3D=3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_S=
OCKET)
+ gl->native =3D VIR_TRISTATE_BOOL_YES;
+ }
}
}
}
@@ -13573,6 +13596,7 @@ virDomainGraphicsGLDefParseXML(virDomainGraphicsDef=
Ptr def,
{
virDomainGraphicsGLDefPtr gl =3D NULL;
char *enable =3D NULL;
+ char *native =3D NULL;
int ret =3D -1;
=20
if (!node)
@@ -13596,14 +13620,26 @@ virDomainGraphicsGLDefParseXML(virDomainGraphicsD=
efPtr def,
goto cleanup;
}
=20
- if (def->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_SPICE)
- gl->rendernode =3D virXMLPropString(node, "rendernode");
+ /* SPICE recognizes a few more attributes */
+ if (def->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
+ gl->rendernode =3D virXMLPropString(node, "rendernode");
+
+ native =3D virXMLPropString(node, "native");
+ if (native &&
+ (gl->native =3D virTristateBoolTypeFromString(native)) <=3D 0)=
{
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown value for attribute enable '%s'"),
+ enable);
+ goto cleanup;
+ }
+ }
=20
VIR_STEAL_PTR(def->gl, gl);
=20
ret =3D 0;
cleanup:
VIR_FREE(enable);
+ VIR_FREE(native);
virDomainGraphicsGLDefFree(gl);
return ret;
}
@@ -26184,8 +26220,13 @@ virDomainGraphicsGLDefFormat(virBufferPtr buf, vir=
DomainGraphicsDefPtr def)
virBufferAsprintf(buf, "enable));
=20
- if (def->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_SPICE)
- virBufferEscapeString(buf, " rendernode=3D'%s'", gl->rendernode);
+ if (gl->enable =3D=3D VIR_TRISTATE_BOOL_YES) {
+ if (def->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
+ virBufferAsprintf(buf, " native=3D'%s'",
+ virTristateBoolTypeToString(gl->native));
+ virBufferEscapeString(buf, " rendernode=3D'%s'", gl->rendernod=
e);
+ }
+ }
=20
virBufferAddLit(buf, "/>\n");
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 20dc1334c4..99b5896391 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1602,6 +1602,7 @@ typedef struct _virDomainGraphicsGLDef virDomainGraph=
icsGLDef;
typedef virDomainGraphicsGLDef *virDomainGraphicsGLDefPtr;
struct _virDomainGraphicsGLDef {
virTristateBool enable;
+ virTristateBool native; /* -spice gl=3Don vs -display egl-headless for=
QEMU */
char *rendernode; /* SPICE only */
};
=20
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 89a8408df6..fc80a6c3a6 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7896,27 +7896,39 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfig=
Ptr cfg,
=20
static int
qemuBuildGraphicsSPICEGLCommandLine(virDomainGraphicsGLDefPtr gl,
+ virCommandPtr cmd,
virBufferPtr opt,
virQEMUCapsPtr qemuCaps)
{
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE_GL)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("This QEMU doesn't support spice OpenGL"));
- return -1;
- }
-
- virBufferAddLit(opt, "gl=3Don,");
-
- if (gl->rendernode) {
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE_RENDERNODE)) {
+ if (gl->native =3D=3D VIR_TRISTATE_BOOL_NO) {
+ /* For non-native OpenGL, we need to add egl-headless to the cmdli=
ne.
+ *
+ * NB: QEMU defaults to '-spice gl=3Doff', so we don't have to add=
that
+ * explicitly, especially since we're not testing for GL capability
+ * presence.
+ */
+ virCommandAddArg(cmd, "-display");
+ virCommandAddArg(cmd, "egl-headless");
+ } else {
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE_GL)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("This QEMU doesn't support spice OpenGL rende=
rnode"));
+ _("This QEMU doesn't support spice OpenGL"));
return -1;
}
=20
- virBufferAddLit(opt, "rendernode=3D");
- virQEMUBuildBufferEscapeComma(opt, gl->rendernode);
- virBufferAddLit(opt, ",");
+ virBufferAddLit(opt, "gl=3Don,");
+
+ if (gl->rendernode) {
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE_RENDERNODE)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("This QEMU doesn't support spice OpenGL r=
endernode"));
+ return -1;
+ }
+
+ virBufferAddLit(opt, "rendernode=3D");
+ virQEMUBuildBufferEscapeComma(opt, gl->rendernode);
+ virBufferAddLit(opt, ",");
+ }
}
=20
return 0;
@@ -8137,7 +8149,8 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfig=
Ptr cfg,
/* OpenGL magic */
if (graphics->gl &&
graphics->gl->enable =3D=3D VIR_TRISTATE_BOOL_YES &&
- qemuBuildGraphicsSPICEGLCommandLine(graphics->gl, &opt, qemuCaps) =
< 0)
+ qemuBuildGraphicsSPICEGLCommandLine(graphics->gl, cmd,
+ &opt, qemuCaps) < 0)
goto error;
=20
virBufferTrim(&opt, ",", -1);
diff --git a/tests/qemuxml2argvdata/graphics-spice-gl-native.args b/tests/q=
emuxml2argvdata/graphics-spice-gl-native.args
new file mode 100644
index 0000000000..70d6694022
--- /dev/null
+++ b/tests/qemuxml2argvdata/graphics-spice-gl-native.args
@@ -0,0 +1,26 @@
+LC_ALL=3DC \
+PATH=3D/bin \
+HOME=3D/home/test \
+USER=3Dtest \
+LOGNAME=3Dtest \
+QEMU_AUDIO_DRV=3Dspice \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-machine pc,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \
+-m 214 \
+-smp 1,sockets=3D1,cores=3D1,threads=3D1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni=
tor.sock,\
+server,nowait \
+-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \
+-rtc base=3Dutc \
+-no-shutdown \
+-no-acpi \
+-boot c \
+-usb \
+-spice port=3D0,gl=3Don,rendernode=3D/dev/dri/foo \
+-vga cirrus \
+-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3
diff --git a/tests/qemuxml2argvdata/graphics-spice-gl-native.xml b/tests/qe=
muxml2argvdata/graphics-spice-gl-native.xml
new file mode 100644
index 0000000000..abfe628a9c
--- /dev/null
+++ b/tests/qemuxml2argvdata/graphics-spice-gl-native.xml
@@ -0,0 +1,25 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219136
+ 219136
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu-system-i686
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvdata/graphics-spice-gl-non-native.args b/tes=
ts/qemuxml2argvdata/graphics-spice-gl-non-native.args
new file mode 100644
index 0000000000..9833cd6c0f
--- /dev/null
+++ b/tests/qemuxml2argvdata/graphics-spice-gl-non-native.args
@@ -0,0 +1,27 @@
+LC_ALL=3DC \
+PATH=3D/bin \
+HOME=3D/home/test \
+USER=3Dtest \
+LOGNAME=3Dtest \
+QEMU_AUDIO_DRV=3Dspice \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-machine pc,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \
+-m 214 \
+-smp 1,sockets=3D1,cores=3D1,threads=3D1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni=
tor.sock,\
+server,nowait \
+-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \
+-rtc base=3Dutc \
+-no-shutdown \
+-no-acpi \
+-boot c \
+-usb \
+-display egl-headless \
+-spice port=3D0 \
+-vga cirrus \
+-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3
diff --git a/tests/qemuxml2argvdata/graphics-spice-gl-non-native.xml b/test=
s/qemuxml2argvdata/graphics-spice-gl-non-native.xml
new file mode 100644
index 0000000000..003f2406ac
--- /dev/null
+++ b/tests/qemuxml2argvdata/graphics-spice-gl-non-native.xml
@@ -0,0 +1,24 @@
+
+ QEMUGuest1
+ 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 c310349b57..e82496d403 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1256,6 +1256,14 @@ mymain(void)
QEMU_CAPS_SPICE_UNIX,
QEMU_CAPS_DEVICE_CIRRUS_VGA);
driver.config->spiceAutoUnixSocket =3D false;
+ DO_TEST("graphics-spice-gl-native",
+ QEMU_CAPS_SPICE,
+ QEMU_CAPS_SPICE_GL,
+ QEMU_CAPS_SPICE_RENDERNODE,
+ QEMU_CAPS_DEVICE_CIRRUS_VGA);
+ DO_TEST("graphics-spice-gl-non-native",
+ QEMU_CAPS_SPICE,
+ QEMU_CAPS_DEVICE_CIRRUS_VGA);
=20
DO_TEST("input-usbmouse", NONE);
DO_TEST("input-usbtablet", NONE);
diff --git a/tests/qemuxml2xmloutdata/video-virtio-gpu-spice-gl.xml b/tests=
/qemuxml2xmloutdata/video-virtio-gpu-spice-gl.xml
index 720d362230..578341e09b 100644
--- a/tests/qemuxml2xmloutdata/video-virtio-gpu-spice-gl.xml
+++ b/tests/qemuxml2xmloutdata/video-virtio-gpu-spice-gl.xml
@@ -31,7 +31,7 @@
-
+