]> xenbits.xensource.com Git - libvirt.git/commitdiff
domain_conf: Fix str2enum translation of video driver name
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 25 Sep 2019 07:54:49 +0000 (09:54 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 25 Sep 2019 08:02:12 +0000 (10:02 +0200)
In bc1e924cf0d we've introduced video driver name and whilst
doing so we've utilized VIR_ENUM_IMPL() macro. Then, in domain
XML parsing code the generated
virDomainVideoBackendTypeFromString() is called and its return
value is assigned directly to an unsigned int variable which is
wrong. Also, the video driver enum has 'default' value which is
not formatted into domain XML but is accepted during parsing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/domain_conf.c
src/conf/domain_conf.h

index 6dea670257f149d7e626ccc13d578f1830d3976b..67555c9be3e98aa49ee10970e6af8f35c33c5c3b 100644 (file)
@@ -15504,11 +15504,13 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xmlopt,
     }
 
     if (driver_name) {
-        if ((def->backend = virDomainVideoBackendTypeFromString(driver_name)) < 0) {
+        int backend;
+        if ((backend = virDomainVideoBackendTypeFromString(driver_name)) <= 0) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("unknown video driver '%s'"), driver_name);
             goto error;
         }
+        def->backend = backend;
     } else {
         def->backend = VIR_DOMAIN_VIDEO_BACKEND_TYPE_DEFAULT;
     }
index cff33f6682cf913513cb88f08dde14e1f49a1945..53bdee22fb1b3c5abc07e36df31478a9ed53147e 100644 (file)
@@ -1378,7 +1378,7 @@ struct _virDomainWatchdogDef {
 
 /* the backend driver used for virtio interfaces */
 typedef enum {
-    VIR_DOMAIN_VIDEO_BACKEND_TYPE_DEFAULT,
+    VIR_DOMAIN_VIDEO_BACKEND_TYPE_DEFAULT = 0,
     VIR_DOMAIN_VIDEO_BACKEND_TYPE_QEMU,
     VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER,