Skip to content

pkg/qemu: tell a virtio-gpu guest every monitor change - #7196

Open
rucoder wants to merge 2 commits into
lf-edge:masterfrom
rucoder:rucoder/qemu-display-patches
Open

rucoder wants to merge 2 commits into
lf-edge:masterfrom
rucoder:rucoder/qemu-display-patches

Conversation

@rucoder

@rucoder rucoder commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds a QEMU display patch series to pkg/qemu. It contains QEMU patches only; the EVE graphical console that uses them is not part of it.

It has two commits:

  • pkg/qemu: backport the D-Bus display fixes and the UIInfo interface. It backports three QEMU master commits: 5378d1da44, 7275e5d1ba, and 378eb3d0db (the org.qemu.Display1.UIInfo interface). The series is written against them. EVE builds QEMU without the D-Bus display, so they change nothing in today's build.
  • pkg/qemu: tell a virtio-gpu guest every monitor change. It adds 20 patches written for upstream QEMU, where they are pending, as 1002-1021.

EVE gives a VM with VNC a virtio-vga (virtio-gpu-pci on arm). For those VMs the series changes this:

  • A VNC client's resize keeps what other UIs asked for, instead of resetting it.

  • The console starts from the size the device starts with, so a first request for "no monitor" reaches the device.

  • The guest is told of every monitor change:

    • a display event the guest clears before reading the display info is raised again, once;
    • an output that goes away and comes back before the guest has looked is held back until it has.
  • A virtio-gpu output configured with a zero size is refused. EVE never configures one.

  • The EDID:

    • writes names of 13 characters;
    • keeps the monitor name and serial number in the base block;
    • takes the product code and serial number as numbers.

    Its descriptors change order, with the same content. A guest sees the same monitor (same manufacturer, product and serial) and the same modes.

Everything else takes effect only with the D-Bus display and GL, which EVE does not build yet:

  • the monitor's identity in the EDID;
  • a connected key for D-Bus clients;
  • the fixes for a scanout with no texture, including a texture leaked on every guest device reset.

These are the parts EVE's graphical console will use.

The series brings qtests and a unit test for the EDID generator. EVE does not build them.

How to test and validate this PR

Done:

  • The patch files apply with patch -p1 --fuzz=0 to a clean QEMU v11.1.3, as the Dockerfile applies them. The result is byte-identical to the patch branch they were generated from.
  • QEMU builds with -Werror and no warnings, with master's configure options (--disable-opengl --disable-dbus-display, VNC on), for x86_64-softmmu and aarch64-softmmu.
  • make pkg/qemu builds.
  • Upstream-style checks were run on the same series on QEMU master:
    • every commit builds with -Werror;
    • tests/qtest/dbus-display-test (34 subtests) and tests/unit/test-edid pass at every commit;
    • each test was checked to fail with the change it covers removed.

To check on a device, run a VM with VNC (Linux or Windows guest, virtio-vga):

  1. The VM boots and shows its desktop over VNC as before.
  2. In a VNC client with remote resizing (for example noVNC with "Remote Resizing"), resize the window. The guest follows the new size.
  3. The guest's monitor is still the same one: on Windows, the same entry in Device Manager under Monitors; on Linux, the same name in xrandr --verbose or edid-decode /sys/class/drm/*/edid.

Changelog notes

QEMU: a VM's virtio-gpu display reports monitor changes, such as a VNC client resizing the display, to the guest more reliably.

PR Backports

  • 17.0-stable: No, it has no pkg/qemu (QEMU comes with xen-tools there).
  • 16.0-stable: No, it has no pkg/qemu (QEMU comes with xen-tools there).
  • 14.5-stable: No, it has no pkg/qemu (QEMU comes with xen-tools there).
  • 13.4-stable: No, it has no pkg/qemu (QEMU comes with xen-tools there).

Checklist

  • I've provided a proper description
  • I've added the proper documentation
  • I've tested my PR on amd64 device
  • I've tested my PR on arm64 device
  • I've written the test verification instructions
  • I've set the proper labels to this PR

And the last but not least:

  • I've checked the boxes above, or I've provided a good reason why I didn't check them. No documentation changes: this is a set of QEMU patches with no new EVE configuration. Not yet tested on devices: the amd64 test device is busy with other tests; the series is covered by the build and patch checks above and by QEMU qtests. Labels are set by maintainers.

Carry three QEMU master commits that the display patches after them are
written against:

- 5378d1da44 ui/dbus: disable scanout iff dmabuf is current
- 7275e5d1ba ui/dbus: fix cursor race, copy cursor data
- 378eb3d0db ui/dbus: add org.qemu.Display1.UIInfo interface

EVE builds QEMU without the D-Bus display, so they change nothing in
today's build. They keep one patch set for builds that enable it.

Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
Add a series written for upstream QEMU, where it is pending, as
patches 1002-1021. EVE gives a VM with VNC a virtio-vga, or a
virtio-gpu-pci on arm, and for those:

- a VNC client's resize keeps what other UIs asked for, and the console
  starts from the size the device starts with, so a first request for
  no monitor reaches the device;
- a display event the guest clears before reading the display info is
  raised again, once, and an output that goes away and comes back
  before the guest looked is held back until it has, so the guest sees
  every change;
- a virtio-gpu output configured with no size is refused;
- the EDID writes names of 13 characters, keeps the name and serial
  number in the base block, and takes the product code and serial
  number as numbers. Its descriptors change order, with the same
  content: a guest sees the same monitor, with the same modes.

The rest takes effect only with the D-Bus display and GL, which EVE does
not build today: the monitor's identity in the EDID, a "connected" key
for D-Bus clients, and the fixes for a scanout with no texture,
including the texture leaked on every guest device reset.

The series brings qtests and a unit test for the EDID generator, which
EVE does not build.

Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
@codecov

codecov Bot commented Nov 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 31.45%. Comparing base (9267176) to head (ab9b4a2).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7196      +/-   ##
==========================================
+ Coverage   30.99%   31.45%   +0.46%     
==========================================
  Files         562      573      +11     
  Lines      101231   102826    +1595     
==========================================
+ Hits        31380    32349     +969     
- Misses      67412    68077     +665     
+ Partials     2439     2400      -39     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rene rene left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 This review was written by Claude (Anthropic's AI assistant, via Claude Code) and posted at the request of the account owner. It is based on reading the patches against the QEMU v11.1.3 sources; nothing was built or booted for it.

Thanks for the detailed description and for splitting the backports from the pending patches.

I went through every hunk that lands in code EVE compiles today (VNC + virtio-vga/virtio-gpu-pci, no GL, no D-Bus). My understanding is that the D-Bus part is groundwork for the graphical console and is expected to stay disabled for now, so I focused on what changes for existing VMs.

For the current VNC path I see only two behaviour changes:

  1. EDID bytes (1015-1018): the established timings III descriptor moves after the monitor name, and the 1400x1050 entry is corrected. Vendor, product, serial, name and preferred mode are unchanged.
  2. Display event re-raise (1007): runs for every guest on every resize. Linux reads the display info before clearing the event, so nothing changes there. A driver that clears first gets each event twice.

The rest of the compiled changes (hold-back in 1008, identity in 1019, the vfio display EDID path, the zero-size check) need inputs that VNC can't produce or that EVE doesn't configure.

Requests before merge:

  • The device test boxes are unchecked. Could you run one Windows guest and one Linux guest with VNC: boot to desktop, resize from noVNC a few times, reboot the guest, and on Windows confirm the monitor entry in Device Manager is unchanged? Windows is the one I'd most like to see, because of item 2 (I don't know in which order viogpu clears the event and reads the display info).
  • 20 of the patches are Upstream-Status: Pending and touch files that move often upstream (ui/console.c, virtio-gpu-base.c, edid-generate.c). Could you link the upstream submission in the PR description or in pkg/qemu/patches/README.md, so we can track it and drop the patches when they land?
  • Since EVE's build doesn't compile ui/dbus-*.c or the virgl code, a bad rebase of 0002-0004, 1010-1012, 1014, 1020 and 1021 at a QEMU bump would go unnoticed. Worth a note in the README that these need a build with --enable-dbus-display --enable-opengl when they are rebased.

A few comments inline; none of them affect the VNC path today, but they are worth fixing before the series goes upstream.

+ * display event twice, and reads the display info once more; one that
+ * clears it again without reading has no use for it.
+ */
+void virtio_gpu_base_events_clear(VirtIOGPUBase *g, uint32_t events_clear)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set_config is called on every config-space write with the whole cached config, and events_clear stays set there until the next config read. A guest that writes events_clear in more than one access (e.g. byte-wise) re-raises the event on the first access and clears the re-raised one on the second, so it takes the interrupt, reads events_read == 0, and keeps the stale display info. Linux writes it as a single 32-bit access, so it is not affected. Could the clear act only when the write actually covers events_clear?

🤖 Written by Claude (Claude Code).


for (i = 0; i < g->parent_obj.conf.max_outputs; i++) {
qemu_console_set_surface(g->parent_obj.scanout[i].con, NULL);
+ qemu_console_gl_scanout_disable(g->parent_obj.scanout[i].con);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Order: this sets the placeholder surface and then disables the GL scanout, so a D-Bus GL listener gets Scanout(placeholder) followed by Disable, and 1012 then drops updates while gl_scanout is false. qemu_graphic_console_close() does it the other way round (disable, then replace the surface). No effect with VNC, where the disable is a no-op.

🤖 Written by Claude (Claude Code).

+ ddl->gl_scanout = true;
+ ddl->scanout_failed = false;
+ } else {
+ dbus_scanout_disable(dcl);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit message says the failure is reported once, but the else branches in dbus_scanout_dmabuf() / dbus_scanout_texture() call dbus_scanout_disable() directly, so scanout_failed is never set. A peer that only implements ScanoutDMABUF v1 with a multi-plane guest gets an error_report() and a Disable call per frame. Routing these through dbus_scanout_failed() would fix it.

🤖 Written by Claude (Claude Code).

}
}

+ for (i = 0; i < g->conf.max_outputs; i++) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: -device virtio-gpu-pci,xres=0 used to start (guest fell back to its default mode) and now fails at realize. EVE never sets it, so this is fine here, but upstream may see it as a compatibility break; falling back to the EDID default instead of failing would avoid that.

🤖 Written by Claude (Claude Code).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants