fix #7525: vga: allow setting the number of outputs for VirtIO GPU

With SPICE and QXL, Linux guests get 'max_outputs=4' on the display
device, so they can use up to four displays with a single device. For
the VirtIO GPU, there is no way to change QEMU's default of a single
output, so using multiple displays requires passing the whole device
via custom arguments.

Add a 'max-outputs' option to the 'vga' property, which sets the
'max_outputs' property of the VirtIO GPU, for both 'virtio' and
'virtio-gl'. QEMU supports up to 16 outputs. Other display types
reject the option, as QXL handles multiple displays on its own.

Signed-off-by: Michal Fox <me@dualfroz.com>
This commit is contained in:
dualfroz committed 2026-10-03 01:53:20 +02:00
1 parent 1b6f27e716
commit 5f10cfd754
4 files changed
+71

No files matched your search

+15
View File
@@ -187,6 +187,15 @@ my $vga_fmt = {
enum => ['vnc'],
optional => 1,
},
'max-outputs' => {
description => "Sets the maximum number of displays the guest can use. Only supported"
. " with 'virtio' and 'virtio-gl'.",
type => 'integer',
optional => 1,
minimum => 1,
maximum => 16,
default => 1,
},
};
my $ivshmem_fmt = {
@@ -1513,6 +1522,12 @@ sub print_vga_device {
}
}
if (my $outputs = $vga->{'max-outputs'}) {
die "'max-outputs' is only supported with VGA type 'virtio' or 'virtio-gl'\n"
if $vga->{type} !~ m/^virtio/;
$max_outputs = ",max_outputs=$outputs";
}
die "no device-type for $vga->{type}\n" if !$type;
my $memory = "";
+11
View File
@@ -0,0 +1,11 @@
# TEST: Test that max-outputs is rejected for non-VirtIO GPUs
# EXPECT_ERROR: 'max-outputs' is only supported with VGA type 'virtio' or 'virtio-gl'
cores: 2
memory: 2048
name: qxldisplays
net0: virtio=A2:C0:43:67:08:A1,bridge=vmbr0
ostype: l26
scsihw: virtio-scsi-pci
smbios1: uuid=7b10d7af-b932-4c66-b2c3-3996152ec465
vmgenid: c773c261-d800-4348-9f5d-167fadd53cf8
vga: qxl,max-outputs=2
@@ -0,0 +1,10 @@
# TEST: Test for VirtIO GPU with multiple outputs
cores: 2
memory: 2048
name: virtiodisplays
net0: virtio=A2:C0:43:67:08:A1,bridge=vmbr0
ostype: l26
scsihw: virtio-scsi-pci
smbios1: uuid=7b10d7af-b932-4c66-b2c3-3996152ec465
vmgenid: c773c261-d800-4348-9f5d-167fadd53cf8
vga: virtio,max-outputs=2
@@ -0,0 +1,35 @@
/usr/bin/kvm \
-id 8006 \
-name virtiodisplays \
-no-shutdown \
-chardev 'socket,id=qmp,path=/var/run/qemu-server/8006.qmp,server=on,wait=off' \
-object 'monitor-qmp,chardev=qmp,id=monitor-qmp' \
-chardev 'socket,id=qmp-event,path=/var/run/qmeventd.sock,reconnect-ms=5000' \
-object 'monitor-qmp,chardev=qmp-event,id=monitor-qmp-event' \
-pidfile /var/run/qemu-server/8006.pid \
-daemonize \
-smbios 'type=1,uuid=7b10d7af-b932-4c66-b2c3-3996152ec465' \
-smp '2,sockets=1,cores=2,maxcpus=2' \
-nodefaults \
-boot 'menu=on,strict=on,reboot-timeout=1000,splash=/usr/share/qemu-server/bootsplash.jpg' \
-vnc 'unix:/var/run/qemu-server/8006.vnc,password=on' \
-cpu kvm64,enforce,+kvm_pv_eoi,+kvm_pv_unhalt,+lahf_lm,+sep \
-m 2048 \
-global 'PIIX4_PM.disable_s3=1' \
-global 'PIIX4_PM.disable_s4=1' \
-device 'pci-bridge,id=pci.1,chassis_nr=1,bus=pci.0,addr=0x1e' \
-device 'pci-bridge,id=pci.2,chassis_nr=2,bus=pci.0,addr=0x1f' \
-device 'pci-bridge,id=pci.4,chassis_nr=4,bus=pci.1,addr=0x1c' \
-device 'vmgenid,guid=c773c261-d800-4348-9f5d-167fadd53cf8' \
-device 'piix3-usb-uhci,id=uhci,bus=pci.0,addr=0x1.0x2' \
-device 'usb-tablet,id=tablet,bus=uhci.0,port=1' \
-device 'virtio-vga,id=vga,max_outputs=2,bus=pci.0,addr=0x2' \
-device 'virtio-serial,id=spice,bus=pci.0,addr=0x9' \
-chardev 'spicevmc,id=vdagent,name=vdagent' \
-device 'virtserialport,chardev=vdagent,name=com.redhat.spice.0' \
-spice 'tls-port=61000,addr=127.0.0.1,tls-ciphers=HIGH,seamless-migration=on' \
-device 'virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3,free-page-reporting=on' \
-iscsi 'initiator-name=iqn.1993-08.org.debian:01:aabbccddeeff' \
-netdev 'type=tap,id=net0,ifname=tap8006i0,script=/usr/libexec/qemu-server/pve-bridge,downscript=/usr/libexec/qemu-server/pve-bridgedown,vhost=on' \
-device 'virtio-net-pci,mac=A2:C0:43:67:08:A1,netdev=net0,bus=pci.0,addr=0x12,id=net0,rx_queue_size=1024,tx_queue_size=256,bootindex=300,host_mtu=1500,host_tunnel=off' \
-machine 'hpet=off,type=pc+pve0'