diff mbox series

[2/8] qemu: domain: Move some validation out of DeviceDefPostParse

Message ID 139fc7181b50d7909d7ac7f4296f4edaf1f22275.1498675591.git.crobinso@redhat.com
State Accepted
Commit 5db046211f27c339bacba216dad646c42b4d52c7
Headers show
Series qemu: Default to video type=virtio for machvirt | expand

Commit Message

Cole Robinson June 28, 2017, 6:49 p.m. UTC
And into DeviceDefValidate which is the expected place

Signed-off-by: Cole Robinson <crobinso@redhat.com>

---
 src/qemu/qemu_domain.c | 55 +++++++++++++++++++++++++++-----------------------
 1 file changed, 30 insertions(+), 25 deletions(-)

-- 
2.13.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Comments

John Ferlan July 18, 2017, 10:20 p.m. UTC | #1
On 06/28/2017 02:49 PM, Cole Robinson wrote:
> And into DeviceDefValidate which is the expected place

> 

> Signed-off-by: Cole Robinson <crobinso@redhat.com>

> ---

>  src/qemu/qemu_domain.c | 55 +++++++++++++++++++++++++++-----------------------

>  1 file changed, 30 insertions(+), 25 deletions(-)

> 


Reviewed-by: John Ferlan <jferlan@redhat.com>


John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox series

Patch

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 8e7404da6..90f489840 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3191,6 +3191,33 @@  qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
         }
     }
 
+    /* forbid capabilities mode hostdev in this kind of hypervisor */
+    if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV &&
+        dev->data.hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("hostdev mode 'capabilities' is not "
+                         "supported in %s"),
+                       virDomainVirtTypeToString(def->virtType));
+        goto cleanup;
+    }
+
+    if (dev->type == VIR_DOMAIN_DEVICE_VIDEO) {
+        if (dev->data.video->type == VIR_DOMAIN_VIDEO_TYPE_QXL &&
+            dev->data.video->vgamem) {
+            if (dev->data.video->vgamem < 1024) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("value for 'vgamem' must be at least 1 MiB "
+                                 "(1024 KiB)"));
+                goto cleanup;
+            }
+            if (dev->data.video->vgamem != VIR_ROUND_UP_POWER_OF_TWO(dev->data.video->vgamem)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("value for 'vgamem' must be power of two"));
+                goto cleanup;
+            }
+        }
+    }
+
     ret = 0;
  cleanup:
     virObjectUnref(cfg);
@@ -3551,31 +3578,9 @@  qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
             goto cleanup;
     }
 
-    /* forbid capabilities mode hostdev in this kind of hypervisor */
-    if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV &&
-        dev->data.hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("hostdev mode 'capabilities' is not "
-                         "supported in %s"),
-                       virDomainVirtTypeToString(def->virtType));
-        goto cleanup;
-    }
-
-    if (dev->type == VIR_DOMAIN_DEVICE_VIDEO &&
-        dev->data.video->type == VIR_DOMAIN_VIDEO_TYPE_QXL) {
-        if (dev->data.video->vgamem) {
-            if (dev->data.video->vgamem < 1024) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("value for 'vgamem' must be at least 1 MiB "
-                                 "(1024 KiB)"));
-                goto cleanup;
-            }
-            if (dev->data.video->vgamem != VIR_ROUND_UP_POWER_OF_TWO(dev->data.video->vgamem)) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("value for 'vgamem' must be power of two"));
-                goto cleanup;
-            }
-        } else {
+    if (dev->type == VIR_DOMAIN_DEVICE_VIDEO) {
+        if (dev->data.video->type == VIR_DOMAIN_VIDEO_TYPE_QXL &&
+            !dev->data.video->vgamem) {
             dev->data.video->vgamem = QEMU_QXL_VGAMEM_DEFAULT;
         }
     }