0a7476
From 5738081ba1c0cb6453224ccd1281e5a536284a4c Mon Sep 17 00:00:00 2001
0a7476
Message-Id: <5738081ba1c0cb6453224ccd1281e5a536284a4c@dist-git>
0a7476
From: Erik Skultety <eskultet@redhat.com>
0a7476
Date: Tue, 9 Apr 2019 08:34:35 +0200
0a7476
Subject: [PATCH] qemu: command: gfx: egl-headless: Add 'rendernode' option to
0a7476
 the cmdline
0a7476
MIME-Version: 1.0
0a7476
Content-Type: text/plain; charset=UTF-8
0a7476
Content-Transfer-Encoding: 8bit
0a7476
0a7476
Depending on whether QEMU actually supports the option, we can put the
0a7476
'rendernode' on the '-display egl-headless' cmdline.
0a7476
0a7476
https://bugzilla.redhat.com/show_bug.cgi?id=1628892
0a7476
0a7476
Signed-off-by: Erik Skultety <eskultet@redhat.com>
0a7476
Reviewed-by: Ján Tomko <jtomko@redhat.com>
0a7476
(cherry picked from commit 3163de7d0e7ae92b9f3e06479c8cd46e43ac8058)
0a7476
0a7476
https: //bugzilla.redhat.com/show_bug.cgi?id=1628892
0a7476
Signed-off-by: Erik Skultety <eskultet@redhat.com>
0a7476
Message-Id: <e38fbdd202bdda60f02eff1f5b06f1566cb8f93f.1554791287.git.eskultet@redhat.com>
0a7476
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
0a7476
---
0a7476
 src/qemu/qemu_command.c                       | 34 ++++++++++++++++---
0a7476
 ...egl-headless-rendernode.x86_64-latest.args | 31 +++++++++++++++++
0a7476
 .../graphics-egl-headless.x86_64-latest.args  | 31 +++++++++++++++++
0a7476
 ...play-spice-egl-headless.x86_64-latest.args |  2 +-
0a7476
 ...isplay-vnc-egl-headless.x86_64-latest.args |  2 +-
0a7476
 tests/qemuxml2argvtest.c                      |  2 ++
0a7476
 6 files changed, 95 insertions(+), 7 deletions(-)
0a7476
 create mode 100644 tests/qemuxml2argvdata/graphics-egl-headless-rendernode.x86_64-latest.args
0a7476
 create mode 100644 tests/qemuxml2argvdata/graphics-egl-headless.x86_64-latest.args
0a7476
0a7476
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
0a7476
index d60fbd4c8c..929f549a69 100644
0a7476
--- a/src/qemu/qemu_command.c
0a7476
+++ b/src/qemu/qemu_command.c
0a7476
@@ -8198,13 +8198,37 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
0a7476
 static int
0a7476
 qemuBuildGraphicsEGLHeadlessCommandLine(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
0a7476
                                         virCommandPtr cmd,
0a7476
-                                        virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED,
0a7476
-                                        virDomainGraphicsDefPtr graphics ATTRIBUTE_UNUSED)
0a7476
+                                        virQEMUCapsPtr qemuCaps,
0a7476
+                                        virDomainGraphicsDefPtr graphics)
0a7476
 {
0a7476
-    virCommandAddArg(cmd, "-display");
0a7476
-    virCommandAddArg(cmd, "egl-headless");
0a7476
+    int ret = -1;
0a7476
+    virBuffer opt = VIR_BUFFER_INITIALIZER;
0a7476
 
0a7476
-    return 0;
0a7476
+    virBufferAddLit(&opt, "egl-headless");
0a7476
+
0a7476
+    if (graphics->data.egl_headless.rendernode) {
0a7476
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_EGL_HEADLESS_RENDERNODE)) {
0a7476
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
0a7476
+                           _("This QEMU doesn't support OpenGL rendernode "
0a7476
+                             "with egl-headless graphics type"));
0a7476
+            goto cleanup;
0a7476
+        }
0a7476
+
0a7476
+        virBufferAddLit(&opt, ",rendernode=");
0a7476
+        virQEMUBuildBufferEscapeComma(&opt,
0a7476
+                                      graphics->data.egl_headless.rendernode);
0a7476
+    }
0a7476
+
0a7476
+    if (virBufferCheckError(&opt) < 0)
0a7476
+        goto cleanup;
0a7476
+
0a7476
+    virCommandAddArg(cmd, "-display");
0a7476
+    virCommandAddArgBuffer(cmd, &opt;;
0a7476
+
0a7476
+    ret = 0;
0a7476
+ cleanup:
0a7476
+    virBufferFreeAndReset(&opt;;
0a7476
+    return ret;
0a7476
 }
0a7476
 
0a7476
 
0a7476
diff --git a/tests/qemuxml2argvdata/graphics-egl-headless-rendernode.x86_64-latest.args b/tests/qemuxml2argvdata/graphics-egl-headless-rendernode.x86_64-latest.args
0a7476
new file mode 100644
0a7476
index 0000000000..ad9079d912
0a7476
--- /dev/null
0a7476
+++ b/tests/qemuxml2argvdata/graphics-egl-headless-rendernode.x86_64-latest.args
0a7476
@@ -0,0 +1,31 @@
0a7476
+LC_ALL=C \
0a7476
+PATH=/bin \
0a7476
+HOME=/home/test \
0a7476
+USER=test \
0a7476
+LOGNAME=test \
0a7476
+/usr/bin/qemu-system-i686 \
0a7476
+-name guest=QEMUGuest1,debug-threads=on \
0a7476
+-S \
0a7476
+-object secret,id=masterKey0,format=raw,\
0a7476
+file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
0a7476
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
0a7476
+-m 214 \
0a7476
+-realtime mlock=off \
0a7476
+-smp 1,sockets=1,cores=1,threads=1 \
0a7476
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
0a7476
+-no-user-config \
0a7476
+-nodefaults \
0a7476
+-chardev socket,id=charmonitor,fd=1729,server,nowait \
0a7476
+-mon chardev=charmonitor,id=monitor,mode=control \
0a7476
+-rtc base=utc \
0a7476
+-no-shutdown \
0a7476
+-no-acpi \
0a7476
+-boot strict=on \
0a7476
+-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
0a7476
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
0a7476
+-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
0a7476
+-display egl-headless,rendernode=/dev/dri/foo \
0a7476
+-device cirrus-vga,id=video0,bus=pci.0,addr=0x2 \
0a7476
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
0a7476
+resourcecontrol=deny \
0a7476
+-msg timestamp=on
0a7476
diff --git a/tests/qemuxml2argvdata/graphics-egl-headless.x86_64-latest.args b/tests/qemuxml2argvdata/graphics-egl-headless.x86_64-latest.args
0a7476
new file mode 100644
0a7476
index 0000000000..ad9079d912
0a7476
--- /dev/null
0a7476
+++ b/tests/qemuxml2argvdata/graphics-egl-headless.x86_64-latest.args
0a7476
@@ -0,0 +1,31 @@
0a7476
+LC_ALL=C \
0a7476
+PATH=/bin \
0a7476
+HOME=/home/test \
0a7476
+USER=test \
0a7476
+LOGNAME=test \
0a7476
+/usr/bin/qemu-system-i686 \
0a7476
+-name guest=QEMUGuest1,debug-threads=on \
0a7476
+-S \
0a7476
+-object secret,id=masterKey0,format=raw,\
0a7476
+file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
0a7476
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
0a7476
+-m 214 \
0a7476
+-realtime mlock=off \
0a7476
+-smp 1,sockets=1,cores=1,threads=1 \
0a7476
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
0a7476
+-no-user-config \
0a7476
+-nodefaults \
0a7476
+-chardev socket,id=charmonitor,fd=1729,server,nowait \
0a7476
+-mon chardev=charmonitor,id=monitor,mode=control \
0a7476
+-rtc base=utc \
0a7476
+-no-shutdown \
0a7476
+-no-acpi \
0a7476
+-boot strict=on \
0a7476
+-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
0a7476
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
0a7476
+-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
0a7476
+-display egl-headless,rendernode=/dev/dri/foo \
0a7476
+-device cirrus-vga,id=video0,bus=pci.0,addr=0x2 \
0a7476
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
0a7476
+resourcecontrol=deny \
0a7476
+-msg timestamp=on
0a7476
diff --git a/tests/qemuxml2argvdata/hostdev-mdev-display-spice-egl-headless.x86_64-latest.args b/tests/qemuxml2argvdata/hostdev-mdev-display-spice-egl-headless.x86_64-latest.args
0a7476
index 0ac90c81d2..6c090ede9b 100644
0a7476
--- a/tests/qemuxml2argvdata/hostdev-mdev-display-spice-egl-headless.x86_64-latest.args
0a7476
+++ b/tests/qemuxml2argvdata/hostdev-mdev-display-spice-egl-headless.x86_64-latest.args
0a7476
@@ -26,7 +26,7 @@ file=/tmp/lib/domain--1-QEMUGuest2/master-key.aes \
0a7476
 -drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-0-0 \
0a7476
 -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
0a7476
 -spice port=0,seamless-migration=on \
0a7476
--display egl-headless \
0a7476
+-display egl-headless,rendernode=/dev/dri/foo \
0a7476
 -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,\
0a7476
 vram64_size_mb=0,vgamem_mb=16,max_outputs=1,bus=pci.0,addr=0x2 \
0a7476
 -device vfio-pci,id=hostdev0,\
0a7476
diff --git a/tests/qemuxml2argvdata/hostdev-mdev-display-vnc-egl-headless.x86_64-latest.args b/tests/qemuxml2argvdata/hostdev-mdev-display-vnc-egl-headless.x86_64-latest.args
0a7476
index cdf545d0e0..b07fb86db5 100644
0a7476
--- a/tests/qemuxml2argvdata/hostdev-mdev-display-vnc-egl-headless.x86_64-latest.args
0a7476
+++ b/tests/qemuxml2argvdata/hostdev-mdev-display-vnc-egl-headless.x86_64-latest.args
0a7476
@@ -26,7 +26,7 @@ file=/tmp/lib/domain--1-QEMUGuest2/master-key.aes \
0a7476
 -drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-0-0 \
0a7476
 -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
0a7476
 -vnc 127.0.0.1:0 \
0a7476
--display egl-headless \
0a7476
+-display egl-headless,rendernode=/dev/dri/foo \
0a7476
 -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,\
0a7476
 vram64_size_mb=0,vgamem_mb=16,max_outputs=1,bus=pci.0,addr=0x2 \
0a7476
 -device vfio-pci,id=hostdev0,\
0a7476
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
0a7476
index f76856dc5f..a29e63d950 100644
0a7476
--- a/tests/qemuxml2argvtest.c
0a7476
+++ b/tests/qemuxml2argvtest.c
0a7476
@@ -1177,6 +1177,8 @@ mymain(void)
0a7476
     DO_TEST("graphics-egl-headless",
0a7476
             QEMU_CAPS_EGL_HEADLESS,
0a7476
             QEMU_CAPS_DEVICE_CIRRUS_VGA);
0a7476
+    DO_TEST_CAPS_LATEST("graphics-egl-headless");
0a7476
+    DO_TEST_CAPS_LATEST("graphics-egl-headless-rendernode");
0a7476
 
0a7476
     DO_TEST("graphics-vnc", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
0a7476
     DO_TEST("graphics-vnc-socket", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
0a7476
-- 
0a7476
2.21.0
0a7476