diff mbox series

[v2,3/5] conf: domain: move video type validation to DeviceDefValidate

Message ID ef00e04e8f3a962c9256e976cc92997c2160a845.1503846114.git.crobinso@redhat.com
State Accepted
Commit 29a90f071dd7c1764f82c7fcbfdded35d252b174
Headers show
Series qemu: Default to video type=virtio for machvirt | expand

Commit Message

Cole Robinson Aug. 27, 2017, 3:04 p.m. UTC
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@redhat.com>

---
 src/conf/domain_conf.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

-- 
2.13.5

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

Comments

Pavel Hrdina Aug. 28, 2017, 10:24 a.m. UTC | #1
On Sun, Aug 27, 2017 at 11:04:40AM -0400, Cole Robinson wrote:
> 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@redhat.com>

> ---

>  src/conf/domain_conf.c | 28 ++++++++++++++++------------

>  1 file changed, 16 insertions(+), 12 deletions(-)


Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox series

Patch

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a6b793075..e902ea9a8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5314,7 +5314,18 @@  virDomainHostdevDefValidate(const virDomainHostdevDef *hostdev)
             break;
         }
     }
+    return 0;
+}
+
 
+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;
 }
 
@@ -5348,11 +5359,13 @@  virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev,
     case VIR_DOMAIN_DEVICE_HOSTDEV:
         return virDomainHostdevDefValidate(dev->data.hostdev);
 
+    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_WATCHDOG:
     case VIR_DOMAIN_DEVICE_GRAPHICS:
     case VIR_DOMAIN_DEVICE_HUB:
@@ -13866,7 +13879,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;
     }
 }
 
@@ -14015,11 +14028,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) {
@@ -21223,11 +21232,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;