]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu_command: properly detect which model to use for video device
authorPavel Hrdina <phrdina@redhat.com>
Fri, 30 Sep 2016 12:41:37 +0000 (14:41 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Wed, 12 Oct 2016 15:46:48 +0000 (17:46 +0200)
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>
src/qemu/qemu_command.c
src/qemu/qemu_domain.c
src/qemu/qemu_domain.h
tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-device.args
tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-spice-gl.args
tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-virgl.args
tests/qemuxml2argvdata/qemuxml2argv-video-virtio-vga.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-video-virtio-vga.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c

index 97e6e373ef635bcd45b11513c157afc689634325..2cd3f9dd03c265cb66ed359d70931c5d84f0cbb2 100644 (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";
     }
index c9378586b32f3d6c96d2587ba92dd79ad014e768..98fb2e52c7fecde7ff9a76805bea9ded3c8c0c62 100644 (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;
+}
index 521531be03460d21dc47296c3e61e172e630b579..dee5d93bc9693d7a51485b7e21773eb04b61bd94 100644 (file)
@@ -738,4 +738,7 @@ int qemuDomainCheckMonitor(virQEMUDriverPtr driver,
                            virDomainObjPtr vm,
                            qemuDomainAsyncJob asyncJob);
 
+bool qemuDomainSupportsVideoVga(virDomainVideoDefPtr video,
+                                virQEMUCapsPtr qemuCaps);
+
 #endif /* __QEMU_DOMAIN_H__ */
index fefa2b694377247fa8ff869249df89b6ee1a1146..110740925011ddd701c0c07be9ffa008d262f8ac 100644 (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
index 88444983c35daf379279cb35d8b5c2ae6bc2da1d..f1ebb62e44f89621d3de407aaad7ef3d114cbbd8 100644 (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
index 6a553117c1340f39eb04f79df5fc185391b4582d..0131be8ddb7b270d47e7c060fcc89c7eb04fa5cd 100644 (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
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-vga.args b/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-vga.args
new file mode 100644 (file)
index 0000000..fefa2b6
--- /dev/null
@@ -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
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-vga.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-vga.xml
new file mode 100644 (file)
index 0000000..e3d28bb
--- /dev/null
@@ -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>
index 60ed9f13b3648dc586d852fc5a558b102e632ae0..5adb2fdddbb8bc4527943936f6b823b37b94ba04 100644 (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,