[PATCH 3/5] qemu: Create a proper type for migration status enum

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

 



The enum will be called qemuMonitorMigrationStatus.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/qemu/qemu_migration.c    |  3 ++-
 src/qemu/qemu_monitor.h      |  6 +++---
 src/qemu/qemu_monitor_json.c | 24 ++++++++++++++++++------
 3 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 855e0e0..524102d 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2518,7 +2518,7 @@ qemuMigrationWaitForSpice(virDomainObjPtr vm)
 static void
 qemuMigrationUpdateJobType(qemuDomainJobInfoPtr jobInfo)
 {
-    switch (jobInfo->stats.status) {
+    switch ((qemuMonitorMigrationStatus) jobInfo->stats.status) {
     case QEMU_MONITOR_MIGRATION_STATUS_COMPLETED:
         jobInfo->type = VIR_DOMAIN_JOB_COMPLETED;
         break;
@@ -2538,6 +2538,7 @@ qemuMigrationUpdateJobType(qemuDomainJobInfoPtr jobInfo)
     case QEMU_MONITOR_MIGRATION_STATUS_SETUP:
     case QEMU_MONITOR_MIGRATION_STATUS_ACTIVE:
     case QEMU_MONITOR_MIGRATION_STATUS_CANCELLING:
+    case QEMU_MONITOR_MIGRATION_STATUS_LAST:
         break;
     }
 }
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 27ff169..4f1c8d3 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -455,7 +455,7 @@ int qemuMonitorGetMigrationCacheSize(qemuMonitorPtr mon,
 int qemuMonitorSetMigrationCacheSize(qemuMonitorPtr mon,
                                      unsigned long long cacheSize);
 
-enum {
+typedef enum {
     QEMU_MONITOR_MIGRATION_STATUS_INACTIVE,
     QEMU_MONITOR_MIGRATION_STATUS_SETUP,
     QEMU_MONITOR_MIGRATION_STATUS_ACTIVE,
@@ -465,14 +465,14 @@ enum {
     QEMU_MONITOR_MIGRATION_STATUS_CANCELLED,
 
     QEMU_MONITOR_MIGRATION_STATUS_LAST
-};
+} qemuMonitorMigrationStatus;
 
 VIR_ENUM_DECL(qemuMonitorMigrationStatus)
 
 typedef struct _qemuMonitorMigrationStats qemuMonitorMigrationStats;
 typedef qemuMonitorMigrationStats *qemuMonitorMigrationStatsPtr;
 struct _qemuMonitorMigrationStats {
-    int status;
+    int status; /* qemuMonitorMigrationStatus */
     unsigned long long total_time;
     /* total or expected depending on status */
     bool downtime_set;
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 2d3b358..50d05b4 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2425,6 +2425,9 @@ qemuMonitorJSONGetMigrationStatsReply(virJSONValuePtr reply,
                                       qemuMonitorMigrationStatsPtr stats)
 {
     virJSONValuePtr ret;
+    virJSONValuePtr ram;
+    virJSONValuePtr disk;
+    virJSONValuePtr comp;
     const char *statusstr;
     int rc;
     double mbps;
@@ -2464,10 +2467,18 @@ qemuMonitorJSONGetMigrationStatsReply(virJSONValuePtr reply,
                                          &stats->setup_time) == 0)
         stats->setup_time_set = true;
 
-    if (stats->status == QEMU_MONITOR_MIGRATION_STATUS_ACTIVE ||
-        stats->status == QEMU_MONITOR_MIGRATION_STATUS_CANCELLING ||
-        stats->status == QEMU_MONITOR_MIGRATION_STATUS_COMPLETED) {
-        virJSONValuePtr ram = virJSONValueObjectGetObject(ret, "ram");
+    switch ((qemuMonitorMigrationStatus) stats->status) {
+    case QEMU_MONITOR_MIGRATION_STATUS_INACTIVE:
+    case QEMU_MONITOR_MIGRATION_STATUS_SETUP:
+    case QEMU_MONITOR_MIGRATION_STATUS_ERROR:
+    case QEMU_MONITOR_MIGRATION_STATUS_CANCELLED:
+    case QEMU_MONITOR_MIGRATION_STATUS_LAST:
+        break;
+
+    case QEMU_MONITOR_MIGRATION_STATUS_ACTIVE:
+    case QEMU_MONITOR_MIGRATION_STATUS_COMPLETED:
+    case QEMU_MONITOR_MIGRATION_STATUS_CANCELLING:
+        ram = virJSONValueObjectGetObject(ret, "ram");
         if (!ram) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("migration was active, but no RAM info was set"));
@@ -2510,7 +2521,7 @@ qemuMonitorJSONGetMigrationStatsReply(virJSONValuePtr reply,
         ignore_value(virJSONValueObjectGetNumberUlong(ram, "normal-bytes",
                                                       &stats->ram_normal_bytes));
 
-        virJSONValuePtr disk = virJSONValueObjectGetObject(ret, "disk");
+        disk = virJSONValueObjectGetObject(ret, "disk");
         if (disk) {
             rc = virJSONValueObjectGetNumberUlong(disk, "transferred",
                                                   &stats->disk_transferred);
@@ -2546,7 +2557,7 @@ qemuMonitorJSONGetMigrationStatsReply(virJSONValuePtr reply,
             }
         }
 
-        virJSONValuePtr comp = virJSONValueObjectGetObject(ret, "xbzrle-cache");
+        comp = virJSONValueObjectGetObject(ret, "xbzrle-cache");
         if (comp) {
             stats->xbzrle_set = true;
             rc = virJSONValueObjectGetNumberUlong(comp, "cache-size",
@@ -2594,6 +2605,7 @@ qemuMonitorJSONGetMigrationStatsReply(virJSONValuePtr reply,
                 return -1;
             }
         }
+        break;
     }
 
     return 0;
-- 
2.7.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]