[PATCH 6/8] conf: domain: move video type validation to DeviceDefValidate

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

 



This allows drivers to set their own default. But if a driver neglects
to fill one in, we still error like we previously would at parse time.

Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 984d15abf..bb61f4091 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5075,6 +5075,18 @@ virDomainControllerDefValidate(const virDomainControllerDef *controller)
 
 
 static int
+virDomainVideoDefValidate(const virDomainVideoDef *video)
+{
+    if (video->type == VIR_DOMAIN_VIDEO_TYPE_DEFAULT) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("missing video model and cannot determine default"));
+        return -1;
+    }
+    return 0;
+}
+
+
+static int
 virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev,
                                    const virDomainDef *def)
 {
@@ -5091,11 +5103,13 @@ virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev,
     case VIR_DOMAIN_DEVICE_CONTROLLER:
         return virDomainControllerDefValidate(dev->data.controller);
 
+    case VIR_DOMAIN_DEVICE_VIDEO:
+        return virDomainVideoDefValidate(dev->data.video);
+
     case VIR_DOMAIN_DEVICE_LEASE:
     case VIR_DOMAIN_DEVICE_FS:
     case VIR_DOMAIN_DEVICE_INPUT:
     case VIR_DOMAIN_DEVICE_SOUND:
-    case VIR_DOMAIN_DEVICE_VIDEO:
     case VIR_DOMAIN_DEVICE_HOSTDEV:
     case VIR_DOMAIN_DEVICE_WATCHDOG:
     case VIR_DOMAIN_DEVICE_GRAPHICS:
@@ -13564,7 +13578,7 @@ virDomainVideoDefaultType(const virDomainDef *def)
     case VIR_DOMAIN_VIRT_BHYVE:
         return VIR_DOMAIN_VIDEO_TYPE_GOP;
     default:
-        return -1;
+        return VIR_DOMAIN_VIDEO_TYPE_DEFAULT;
     }
 }
 
@@ -13709,11 +13723,7 @@ virDomainVideoDefParseXML(xmlNodePtr node,
             goto error;
         }
     } else {
-        if ((def->type = virDomainVideoDefaultType(dom)) < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("missing video model and cannot determine default"));
-            goto error;
-        }
+        def->type = virDomainVideoDefaultType(dom);
     }
 
     if (ram) {
@@ -20960,11 +20970,6 @@ virDomainDefAddImplicitVideo(virDomainDefPtr def)
     if (!(video = virDomainVideoDefNew()))
         goto cleanup;
     video->type = virDomainVideoDefaultType(def);
-    if (video->type < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("cannot determine default video type"));
-        goto cleanup;
-    }
     if (VIR_APPEND_ELEMENT(def->videos, def->nvideos, video) < 0)
         goto cleanup;
 
-- 
2.13.0

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



[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