[libvirt] [PATCH v1 07/11] conf: Allow usage of the <gl> element with VNC graphics

Erik Skultety eskultet at redhat.com
Wed Jun 27 13:34:44 UTC 2018


VNC doesn't support OpenGL natively, but can run with non-native
egl-headless support, so enable that.

Signed-off-by: Erik Skultety <eskultet at redhat.com>
---
 docs/formatdomain.html.in                          |  6 ++++
 docs/schemas/domaincommon.rng                      |  7 ++++
 src/conf/domain_conf.c                             |  8 +++++
 src/qemu/qemu_command.c                            |  7 ++++
 tests/qemuxml2argvdata/graphics-vnc-gl-invalid.xml | 37 ++++++++++++++++++++++
 tests/qemuxml2argvdata/graphics-vnc-gl.args        | 28 ++++++++++++++++
 tests/qemuxml2argvdata/graphics-vnc-gl.xml         | 37 ++++++++++++++++++++++
 tests/qemuxml2argvtest.c                           |  1 +
 8 files changed, 131 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/graphics-vnc-gl-invalid.xml
 create mode 100644 tests/qemuxml2argvdata/graphics-vnc-gl.args
 create mode 100644 tests/qemuxml2argvdata/graphics-vnc-gl.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 0d68596991..aa0d6b26df 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -6350,6 +6350,12 @@ qemu-kvm -net nic,model=? /dev/null
               auto-allocation and <code>autoport</code> having no effect due to
               security reasons) <span class="since">Since 1.0.6</span>.
             </p>
+            <p>
+              <span class="since">Since 4.6.0</span> it's possible to use the
+              <code>gl</code> element with <code>enable='yes'</code> to enable
+              OpenGL support using QEMU's egl-headless display, since VNC
+              doesn't support OpenGL natively like SPICE does.
+            </p>
           </dd>
           <dt><code>spice</code> <span class="since">Since 0.8.6</span></dt>
           <dd>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index f46145cf9b..20649c5f6f 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3135,6 +3135,13 @@
             </attribute>
           </optional>
           <ref name="listenElements"/>
+          <optional>
+            <element name="gl">
+              <attribute name="enable">
+                <ref name="virYesNo"/>
+              </attribute>
+            </element>
+          </optional>
         </group>
         <group>
           <attribute name="type">
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6bfa3ca130..2ccd9e124f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -13619,8 +13619,11 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDefPtr def,
     char *websocket = virXMLPropString(node, "websocket");
     char *sharePolicy = virXMLPropString(node, "sharePolicy");
     char *autoport = virXMLPropString(node, "autoport");
+    xmlNodePtr save = ctxt->node;
     int ret = -1;
 
+    ctxt->node = node;
+
     if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0)
         goto cleanup;
 
@@ -13681,12 +13684,17 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDefPtr def,
                                          def->type) < 0)
         goto cleanup;
 
+    if (virDomainGraphicsGLDefParseXML(def,
+                                       virXPathNode("./gl[1]", ctxt)) < 0)
+        goto cleanup;
+
     ret = 0;
  cleanup:
     VIR_FREE(port);
     VIR_FREE(autoport);
     VIR_FREE(websocket);
     VIR_FREE(sharePolicy);
+    ctxt->node = save;
     return ret;
 }
 
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index ef0be95b0f..89a8408df6 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7879,6 +7879,13 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
     else
         virCommandAddEnvString(cmd, "QEMU_AUDIO_DRV=none");
 
+    /* OpenGL support */
+    if (graphics->gl &&
+        graphics->gl->enable == VIR_TRISTATE_BOOL_YES) {
+        virCommandAddArg(cmd, "-display");
+        virCommandAddArg(cmd, "egl-headless");
+    }
+
     return 0;
 
  error:
diff --git a/tests/qemuxml2argvdata/graphics-vnc-gl-invalid.xml b/tests/qemuxml2argvdata/graphics-vnc-gl-invalid.xml
new file mode 100644
index 0000000000..0f34791046
--- /dev/null
+++ b/tests/qemuxml2argvdata/graphics-vnc-gl-invalid.xml
@@ -0,0 +1,37 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-i686</emulator>
+    <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='usb' index='0'/>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <graphics type='vnc' port='5903' autoport='no'>
+      <listen type='none'/>
+      <gl enable='yes' native='yes' rendernode='/dev/dri/foo'/>
+    </graphics>
+    <video>
+      <model type='cirrus' vram='16384' heads='1'/>
+    </video>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/graphics-vnc-gl.args b/tests/qemuxml2argvdata/graphics-vnc-gl.args
new file mode 100644
index 0000000000..2d2b3cf0fb
--- /dev/null
+++ b/tests/qemuxml2argvdata/graphics-vnc-gl.args
@@ -0,0 +1,28 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot c \
+-usb \
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
+-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
+-vnc '[2001:1:2:3:4:5:1234:1234]:3' \
+-display egl-headless \
+-vga cirrus
diff --git a/tests/qemuxml2argvdata/graphics-vnc-gl.xml b/tests/qemuxml2argvdata/graphics-vnc-gl.xml
new file mode 100644
index 0000000000..fea2caf843
--- /dev/null
+++ b/tests/qemuxml2argvdata/graphics-vnc-gl.xml
@@ -0,0 +1,37 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-i686</emulator>
+    <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='usb' index='0'/>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <graphics type='vnc' port='5903' autoport='no' listen='2001:1:2:3:4:5:1234:1234'>
+      <listen type='address' address='2001:1:2:3:4:5:1234:1234'/>
+      <gl enable='yes'/>
+    </graphics>
+    <video>
+      <model type='cirrus' vram='16384' heads='1'/>
+    </video>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index c279ac4975..c310349b57 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1187,6 +1187,7 @@ mymain(void)
     DO_TEST("graphics-vnc-none", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
     DO_TEST("graphics-vnc-socket-new-cmdline", QEMU_CAPS_VNC,
             QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_VNC_MULTI_SERVERS);
+    DO_TEST("graphics-vnc-gl", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
 
     driver.config->vncSASL = 1;
     VIR_FREE(driver.config->vncSASLdir);
-- 
2.14.4




More information about the libvir-list mailing list