[libvirt PATCH v2 3/6] conf: use enum variable for video type

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

 



Rather than storing the video type as an integer, use the proper enum
type within the struct.

Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
---
 src/conf/domain_conf.c       |  4 +---
 src/conf/domain_conf.h       |  2 +-
 src/libxl/libxl_conf.c       | 10 ++++++++++
 src/libxl/libxl_domain.c     | 11 +++++++++++
 src/qemu/qemu_monitor_json.c | 16 +++++++++++++++-
 src/qemu/qemu_process.c      |  7 +++++++
 6 files changed, 45 insertions(+), 5 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3a97358a11..39aa6a1058 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -14074,7 +14074,6 @@ virDomainVideoModelDefParseXML(virDomainVideoDef *def,
 {
     xmlNodePtr accel_node;
     xmlNodePtr res_node;
-    virDomainVideoType type;
     virTristateBool primary;
     int rc = 0;
 
@@ -14094,10 +14093,9 @@ virDomainVideoModelDefParseXML(virDomainVideoDef *def,
 
     if (virXMLPropEnumDefault(node, "type",
                               virDomainVideoTypeFromString,
-                              VIR_XML_PROP_NONE, &type,
+                              VIR_XML_PROP_NONE, &def->type,
                               VIR_DOMAIN_VIDEO_TYPE_DEFAULT) < 0)
         return -1;
-    def->type = type;
 
     if (virXMLPropUInt(node, "ram", 10, VIR_XML_PROP_NONE, &def->ram) < 0)
         return -1;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 9fcf842ee7..fa64491978 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1727,7 +1727,7 @@ struct _virDomainVideoDriverDef {
 struct _virDomainVideoDef {
     virObject *privateData;
 
-    int type;   /* enum virDomainVideoType */
+    virDomainVideoType type;
     unsigned int ram;  /* kibibytes (multiples of 1024) */
     unsigned int vram; /* kibibytes (multiples of 1024) */
     unsigned int vram64; /* kibibytes (multiples of 1024) */
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index a0fc51c74a..1a608960b1 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -2364,6 +2364,16 @@ libxlMakeVideo(virDomainDef *def, libxl_domain_config *d_config)
             }
             break;
 
+        case VIR_DOMAIN_VIDEO_TYPE_DEFAULT:
+        case VIR_DOMAIN_VIDEO_TYPE_VMVGA:
+        case VIR_DOMAIN_VIDEO_TYPE_VBOX:
+        case VIR_DOMAIN_VIDEO_TYPE_PARALLELS:
+        case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
+        case VIR_DOMAIN_VIDEO_TYPE_GOP:
+        case VIR_DOMAIN_VIDEO_TYPE_NONE:
+        case VIR_DOMAIN_VIDEO_TYPE_BOCHS:
+        case VIR_DOMAIN_VIDEO_TYPE_RAMFB:
+        case VIR_DOMAIN_VIDEO_TYPE_LAST:
         default:
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("video type %s is not supported by libxl"),
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index ee031267ca..d4ba030c2a 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -331,6 +331,17 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDef *dev,
                     if (dev->data.video->vram == 0)
                         dev->data.video->vram = 128 * 1024;
                     break;
+                case VIR_DOMAIN_VIDEO_TYPE_DEFAULT:
+                case VIR_DOMAIN_VIDEO_TYPE_VMVGA:
+                case VIR_DOMAIN_VIDEO_TYPE_VBOX:
+                case VIR_DOMAIN_VIDEO_TYPE_PARALLELS:
+                case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
+                case VIR_DOMAIN_VIDEO_TYPE_GOP:
+                case VIR_DOMAIN_VIDEO_TYPE_NONE:
+                case VIR_DOMAIN_VIDEO_TYPE_BOCHS:
+                case VIR_DOMAIN_VIDEO_TYPE_RAMFB:
+                case VIR_DOMAIN_VIDEO_TYPE_LAST:
+                    break;
             }
         }
     }
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 4d339f29b8..791463e2bb 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -1897,9 +1897,16 @@ qemuMonitorJSONUpdateVideoMemorySize(qemuMonitor *mon,
         }
         video->vram = prop.val.ul * 1024;
         break;
+    case VIR_DOMAIN_VIDEO_TYPE_DEFAULT:
     case VIR_DOMAIN_VIDEO_TYPE_CIRRUS:
     case VIR_DOMAIN_VIDEO_TYPE_XEN:
     case VIR_DOMAIN_VIDEO_TYPE_VBOX:
+    case VIR_DOMAIN_VIDEO_TYPE_PARALLELS:
+    case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
+    case VIR_DOMAIN_VIDEO_TYPE_GOP:
+    case VIR_DOMAIN_VIDEO_TYPE_NONE:
+    case VIR_DOMAIN_VIDEO_TYPE_BOCHS:
+    case VIR_DOMAIN_VIDEO_TYPE_RAMFB:
     case VIR_DOMAIN_VIDEO_TYPE_LAST:
         break;
     }
@@ -1937,11 +1944,18 @@ qemuMonitorJSONUpdateVideoVram64Size(qemuMonitor *mon,
             video->vram64 = prop.val.ul * 1024;
         }
         break;
+    case VIR_DOMAIN_VIDEO_TYPE_DEFAULT:
     case VIR_DOMAIN_VIDEO_TYPE_VGA:
-    case VIR_DOMAIN_VIDEO_TYPE_VMVGA:
     case VIR_DOMAIN_VIDEO_TYPE_CIRRUS:
+    case VIR_DOMAIN_VIDEO_TYPE_VMVGA:
     case VIR_DOMAIN_VIDEO_TYPE_XEN:
     case VIR_DOMAIN_VIDEO_TYPE_VBOX:
+    case VIR_DOMAIN_VIDEO_TYPE_PARALLELS:
+    case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
+    case VIR_DOMAIN_VIDEO_TYPE_GOP:
+    case VIR_DOMAIN_VIDEO_TYPE_NONE:
+    case VIR_DOMAIN_VIDEO_TYPE_BOCHS:
+    case VIR_DOMAIN_VIDEO_TYPE_RAMFB:
     case VIR_DOMAIN_VIDEO_TYPE_LAST:
         break;
     }
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 5af925e521..bdb213b7c8 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3097,9 +3097,16 @@ qemuProcessUpdateVideoRamSize(virQEMUDriver *driver,
                     goto error;
             }
             break;
+        case VIR_DOMAIN_VIDEO_TYPE_DEFAULT:
         case VIR_DOMAIN_VIDEO_TYPE_CIRRUS:
         case VIR_DOMAIN_VIDEO_TYPE_XEN:
         case VIR_DOMAIN_VIDEO_TYPE_VBOX:
+        case VIR_DOMAIN_VIDEO_TYPE_PARALLELS:
+        case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
+        case VIR_DOMAIN_VIDEO_TYPE_GOP:
+        case VIR_DOMAIN_VIDEO_TYPE_NONE:
+        case VIR_DOMAIN_VIDEO_TYPE_BOCHS:
+        case VIR_DOMAIN_VIDEO_TYPE_RAMFB:
         case VIR_DOMAIN_VIDEO_TYPE_LAST:
             break;
         }
-- 
2.35.1




[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