render / rpms / libvirt

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