@samitouri / QOSamiQemu / commits / d3a4969dc5

Support per-head resolutions with virtio-gpu

In 454f4b0f, we started down the path of supporting separate configurations per display head (e.g., you have 2 heads - one with EDID name "AAA" and the other with EDID name "BBB"). In this change, we add resolution to this configuration surface (e.g., you have 2 heads - one with resolution 111x222 and the other with resolution 333x444). -display vnc=localhost:0,id=aaa,display=vga,head=0 \ -display vnc=localhost:1,id=bbb,display=vga,head=1 \ -device '{"driver":"virtio-vga", "max_outputs":2, "id":"vga", "outputs":[ { "name":"AAA", "xres":111, "yres":222 }, { "name":"BBB", "xres":333, "yres":444 } ]}' Here is the behavior matrix of the current resolution configuration surface (xres/yres) with the new resolution configuration surface (outputs[i].xres/yres). Note - we use "xres" and "yres" (instead of, say, "width" and "height") to match analogous virtio_gpu_base_conf.xres/yres. Case: !(xres || yres) && !(outputs[i].has_xres && outputs[i].has_yres) Behavior: current behavior - outputs[0] enabled with default xres/yres Case: (xres || yres) && !(outputs[i].has_xres && outputs[i].has_yres) Behavior: current behavior - outputs[0] enabled with xres/yres Case: outputs[i].has_xres && outputs[i].has_yres Behavior: new behavior - outputs[i] enabled with outputs[i].xres/yres Case: outputs[i].has_xres != outputs[i].has_yres Behavior: error Signed-off-by: Andrew Keesler <ankeesler@google.com> Acked-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20260210123038.2332364-2-ankeesler@google.com> [AJB: fix format strings for size_t in error_setg] Message-ID: <20260304165043.1437519-2-alex.bennee@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

Andrew Keesler committed Mar 4, 2026 at 16:50 UTC d3a4969dc5acbece7f2ff3acc666de09dd830523
2 files changed +27 -2
hw/display/virtio-gpu-base.c
+16
@@ -233,6 +233,22 @@ virtio_gpu_base_device_realize(DeviceState *qdev,
233 g->req_state[0].width = g->conf.xres;
234 g->req_state[0].height = g->conf.yres;
235
236 + for (output_idx = 0, node = g->conf.outputs;
237 + node && output_idx < g->conf.max_outputs;
238 + output_idx++, node = node->next) {
239 + if (node->value->has_xres != node->value->has_yres) {
240 + error_setg(errp,
241 + "must set both outputs[%zd].xres and outputs[%zd].yres",
242 + output_idx, output_idx);
243 + return false;
244 + }
245 + if (node->value->has_xres && node->value->has_yres) {
246 + g->enabled_output_bitmask |= (1 << output_idx);
247 + g->req_state[output_idx].width = node->value->xres;
248 + g->req_state[output_idx].height = node->value->yres;
249 + }
250 + }
251 +
252 g->hw_ops = &virtio_gpu_ops;
253 for (i = 0; i < g->conf.max_outputs; i++) {
254 g->scanout[i].con =
qapi/virtio.json
+11 -2
@@ -970,15 +970,24 @@
970 ##
971 # @VirtIOGPUOutput:
972 #
973 -# Describes configuration of a VirtIO GPU output.
973 +# Describes configuration of a VirtIO GPU output. If both @xres and
974 +# @yres are set, they take precedence over root virtio-gpu resolution
975 +# configuration and enable the corresponding output. If none of @xres
976 +# and @yres are set, root virtio-gpu resolution configuration takes
977 +# precedence and only the first output is enabled. Only setting one
978 +# of @xres or @yres is an error.
979 #
980 # @name: the name of the output
981 #
982 +# @xres: horizontal resolution of the output in pixels (since 11.0)
983 +#
984 +# @yres: vertical resolution of the output in pixels (since 11.0)
985 +#
986 # Since: 10.1
987 ##
988
989 { 'struct': 'VirtIOGPUOutput',
981 - 'data': { 'name': 'str' } }
990 + 'data': { 'name': 'str', '*xres': 'uint16', '*yres': 'uint16' } }
991
992 ##
993 # @DummyVirtioForceArrays: