diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 1455c0d5bd2665e7efe35ac4b14d7e44f2e38153..b5d84e6bfb7bdc067f5c8b251985732a8e12b9ea 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4091,6 +4091,16 @@ qemuBuildDeviceVideoStr(const virDomainDef *def,
/* QEMU accepts mebibytes for vgamem_mb. */
virBufferAsprintf(&buf, ",vgamem_mb=%u", video->vgamem / 1024);
}
+
+ if ((video->primary &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VGA_MAX_OUTPUTS)) ||
+ (!video->primary &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_MAX_OUTPUTS))) {
+ if (video->heads)
+ virBufferAsprintf(&buf, ",max_outputs=%u", video->heads);
+ } else {
+ video->heads = 0;
+ }
} else if (video->vram &&
((video->type == VIR_DOMAIN_VIDEO_TYPE_VGA &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) ||
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index c5b2963d65b62818a268a8f5b3804b6989ad3e67..bed5f0b581b9b731b98923a0a52695f5d141bdd5 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -3131,7 +3131,6 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
if (nmigrate_disks) {
if (has_drive_mirror) {
size_t i, j;
-
/* Check user requested only known disk targets. */
for (i = 0; i < nmigrate_disks; i++) {
for (j = 0; j < vm->def->ndisks; j++) {
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-heads.args b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-heads.args
new file mode 100644
index 0000000000000000000000000000000000000000..a939177088f9484fef2f0b5e70c47a5684615c83
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-heads.args
@@ -0,0 +1,28 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 214 \
+-smp 1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
+-no-acpi \
+-boot c \
+-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 \
+-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,max_outputs=1,\
+bus=pci.0,addr=0x2 \
+-device qxl,id=video1,ram_size=67108864,vram_size=33554432,max_outputs=3,\
+bus=pci.0,addr=0x4 \
+-device qxl,id=video2,ram_size=67108864,vram_size=67108864,max_outputs=7,\
+bus=pci.0,addr=0x5 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-heads.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-heads.xml
new file mode 100644
index 0000000000000000000000000000000000000000..45d08745e6521a4a6d48d5f44d01eade72f97666
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-heads.xml
@@ -0,0 +1,47 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219136
+ 219136
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-noheads.args b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-noheads.args
new file mode 100644
index 0000000000000000000000000000000000000000..c609d487e181c52f51c1767292e6bb46d83f3f53
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-noheads.args
@@ -0,0 +1,24 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 214 \
+-smp 1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
+-no-acpi \
+-boot c \
+-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 \
+-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,max_outputs=1,\
+bus=pci.0,addr=0x2 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-noheads.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-noheads.xml
new file mode 100644
index 0000000000000000000000000000000000000000..de003be537073178880cdb09005f60834697d6f2
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-noheads.xml
@@ -0,0 +1,39 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219136
+ 219136
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index db42b7bd71be55f0686f7650c02664e05dfa932d..b2cde8e542b59ae77614b9d19dd8ba96457acb8a 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1455,6 +1455,20 @@ mymain(void)
QEMU_CAPS_DEVICE_QXL_VGA, QEMU_CAPS_DEVICE_QXL,
QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_QXL_VGA_VGAMEM,
QEMU_CAPS_QXL_VGAMEM);
+ DO_TEST("video-qxl-heads",
+ QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
+ QEMU_CAPS_VGA_QXL,
+ QEMU_CAPS_DEVICE_QXL_VGA,
+ QEMU_CAPS_DEVICE_QXL,
+ QEMU_CAPS_QXL_MAX_OUTPUTS,
+ QEMU_CAPS_QXL_VGA_MAX_OUTPUTS);
+ DO_TEST("video-qxl-noheads",
+ QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
+ QEMU_CAPS_VGA_QXL,
+ QEMU_CAPS_DEVICE_QXL_VGA,
+ QEMU_CAPS_DEVICE_QXL,
+ QEMU_CAPS_QXL_MAX_OUTPUTS,
+ QEMU_CAPS_QXL_VGA_MAX_OUTPUTS);
DO_TEST("video-virtio-gpu-device",
QEMU_CAPS_DEVICE_VIRTIO_GPU,
QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-video-qxl-heads.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-video-qxl-heads.xml
new file mode 100644
index 0000000000000000000000000000000000000000..e7b18ab2b2ab68d7c40e4e57a7a1f3eb197f4ace
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-video-qxl-heads.xml
@@ -0,0 +1,47 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219136
+ 219136
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-video-qxl-noheads.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-video-qxl-noheads.xml
new file mode 100644
index 0000000000000000000000000000000000000000..ee22e30ad0267d7be079d7d4c1726fe5e33630ef
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-video-qxl-noheads.xml
@@ -0,0 +1,39 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219136
+ 219136
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index e9d1f938360de0ef1cac8d62ac1d819e7e322b04..eca8e7822523abd1d7c80b2a7069678c36f69526 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -817,6 +817,9 @@ mymain(void)
DO_TEST("acpi-table");
+ DO_TEST("video-qxl-heads");
+ DO_TEST("video-qxl-noheads");
+
qemuTestDriverFree(&driver);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;