
On 25.11.2015 09:42, Marc-André Lureau wrote:
Check if virtio-gpu provides virgl option, and add qemu command line formatter.
It is enabled with the existing accel3d attribute: <model type='virtio' heads='1'> <acceleration accel3d='yes'/> </model>
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com> --- src/qemu/qemu_capabilities.c | 7 ++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 17 +++- tests/qemucapabilitiesdata/caps_1.2.2-1.replies | 22 +++-- tests/qemucapabilitiesdata/caps_1.3.1-1.replies | 22 +++-- tests/qemucapabilitiesdata/caps_1.4.2-1.replies | 22 +++-- tests/qemucapabilitiesdata/caps_1.5.3-1.replies | 22 +++-- tests/qemucapabilitiesdata/caps_1.6.0-1.replies | 22 +++-- tests/qemucapabilitiesdata/caps_1.6.50-1.replies | 22 +++-- tests/qemucapabilitiesdata/caps_2.1.1-1.replies | 22 +++-- tests/qemucapabilitiesdata/caps_2.4.0-1.replies | 95 ++++++++++++++++++-- tests/qemucapabilitiesdata/caps_2.5.0-1.caps | 1 + tests/qemucapabilitiesdata/caps_2.5.0-1.replies | 100 +++++++++++++++++++-- .../qemuxml2argv-video-virtio-gpu-virgl.args | 23 +++++ .../qemuxml2argv-video-virtio-gpu-virgl.xml | 33 +++++++ tests/qemuxml2argvtest.c | 4 + tests/qemuxml2xmltest.c | 1 + 17 files changed, 372 insertions(+), 64 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-virgl.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-virgl.xml
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 887c87e..2808960 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5896,7 +5896,22 @@ qemuBuildDeviceVideoStr(virDomainDefPtr def,
virBufferAsprintf(&buf, "%s,id=%s", model, video->info.alias);
- if (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL) { + if (video->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO) { + if (video->accel) { + if (video->accel->accel3d && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_GPU_VIRGL)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("virtio-gpu 3d acceleration is not supported")); + goto error; + } + + if (video->accel->accel3d) { + virBufferAsprintf(&buf, ",virgl=%s", + virTristateSwitchTypeToString(video->accel->accel3d)); + } + }
Or shorter: if (accel && accel3d) { if (!qemuSupport) { reportError; goto error; } virBufferAsprintf(); }
+ + } else if (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL) { if (video->vram > (UINT_MAX / 1024)) { virReportError(VIR_ERR_OVERFLOW, _("value for 'vram' must be less than '%u'"),
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-virgl.args b/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-virgl.args new file mode 100644 index 0000000..35051ea --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-virgl.args @@ -0,0 +1,23 @@ +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 1024 \ +-smp 1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/test-monitor,server,nowait \ +-no-acpi \ +-boot c \ +-usb \ +-drive file=/var/lib/libvirt/images/QEMUGuest1,if=none,id=drive-ide0-0-0,format=qcow2,cache=none \
Yet another long line. 'make syntax-check' would have caught this.
+-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ +-device virtio-vga,id=video0,virgl=on,bus=pci.0,addr=0x2 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-virgl.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-virgl.xml new file mode 100644 index 0000000..0227424 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-virgl.xml @@ -0,0 +1,33 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</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</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='qcow2' cache='none'/> + <source file='/var/lib/libvirt/images/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <controller type='ide' index='0'/> + <controller type='usb' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <video> + <model type='virtio' heads='1'> + <acceleration accel3d='yes'/> + </model> + </video> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 1bb0bde..4baadb7 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1751,6 +1751,10 @@ mymain(void) DO_TEST("video-virtio-gpu-device", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VIRTIO_GPU, QEMU_CAPS_DEVICE_VIDEO_PRIMARY); + DO_TEST("video-virtio-gpu-virgl", + QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_DEVICE_VIRTIO_GPU_VIRGL, + QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
And again, I'd move this to the rest of video-* tests.
qemuTestDriverFree(&driver);
ACK Michal