Since QEMU 2.12, QEMU understands a new vfio-pci device option 'display'
which can be used to turn on display capabilities on vgpu-enabled
mediated devices, IOW emulated GPU devices like QXL will no longer be
needed with vgpu-enable mdevs.
Since QEMU 2.12 defaults to 'auto' for the 'display' attribute, which
often doesn't work as reliably, we need to play it safe here and
explicitly format display='off' if this attribute wasn't provided in the
XML explicitly.
Signed-off-by: Erik Skultety <eskultet(a)redhat.com>
---
src/qemu/qemu_command.c | 24 ++++++++++++-
.../hostdev-mdev-display-spice-egl-headless.args | 32 +++++++++++++++++
.../hostdev-mdev-display-spice-egl-headless.xml | 40 +++++++++++++++++++++
.../hostdev-mdev-display-spice-opengl.args | 31 ++++++++++++++++
.../hostdev-mdev-display-spice-opengl.xml | 41 ++++++++++++++++++++++
.../hostdev-mdev-display-vnc-egl-headless.args | 32 +++++++++++++++++
.../hostdev-mdev-display-vnc-egl-headless.xml | 40 +++++++++++++++++++++
.../qemuxml2argvdata/hostdev-mdev-display-vnc.args | 31 ++++++++++++++++
.../qemuxml2argvdata/hostdev-mdev-display-vnc.xml | 39 ++++++++++++++++++++
tests/qemuxml2argvtest.c | 31 ++++++++++++++++
10 files changed, 340 insertions(+), 1 deletion(-)
create mode 100644 tests/qemuxml2argvdata/hostdev-mdev-display-spice-egl-headless.args
create mode 100644 tests/qemuxml2argvdata/hostdev-mdev-display-spice-egl-headless.xml
create mode 100644 tests/qemuxml2argvdata/hostdev-mdev-display-spice-opengl.args
create mode 100644 tests/qemuxml2argvdata/hostdev-mdev-display-spice-opengl.xml
create mode 100644 tests/qemuxml2argvdata/hostdev-mdev-display-vnc-egl-headless.args
create mode 100644 tests/qemuxml2argvdata/hostdev-mdev-display-vnc-egl-headless.xml
create mode 100644 tests/qemuxml2argvdata/hostdev-mdev-display-vnc.args
create mode 100644 tests/qemuxml2argvdata/hostdev-mdev-display-vnc.xml
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 8026efbe87..6192253a9c 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5178,6 +5178,17 @@ qemuBuildHostdevMediatedDevStr(const virDomainDef *def,
virBufferAdd(&buf, dev_str, -1);
virBufferAsprintf(&buf, ",id=%s,sysfsdev=%s", dev->info->alias,
mdevPath);
+ /* QEMU 2.12 added support for vfio-pci display type, we default to
+ * 'display=off', since QEMU defaults to 'auto' which is unreliable
and
+ * we don't want to risk any breakages */
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VFIO_PCI_DISPLAY) &&
+ mdevsrc->display == VIR_TRISTATE_SWITCH_ABSENT)
+ mdevsrc->display = VIR_TRISTATE_SWITCH_OFF;
+
+ if (mdevsrc->display > VIR_TRISTATE_SWITCH_ABSENT)
+ virBufferAsprintf(&buf, ",display=%s",
+ virTristateSwitchTypeToString(mdevsrc->display));
+
if (qemuBuildDeviceAddressStr(&buf, def, dev->info, qemuCaps) < 0)
goto cleanup;
@@ -5395,7 +5406,9 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
/* MDEV */
if (virHostdevIsMdevDevice(hostdev)) {
- switch ((virMediatedDeviceModelType) subsys->u.mdev.model) {
+ virDomainHostdevSubsysMediatedDevPtr mdevsrc = &subsys->u.mdev;
+
+ switch ((virMediatedDeviceModelType) mdevsrc->model) {
case VIR_MDEV_MODEL_TYPE_VFIO_PCI:
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -5403,6 +5416,15 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
"supported by this version of QEMU"));
return -1;
}
+
+ if (mdevsrc->display != VIR_TRISTATE_SWITCH_ABSENT &&
+ !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VFIO_PCI_DISPLAY)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("display property of device vfio-pci is "
+ "not supported by this version of
QEMU"));
+ return -1;
+ }
+
break;
case VIR_MDEV_MODEL_TYPE_VFIO_CCW:
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_CCW)) {
diff --git a/tests/qemuxml2argvdata/hostdev-mdev-display-spice-egl-headless.args
b/tests/qemuxml2argvdata/hostdev-mdev-display-spice-egl-headless.args
new file mode 100644
index 0000000000..0d7792c938
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-mdev-display-spice-egl-headless.args
@@ -0,0 +1,32 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=spice \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest2 \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest2/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot c \
+-usb \
+-drive file=/dev/HostVG/QEMUGuest2,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 \
+-spice port=0 \
+-display egl-headless \
+-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0,\
+addr=0x2 \
+-device vfio-pci,id=hostdev0,\
+sysfsdev=/sys/bus/mdev/devices/53764d0e-85a0-42b4-af5c-2046b460b1dc,display=on,\
+bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/hostdev-mdev-display-spice-egl-headless.xml
b/tests/qemuxml2argvdata/hostdev-mdev-display-spice-egl-headless.xml
new file mode 100644
index 0000000000..c8f10c2f3a
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-mdev-display-spice-egl-headless.xml
@@ -0,0 +1,40 @@
+<domain type='qemu' id='1'>
+ <name>QEMUGuest2</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest2'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0'
target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='ide' index='0'>
+ </controller>
+ <graphics type='spice'/>
+ <graphics type='egl-headless'/>
+ <hostdev mode='subsystem' type='mdev' model='vfio-pci'
display='on'>
+ <source>
+ <address uuid='53764d0e-85a0-42b4-af5c-2046b460b1dc'/>
+ </source>
+ </hostdev>
+ <video>
+ <model type='qxl' heads='1'/>
+ </video>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/hostdev-mdev-display-spice-opengl.args
b/tests/qemuxml2argvdata/hostdev-mdev-display-spice-opengl.args
new file mode 100644
index 0000000000..170b4e4ed0
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-mdev-display-spice-opengl.args
@@ -0,0 +1,31 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=spice \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest2 \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest2/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot c \
+-usb \
+-drive file=/dev/HostVG/QEMUGuest2,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 \
+-spice port=0,gl=on,rendernode=/dev/dri/foo \
+-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0,\
+addr=0x2 \
+-device vfio-pci,id=hostdev0,\
+sysfsdev=/sys/bus/mdev/devices/53764d0e-85a0-42b4-af5c-2046b460b1dc,display=on,\
+bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/hostdev-mdev-display-spice-opengl.xml
b/tests/qemuxml2argvdata/hostdev-mdev-display-spice-opengl.xml
new file mode 100644
index 0000000000..18c9817608
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-mdev-display-spice-opengl.xml
@@ -0,0 +1,41 @@
+<domain type='qemu' id='1'>
+ <name>QEMUGuest2</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest2'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0'
target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='ide' index='0'>
+ </controller>
+ <graphics type='spice'>
+ <gl enable='yes' rendernode='/dev/dri/foo'/>
+ </graphics>
+ <hostdev mode='subsystem' type='mdev' model='vfio-pci'
display='on'>
+ <source>
+ <address uuid='53764d0e-85a0-42b4-af5c-2046b460b1dc'/>
+ </source>
+ </hostdev>
+ <video>
+ <model type='qxl' heads='1'/>
+ </video>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/hostdev-mdev-display-vnc-egl-headless.args
b/tests/qemuxml2argvdata/hostdev-mdev-display-vnc-egl-headless.args
new file mode 100644
index 0000000000..439e741b0d
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-mdev-display-vnc-egl-headless.args
@@ -0,0 +1,32 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest2 \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest2/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot c \
+-usb \
+-drive file=/dev/HostVG/QEMUGuest2,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 \
+-vnc 127.0.0.1:0 \
+-display egl-headless \
+-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0,\
+addr=0x2 \
+-device vfio-pci,id=hostdev0,\
+sysfsdev=/sys/bus/mdev/devices/53764d0e-85a0-42b4-af5c-2046b460b1dc,display=on,\
+bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/hostdev-mdev-display-vnc-egl-headless.xml
b/tests/qemuxml2argvdata/hostdev-mdev-display-vnc-egl-headless.xml
new file mode 100644
index 0000000000..b3eaeeef13
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-mdev-display-vnc-egl-headless.xml
@@ -0,0 +1,40 @@
+<domain type='qemu' id='1'>
+ <name>QEMUGuest2</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest2'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0'
target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='ide' index='0'>
+ </controller>
+ <graphics type='vnc'/>
+ <graphics type='egl-headless'/>
+ <hostdev mode='subsystem' type='mdev' model='vfio-pci'
display='on'>
+ <source>
+ <address uuid='53764d0e-85a0-42b4-af5c-2046b460b1dc'/>
+ </source>
+ </hostdev>
+ <video>
+ <model type='qxl' heads='1'/>
+ </video>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/hostdev-mdev-display-vnc.args
b/tests/qemuxml2argvdata/hostdev-mdev-display-vnc.args
new file mode 100644
index 0000000000..d1fa3e7b8c
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-mdev-display-vnc.args
@@ -0,0 +1,31 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest2 \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest2/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot c \
+-usb \
+-drive file=/dev/HostVG/QEMUGuest2,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 \
+-vnc 127.0.0.1:0 \
+-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0,\
+addr=0x2 \
+-device vfio-pci,id=hostdev0,\
+sysfsdev=/sys/bus/mdev/devices/53764d0e-85a0-42b4-af5c-2046b460b1dc,display=on,\
+bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/hostdev-mdev-display-vnc.xml
b/tests/qemuxml2argvdata/hostdev-mdev-display-vnc.xml
new file mode 100644
index 0000000000..f5b3575c04
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-mdev-display-vnc.xml
@@ -0,0 +1,39 @@
+<domain type='qemu' id='1'>
+ <name>QEMUGuest2</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest2'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0'
target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='ide' index='0'>
+ </controller>
+ <graphics type='vnc'/>
+ <hostdev mode='subsystem' type='mdev' model='vfio-pci'
display='on'>
+ <source>
+ <address uuid='53764d0e-85a0-42b4-af5c-2046b460b1dc'/>
+ </source>
+ </hostdev>
+ <video>
+ <model type='qxl' heads='1'/>
+ </video>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 26f40d3144..0a289ca9cf 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1591,6 +1591,37 @@ mymain(void)
QEMU_CAPS_DEVICE_VFIO_PCI);
DO_TEST_PARSE_ERROR("hostdev-mdev-invalid-target-address",
QEMU_CAPS_DEVICE_VFIO_PCI);
+ DO_TEST("hostdev-mdev-display-spice-opengl",
+ QEMU_CAPS_SPICE,
+ QEMU_CAPS_SPICE_GL,
+ QEMU_CAPS_SPICE_RENDERNODE,
+ QEMU_CAPS_DEVICE_QXL,
+ QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
+ QEMU_CAPS_DEVICE_VFIO_PCI,
+ QEMU_CAPS_VFIO_PCI_DISPLAY);
+ DO_TEST("hostdev-mdev-display-spice-egl-headless",
+ QEMU_CAPS_SPICE,
+ QEMU_CAPS_EGL_HEADLESS,
+ QEMU_CAPS_DEVICE_QXL,
+ QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
+ QEMU_CAPS_DEVICE_VFIO_PCI,
+ QEMU_CAPS_VFIO_PCI_DISPLAY);
+ DO_TEST("hostdev-mdev-display-vnc",
+ QEMU_CAPS_VNC,
+ QEMU_CAPS_DEVICE_QXL,
+ QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
+ QEMU_CAPS_DEVICE_VFIO_PCI,
+ QEMU_CAPS_VFIO_PCI_DISPLAY);
+ DO_TEST("hostdev-mdev-display-vnc-egl-headless",
+ QEMU_CAPS_VNC,
+ QEMU_CAPS_EGL_HEADLESS,
+ QEMU_CAPS_DEVICE_QXL,
+ QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
+ QEMU_CAPS_DEVICE_VFIO_PCI,
+ QEMU_CAPS_VFIO_PCI_DISPLAY);
+ DO_TEST_PARSE_ERROR("hostdev-mdev-display-missing-graphics",
+ QEMU_CAPS_DEVICE_VFIO_PCI,
+ QEMU_CAPS_VFIO_PCI_DISPLAY);
DO_TEST("pci-rom", NONE);
DO_TEST("pci-rom-disabled", NONE);
DO_TEST("pci-rom-disabled-invalid", NONE);
--
2.14.4