[PATCH 2/5] qemu: Validate video model

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The aim is to eliminate virDomainCapsDeviceDefValidate(). And in
order to do so, the domain video model has to be validated in
qemuValidateDomainDeviceDefVideo().

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/conf/domain_capabilities.c                | 19 +--------
 src/qemu/qemu_validate.c                      | 42 +++++++++++++++++++
 .../default-video-type-x86_64-caps-test-0.err |  2 +-
 .../video-invalid-multiple-devices.err        |  2 +-
 4 files changed, 45 insertions(+), 20 deletions(-)

diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index b886ba7090..0e0e6d1600 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -640,22 +640,8 @@ virDomainCapsFormat(const virDomainCaps *caps)
     } while (0)
 
 
-static int
-virDomainCapsDeviceVideoDefValidate(const virDomainCaps *caps,
-                                    const virDomainVideoDef *dev)
-{
-    if (ENUM_VALUE_MISSING(caps->video.modelType, dev->type)) {
-        ENUM_VALUE_ERROR("video model",
-                         virDomainVideoTypeToString(dev->type));
-        return -1;
-    }
-
-    return 0;
-}
-
-
 int
-virDomainCapsDeviceDefValidate(const virDomainCaps *caps,
+virDomainCapsDeviceDefValidate(const virDomainCaps *caps G_GNUC_UNUSED,
                                const virDomainDeviceDef *dev,
                                const virDomainDef *def G_GNUC_UNUSED)
 {
@@ -663,9 +649,6 @@ virDomainCapsDeviceDefValidate(const virDomainCaps *caps,
 
     switch ((virDomainDeviceType) dev->type) {
     case VIR_DOMAIN_DEVICE_VIDEO:
-        ret = virDomainCapsDeviceVideoDefValidate(caps, dev->data.video);
-        break;
-
     case VIR_DOMAIN_DEVICE_AUDIO:
         /* TODO: add validation */
         break;
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index c18865367e..4defdb02cf 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -2203,10 +2203,52 @@ static int
 qemuValidateDomainDeviceDefVideo(const virDomainVideoDef *video,
                                  virQEMUCapsPtr qemuCaps)
 {
+    virQEMUCapsFlags cap = QEMU_CAPS_LAST;
+
     /* there's no properties to validate for NONE video devices */
     if (video->type == VIR_DOMAIN_VIDEO_TYPE_NONE)
         return 0;
 
+    switch ((virDomainVideoType) video->type) {
+    case VIR_DOMAIN_VIDEO_TYPE_VGA:
+        cap = QEMU_CAPS_DEVICE_VGA;
+        break;
+    case VIR_DOMAIN_VIDEO_TYPE_CIRRUS:
+        cap = QEMU_CAPS_DEVICE_CIRRUS_VGA;
+        break;
+    case VIR_DOMAIN_VIDEO_TYPE_VMVGA:
+        cap = QEMU_CAPS_DEVICE_VMWARE_SVGA;
+        break;
+    case VIR_DOMAIN_VIDEO_TYPE_QXL:
+        cap = QEMU_CAPS_DEVICE_QXL;
+        break;
+    case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
+        cap = QEMU_CAPS_DEVICE_VIRTIO_GPU;
+        break;
+    case VIR_DOMAIN_VIDEO_TYPE_BOCHS:
+        cap = QEMU_CAPS_DEVICE_BOCHS_DISPLAY;
+        break;
+    case VIR_DOMAIN_VIDEO_TYPE_RAMFB:
+        cap = QEMU_CAPS_DEVICE_RAMFB;
+        break;
+    case VIR_DOMAIN_VIDEO_TYPE_DEFAULT:
+    case VIR_DOMAIN_VIDEO_TYPE_XEN:
+    case VIR_DOMAIN_VIDEO_TYPE_VBOX:
+    case VIR_DOMAIN_VIDEO_TYPE_PARALLELS:
+    case VIR_DOMAIN_VIDEO_TYPE_GOP:
+    case VIR_DOMAIN_VIDEO_TYPE_NONE:
+    case VIR_DOMAIN_VIDEO_TYPE_LAST:
+        /* nada */
+        break;
+    }
+
+    if (!virQEMUCapsGet(qemuCaps, cap)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("domain configuration does not support video model '%s'"),
+                       virDomainVideoTypeToString(video->type));
+        return -1;
+    }
+
     if (!video->primary &&
         video->type != VIR_DOMAIN_VIDEO_TYPE_QXL &&
         video->type != VIR_DOMAIN_VIDEO_TYPE_VIRTIO) {
diff --git a/tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-0.err b/tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-0.err
index 82576471b7..f7b6b57926 100644
--- a/tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-0.err
+++ b/tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-0.err
@@ -1 +1 @@
-unsupported configuration: domain configuration does not support 'video model' value 'default'
+unsupported configuration: domain configuration does not support video model 'default'
diff --git a/tests/qemuxml2argvdata/video-invalid-multiple-devices.err b/tests/qemuxml2argvdata/video-invalid-multiple-devices.err
index 7fc20b2370..5c1e557021 100644
--- a/tests/qemuxml2argvdata/video-invalid-multiple-devices.err
+++ b/tests/qemuxml2argvdata/video-invalid-multiple-devices.err
@@ -1 +1 @@
-unsupported configuration: domain configuration does not support 'video model' value 'qxl'
+unsupported configuration: domain configuration does not support video model 'qxl'
-- 
2.26.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux