aboutsummaryrefslogtreecommitdiff
path: root/migration/migration.c
diff options
context:
space:
mode:
authorzhanghailiang <zhang.zhanghailiang@huawei.com>2015-03-13 16:08:40 +0800
committerJuan Quintela <quintela@redhat.com>2015-03-17 15:20:37 +0100
commit24b8c39b5c34b05f1ac870c421e2e61574abbdf9 (patch)
tree80891c0d0feae3ed25d4acbdc7d8bc04ef32171d /migration/migration.c
parente49f35bdb4974d6cfd7e5eb5cb9f8c50eef3f3a9 (diff)
migration: Convert 'status' of MigrationInfo to use an enum type
The original 'status' is an open-coded 'str' type, convert it to use an enum type. This conversion is backwards compatible, better documented and more convenient for future extensibility. In addition, Fix a typo for qapi-schema.json (just remove the typo) : s/'completed'. 'comppleted' (since 1.2)/'completed' (since 1.2) Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
Diffstat (limited to 'migration/migration.c')
-rw-r--r--migration/migration.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/migration/migration.c b/migration/migration.c
index b0860fa5c1..d7a1e7d2a3 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -26,16 +26,6 @@
#include "qmp-commands.h"
#include "trace.h"
-enum {
- MIGRATION_STATUS_FAILED = -1,
- MIGRATION_STATUS_NONE,
- MIGRATION_STATUS_SETUP,
- MIGRATION_STATUS_CANCELLING,
- MIGRATION_STATUS_CANCELLED,
- MIGRATION_STATUS_ACTIVE,
- MIGRATION_STATUS_COMPLETED,
-};
-
#define MAX_THROTTLE (32 << 20) /* Migration speed throttling */
/* Amount of time to allocate to each "chunk" of bandwidth-throttled
@@ -205,13 +195,13 @@ MigrationInfo *qmp_query_migrate(Error **errp)
break;
case MIGRATION_STATUS_SETUP:
info->has_status = true;
- info->status = g_strdup("setup");
+ info->status = MIGRATION_STATUS_SETUP;
info->has_total_time = false;
break;
case MIGRATION_STATUS_ACTIVE:
case MIGRATION_STATUS_CANCELLING:
info->has_status = true;
- info->status = g_strdup("active");
+ info->status = MIGRATION_STATUS_ACTIVE;
info->has_total_time = true;
info->total_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME)
- s->total_time;
@@ -247,7 +237,7 @@ MigrationInfo *qmp_query_migrate(Error **errp)
get_xbzrle_cache_stats(info);
info->has_status = true;
- info->status = g_strdup("completed");
+ info->status = MIGRATION_STATUS_COMPLETED;
info->has_total_time = true;
info->total_time = s->total_time;
info->has_downtime = true;
@@ -269,11 +259,11 @@ MigrationInfo *qmp_query_migrate(Error **errp)
break;
case MIGRATION_STATUS_FAILED:
info->has_status = true;
- info->status = g_strdup("failed");
+ info->status = MIGRATION_STATUS_FAILED;
break;
case MIGRATION_STATUS_CANCELLED:
info->has_status = true;
- info->status = g_strdup("cancelled");
+ info->status = MIGRATION_STATUS_CANCELLED;
break;
}