Depending on whether QEMU actually supports the option, we can put the 'rendernode' on the '-display egl-headless' cmdline. As for the test, we don't need a new input source, hence the symlink, we just need a new .args output, since the functionality is determined by a QEMU capability. Signed-off-by: Erik Skultety <eskultet@xxxxxxxxxx> --- src/qemu/qemu_command.c | 29 ++++++++++++++++--- ...graphics-egl-headless-rendernode-auto.args | 26 +++++++++++++++++ .../graphics-egl-headless-rendernode-auto.xml | 1 + .../graphics-egl-headless.args | 2 +- .../graphics-spice-egl-headless.args | 2 +- .../graphics-vnc-egl-headless.args | 2 +- ...play-spice-egl-headless.x86_64-latest.args | 2 +- ...isplay-vnc-egl-headless.x86_64-latest.args | 2 +- tests/qemuxml2argvtest.c | 7 +++++ 9 files changed, 64 insertions(+), 9 deletions(-) create mode 100644 tests/qemuxml2argvdata/graphics-egl-headless-rendernode-auto.args create mode 120000 tests/qemuxml2argvdata/graphics-egl-headless-rendernode-auto.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 34c8ad751b..19098e4ebe 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8310,13 +8310,34 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, static int qemuBuildGraphicsEGLHeadlessCommandLine(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED, virCommandPtr cmd, - virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED, - virDomainGraphicsDefPtr graphics ATTRIBUTE_UNUSED) + virQEMUCapsPtr qemuCaps, + virDomainGraphicsDefPtr graphics) { + int ret = -1; + virBuffer opt = VIR_BUFFER_INITIALIZER; + + virBufferAddLit(&opt, "egl-headless"); + + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_EGL_HEADLESS_RENDERNODE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("This QEMU doesn't support OpenGL rendernode " + "with egl-headless graphics type")); + goto cleanup; + } + + virBufferAddLit(&opt, ",rendernode="); + virQEMUBuildBufferEscapeComma(&opt, graphics->data.egl_headless.rendernode); + + if (virBufferCheckError(&opt) < 0) + goto cleanup; + virCommandAddArg(cmd, "-display"); - virCommandAddArg(cmd, "egl-headless"); + virCommandAddArgBuffer(cmd, &opt); - return 0; + ret = 0; + cleanup: + virBufferFreeAndReset(&opt); + return ret; } diff --git a/tests/qemuxml2argvdata/graphics-egl-headless-rendernode-auto.args b/tests/qemuxml2argvdata/graphics-egl-headless-rendernode-auto.args new file mode 100644 index 0000000000..84633abca8 --- /dev/null +++ b/tests/qemuxml2argvdata/graphics-egl-headless-rendernode-auto.args @@ -0,0 +1,26 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +/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 \ +-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,\ +bootindex=1 \ +-display egl-headless,rendernode=/dev/dri/foo \ +-vga cirrus diff --git a/tests/qemuxml2argvdata/graphics-egl-headless-rendernode-auto.xml b/tests/qemuxml2argvdata/graphics-egl-headless-rendernode-auto.xml new file mode 120000 index 0000000000..065e77919e --- /dev/null +++ b/tests/qemuxml2argvdata/graphics-egl-headless-rendernode-auto.xml @@ -0,0 +1 @@ +graphics-egl-headless.xml \ No newline at end of file diff --git a/tests/qemuxml2argvdata/graphics-egl-headless.args b/tests/qemuxml2argvdata/graphics-egl-headless.args index 6428dbb121..84633abca8 100644 --- a/tests/qemuxml2argvdata/graphics-egl-headless.args +++ b/tests/qemuxml2argvdata/graphics-egl-headless.args @@ -22,5 +22,5 @@ server,nowait \ -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,\ bootindex=1 \ --display egl-headless \ +-display egl-headless,rendernode=/dev/dri/foo \ -vga cirrus diff --git a/tests/qemuxml2argvdata/graphics-spice-egl-headless.args b/tests/qemuxml2argvdata/graphics-spice-egl-headless.args index 60eba443f2..df86f7f328 100644 --- a/tests/qemuxml2argvdata/graphics-spice-egl-headless.args +++ b/tests/qemuxml2argvdata/graphics-spice-egl-headless.args @@ -24,7 +24,7 @@ server,nowait \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,\ bootindex=1 \ -spice port=5903,addr=127.0.0.1 \ --display egl-headless \ +-display egl-headless,rendernode=/dev/dri/foo \ -vga qxl \ -global qxl-vga.ram_size=67108864 \ -global qxl-vga.vram_size=33554432 \ diff --git a/tests/qemuxml2argvdata/graphics-vnc-egl-headless.args b/tests/qemuxml2argvdata/graphics-vnc-egl-headless.args index bb615da859..8dffc7d085 100644 --- a/tests/qemuxml2argvdata/graphics-vnc-egl-headless.args +++ b/tests/qemuxml2argvdata/graphics-vnc-egl-headless.args @@ -24,5 +24,5 @@ server,nowait \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,\ bootindex=1 \ -vnc '[2001:1:2:3:4:5:1234:1234]:3' \ --display egl-headless \ +-display egl-headless,rendernode=/dev/dri/foo \ -vga cirrus 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 index b84869264e..f5229936fc 100644 --- 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 @@ -24,7 +24,7 @@ file=/tmp/lib/domain--1-QEMUGuest2/master-key.aes \ -boot strict=on \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ -spice port=0,seamless-migration=on \ --display egl-headless \ +-display egl-headless,rendernode=/dev/dri/foo \ -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,\ vram64_size_mb=0,vgamem_mb=16,max_outputs=1,bus=pci.0,addr=0x2 \ -device vfio-pci,id=hostdev0,\ 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 index 91708d7663..9eaaf89eef 100644 --- 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 @@ -24,7 +24,7 @@ file=/tmp/lib/domain--1-QEMUGuest2/master-key.aes \ -boot strict=on \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ -vnc 127.0.0.1:0 \ --display egl-headless \ +-display egl-headless,rendernode=/dev/dri/foo \ -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,\ vram64_size_mb=0,vgamem_mb=16,max_outputs=1,bus=pci.0,addr=0x2 \ -device vfio-pci,id=hostdev0,\ diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index eae2b7edf7..787b54c74b 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1245,6 +1245,11 @@ mymain(void) DO_TEST("graphics-egl-headless", QEMU_CAPS_EGL_HEADLESS, + QEMU_CAPS_EGL_HEADLESS_RENDERNODE, + QEMU_CAPS_DEVICE_CIRRUS_VGA); + DO_TEST("graphics-egl-headless-rendernode-auto", + QEMU_CAPS_EGL_HEADLESS, + QEMU_CAPS_EGL_HEADLESS_RENDERNODE, QEMU_CAPS_DEVICE_CIRRUS_VGA); DO_TEST("graphics-vnc", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA); @@ -1284,6 +1289,7 @@ mymain(void) DO_TEST("graphics-vnc-egl-headless", QEMU_CAPS_VNC, QEMU_CAPS_EGL_HEADLESS, + QEMU_CAPS_EGL_HEADLESS_RENDERNODE, QEMU_CAPS_DEVICE_CIRRUS_VGA); DO_TEST("graphics-sdl", @@ -1346,6 +1352,7 @@ mymain(void) DO_TEST("graphics-spice-egl-headless", QEMU_CAPS_SPICE, QEMU_CAPS_EGL_HEADLESS, + QEMU_CAPS_EGL_HEADLESS_RENDERNODE, QEMU_CAPS_DEVICE_QXL); DO_TEST_FAILURE("graphics-spice-invalid-egl-headless", QEMU_CAPS_SPICE, -- 2.19.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list