qemu_command: properly detect which model to use for video device

This improves commit 706b5b6277 in a way that we check qemu capabilities
instead of what architecture we are running on to detect whether we can
use *virtio-vga* model or not.  This is not a case only for arm/aarch64.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Pavel Hrdina 2016-09-30 14:41:37 +02:00
parent 6869428c12
commit 4c029e8cfa
9 changed files with 80 additions and 6 deletions

View File

@ -4266,10 +4266,8 @@ qemuBuildDeviceVideoStr(const virDomainDef *def,
virDomainVideoTypeToString(video->type));
goto error;
}
if (video->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO &&
qemuDomainMachineIsVirt(def)) {
if (!qemuDomainSupportsVideoVga(video, qemuCaps))
model = "virtio-gpu-pci";
}
} else {
model = "qxl";
}

View File

@ -6244,3 +6244,15 @@ qemuDomainCheckMonitor(virQEMUDriverPtr driver,
return ret;
}
bool
qemuDomainSupportsVideoVga(virDomainVideoDefPtr video,
virQEMUCapsPtr qemuCaps)
{
if (video->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO &&
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_VGA))
return false;
return true;
}

View File

@ -738,4 +738,7 @@ int qemuDomainCheckMonitor(virQEMUDriverPtr driver,
virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob);
bool qemuDomainSupportsVideoVga(virDomainVideoDefPtr video,
virQEMUCapsPtr qemuCaps);
#endif /* __QEMU_DOMAIN_H__ */

View File

@ -20,5 +20,5 @@ QEMU_AUDIO_DRV=none \
-drive file=/var/lib/libvirt/images/QEMUGuest1,format=qcow2,if=none,\
id=drive-ide0-0-0,cache=none \
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
-device virtio-vga,id=video0,bus=pci.0,addr=0x2 \
-device virtio-gpu-pci,id=video0,bus=pci.0,addr=0x2 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3

View File

@ -20,5 +20,5 @@ QEMU_AUDIO_DRV=spice \
id=drive-ide0-0-0,cache=none \
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
-spice port=0,gl=on \
-device virtio-vga,id=video0,virgl=on,bus=pci.0,addr=0x2 \
-device virtio-gpu-pci,id=video0,virgl=on,bus=pci.0,addr=0x2 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3

View File

@ -20,5 +20,5 @@ QEMU_AUDIO_DRV=none \
-drive file=/var/lib/libvirt/images/QEMUGuest1,format=qcow2,if=none,\
id=drive-ide0-0-0,cache=none \
-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-gpu-pci,id=video0,virgl=on,bus=pci.0,addr=0x2 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3

View File

@ -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 1024 \
-smp 1,sockets=1,cores=1,threads=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=/var/lib/libvirt/images/QEMUGuest1,format=qcow2,if=none,\
id=drive-ide0-0-0,cache=none \
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
-device virtio-vga,id=video0,bus=pci.0,addr=0x2 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3

View File

@ -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'/>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<video>
<model type='virtio' heads='1'/>
</video>
<memballoon model='virtio'/>
</devices>
</domain>

View File

@ -1616,6 +1616,10 @@ mymain(void)
QEMU_CAPS_SPICE,
QEMU_CAPS_SPICE_GL,
QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
DO_TEST("video-virtio-vga",
QEMU_CAPS_DEVICE_VIRTIO_GPU,
QEMU_CAPS_DEVICE_VIRTIO_VGA,
QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
DO_TEST_PARSE_ERROR("video-invalid", NONE);
DO_TEST("virtio-rng-default", QEMU_CAPS_DEVICE_VIRTIO_RNG,