Virtual monitor heads are not "connected" until viewed in a front end
Host environment
- Operating system: Debian 11
- OS/kernel version: Linux shodan 5.10.0-13-amd64 #1 SMP Debian 5.10.106-1 (2022-03-17) x86_64 GNU/Linux
- Architecture: AMD64
- QEMU flavor: qemu-system-aarch64, but appears to effect all
- QEMU version: QEMU emulator version 7.0.50 (v7.0.0-2471-g8e3d85d3)
- QEMU command line:
qemu-system-aarch64 -drive id=disk0,file=image.img,if=none,format=raw -device virtio-blk-device,drive=disk0 -machine virt -cpu cortex-a72 -smp 4 -m 2048 -kernel /vmlinuz -append 'root=/dev/vda rw mem=2048M' -display gtk,gl=on -device virtio-gpu-gl,id=gpu,edid=on,xres=1920,yres=720,max_outputs=4
Emulated/Virtualized environment
- Operating system: Linux
- OS/kernel version: Linux test 5.4.178-yocto-standard #1 SMP PREEMPT Wed Feb 9 23:01:35 UTC 2022 aarch64 GNU/Linux
- Architecture: Arm Aarch64
Description of problem
When you attach a virtual GPU to a guest, qemu appears to only "attach" a virtual monitor to an output port when that virtual display is
viewed using the GUI. For example, when you boot using the above command line, there will be four displays in /sys/class/drm/
on the guest,
card0-Virtual-1
through to card0-Virtual-4
. In each of these directories, there is an "enabled" file, which contains either
"enabled" or "disabled". These contain "disabled" until you switch tab/view to look at it using the GUI, at which point they change to "enabled".
This causes a problem for us because Weston will not initialise displays that do not have a monitor attached, meaning the system we are trying to boot fails because not all the Weston display surfaces are available.
There does not appear to be a command line option to force virtual monitors to be attached to virtual displays immediately. Looking through the
Gtk user interface code (and the other front ends) there does not appear to be a call into the qemu core that requests the connection of a virtual
monitor to the virtual displays - my guess is that qemu only connects a monitor when a render request first happens (or similar), but I have not followed the code paths deeper than the source files in QEMU/ui/
.
I also tried using the screengrab
command to screenshot each head, but this does not need sufficient to cause the display to be marked
enabled in the guest.
While we could possibly automate the GUI using some external tool, we ultimately need to run this in a CI environment using
egl-headless
or similar.
Steps to reproduce
- Launch qemu with virtio-gpu-gl setting max_outputs > 1
- On guest,
cat /sys/drm/class/card0-Virtual-2
- it reads "disabled" - On host, switch the view to look at the second display ("virtio-gpu-gl-pci.1")
- On guest,
cat /sys/drm/class/card0-Virtual-2
- it now reads "enabled"
Desired/expected functionality
Either all displays are "enabled" at boot, or you can specify which are enabled at boot in the -device configuration stanza.