[libvirt] [PATCH 3/8] qemu: annotate some VIDEO_TYPE enum switch

Cole Robinson crobinso at redhat.com
Wed Jun 28 18:49:29 UTC 2017


For the ram/vram monitor wrappers, just add a default: clause...
seems like it should be rarely extended so this saves every committer
from needing to update

For the validation switch, fill in the missing values

Signed-off-by: Cole Robinson <crobinso at redhat.com>
---
 src/qemu/qemu_domain.c       |  3 ++-
 src/qemu/qemu_monitor_json.c | 16 ++++------------
 src/qemu/qemu_process.c      |  7 ++-----
 3 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 90f489840..ac1bc1a1e 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2950,10 +2950,11 @@ qemuDomainDefValidateVideo(const virDomainDef *def)
     for (i = 0; i < def->nvideos; i++) {
         video = def->videos[i];
 
-        switch (video->type) {
+        switch ((virDomainVideoType) video->type) {
         case VIR_DOMAIN_VIDEO_TYPE_XEN:
         case VIR_DOMAIN_VIDEO_TYPE_VBOX:
         case VIR_DOMAIN_VIDEO_TYPE_PARALLELS:
+        case VIR_DOMAIN_VIDEO_TYPE_GOP:
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("video type '%s' is not supported with QEMU"),
                            virDomainVideoTypeToString(video->type));
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 5ddc09ca6..2afc03329 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -1565,7 +1565,7 @@ qemuMonitorJSONUpdateVideoMemorySize(qemuMonitorPtr mon,
         {0}
     };
 
-    switch (video->type) {
+    switch ((virDomainVideoType) video->type) {
     case VIR_DOMAIN_VIDEO_TYPE_VGA:
         if (qemuMonitorJSONGetObjectProperty(mon, path, "vgamem_mb", &prop) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -1608,10 +1608,7 @@ qemuMonitorJSONUpdateVideoMemorySize(qemuMonitorPtr mon,
         }
         video->vram = prop.val.ul * 1024;
         break;
-    case VIR_DOMAIN_VIDEO_TYPE_CIRRUS:
-    case VIR_DOMAIN_VIDEO_TYPE_XEN:
-    case VIR_DOMAIN_VIDEO_TYPE_VBOX:
-    case VIR_DOMAIN_VIDEO_TYPE_LAST:
+    default:
         break;
     }
 
@@ -1635,7 +1632,7 @@ qemuMonitorJSONUpdateVideoVram64Size(qemuMonitorPtr mon,
         {0}
     };
 
-    switch (video->type) {
+    switch ((virDomainVideoType) video->type) {
     case VIR_DOMAIN_VIDEO_TYPE_QXL:
         if (video->vram64 != 0) {
             if (qemuMonitorJSONGetObjectProperty(mon, path,
@@ -1648,12 +1645,7 @@ qemuMonitorJSONUpdateVideoVram64Size(qemuMonitorPtr mon,
             video->vram64 = prop.val.ul * 1024;
         }
         break;
-    case VIR_DOMAIN_VIDEO_TYPE_VGA:
-    case VIR_DOMAIN_VIDEO_TYPE_VMVGA:
-    case VIR_DOMAIN_VIDEO_TYPE_CIRRUS:
-    case VIR_DOMAIN_VIDEO_TYPE_XEN:
-    case VIR_DOMAIN_VIDEO_TYPE_VBOX:
-    case VIR_DOMAIN_VIDEO_TYPE_LAST:
+    default:
         break;
     }
 
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index d669dfb32..fb6e2c82b 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2605,7 +2605,7 @@ qemuProcessUpdateVideoRamSize(virQEMUDriverPtr driver,
     for (i = 0; i < vm->def->nvideos; i++) {
         video = vm->def->videos[i];
 
-        switch (video->type) {
+        switch ((virDomainVideoType) video->type) {
         case VIR_DOMAIN_VIDEO_TYPE_VGA:
             if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VGA_VGAMEM)) {
                 if (qemuMonitorUpdateVideoMemorySize(priv->mon, video, "VGA") < 0)
@@ -2642,10 +2642,7 @@ qemuProcessUpdateVideoRamSize(virQEMUDriverPtr driver,
                     goto error;
             }
             break;
-        case VIR_DOMAIN_VIDEO_TYPE_CIRRUS:
-        case VIR_DOMAIN_VIDEO_TYPE_XEN:
-        case VIR_DOMAIN_VIDEO_TYPE_VBOX:
-        case VIR_DOMAIN_VIDEO_TYPE_LAST:
+        default:
             break;
         }
 
-- 
2.13.0




More information about the libvir-list mailing list