From b1deb8228c5a450d90a155f1361b99aa2831c845 Mon Sep 17 00:00:00 2001
From: Luiz Capitulino <lcapitulino@redhat.com>
Date: Wed, 19 Oct 2011 14:53:55 +0200
Subject: [PATCH 09/13] RunState: Rename enum values

RH-Author: Luiz Capitulino <lcapitulino@redhat.com>
Message-id: <1319036039-4358-10-git-send-email-lcapitulino@redhat.com>
Patchwork-id: 34413
O-Subject: [PATCH RHEL6.2 qemu-kvm v3 09/13] RunState: Rename enum values
Bugzilla: 617889
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>

This is the RHEL6.2-only equivalent of upstream commit,
0461d5a699cb8825039400b76839115e35b73d65 which renamed the RunState
values as generated by the QAPI.

Please, note that this RHEL6.2-only version of the renaming was done
by hand, because it's easier that way and I don't plan backporting
the QAPI either.

The other option (ie. to backport commit 0461d5a699) would require
to also backport the following two commits:

0d45b702918f855c24bfd13c0f91b31f89c2e097
c4d11e38bd475f33d5fa9ceba5292304727f3113

Which will generate endless conflicts...

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 blockdev.c      |    2 +-
 gdbstub.c       |   12 +++---
 hw/ide/core.c   |    2 +-
 hw/scsi-disk.c  |    2 +-
 hw/virtio-blk.c |    2 +-
 hw/watchdog.c   |    2 +-
 kvm-all.c       |    2 +-
 migration.c     |    6 +-
 monitor.c       |   10 ++--
 qemu-kvm.c      |   14 +++---
 savevm.c        |    4 +-
 sysemu.h        |   30 +++++++-------
 vl.c            |  120 +++++++++++++++++++++++++++---------------------------
 13 files changed, 104 insertions(+), 104 deletions(-)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 blockdev.c      |    2 +-
 gdbstub.c       |   12 +++---
 hw/ide/core.c   |    2 +-
 hw/scsi-disk.c  |    2 +-
 hw/virtio-blk.c |    2 +-
 hw/watchdog.c   |    2 +-
 kvm-all.c       |    2 +-
 migration.c     |    6 +-
 monitor.c       |   10 ++--
 qemu-kvm.c      |   14 +++---
 savevm.c        |    4 +-
 sysemu.h        |   30 +++++++-------
 vl.c            |  122 +++++++++++++++++++++++++++---------------------------
 13 files changed, 105 insertions(+), 105 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index 6c79a24..4ef24a7 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -425,7 +425,7 @@ static int drive_open(DriveInfo *dinfo)
     int res;
     int bdrv_flags = dinfo->bdrv_flags;
 
-    if (runstate_check(RSTATE_IN_MIGRATE)) {
+    if (runstate_check(RUN_STATE_INMIGRATE)) {
         bdrv_flags |= BDRV_O_INCOMING;
     }
 
diff --git a/gdbstub.c b/gdbstub.c
index d8d5bcd..9c55403 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -2125,14 +2125,14 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state)
     const char *type;
     int ret;
 
-    if (running || (state != RSTATE_DEBUG && state != RSTATE_PAUSED) ||
+    if (running || (state != RUN_STATE_DEBUG && state != RUN_STATE_PAUSED) ||
         s->state == RS_INACTIVE || s->state == RS_SYSCALL)
         return;
 
     /* disable single step if it was enable */
     cpu_single_step(env, 0);
 
-    if (state == RSTATE_DEBUG) {
+    if (state == RUN_STATE_DEBUG) {
         if (env->watchpoint_hit) {
             switch (env->watchpoint_hit->flags & BP_MEM_ACCESS) {
             case BP_MEM_READ:
@@ -2183,7 +2183,7 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...)
     gdb_current_syscall_cb = cb;
     s->state = RS_SYSCALL;
 #ifndef CONFIG_USER_ONLY
-    vm_stop(RSTATE_DEBUG);
+    vm_stop(RUN_STATE_DEBUG);
 #endif
     s->state = RS_IDLE;
     va_start(va, fmt);
@@ -2257,7 +2257,7 @@ static void gdb_read_byte(GDBState *s, int ch)
     if (runstate_is_running()) {
         /* when the CPU is running, we cannot do anything except stop
            it when receiving a char */
-        vm_stop(RSTATE_PAUSED);
+        vm_stop(RUN_STATE_PAUSED);
     } else
 #endif
     {
@@ -2507,7 +2507,7 @@ static void gdb_chr_event(void *opaque, int event)
 {
     switch (event) {
     case CHR_EVENT_OPENED:
-        vm_stop(RSTATE_PAUSED);
+        vm_stop(RUN_STATE_PAUSED);
         gdb_has_xml = 0;
         break;
     default:
@@ -2548,7 +2548,7 @@ static int gdb_monitor_write(CharDriverState *chr, const uint8_t *buf, int len)
 static void gdb_sigterm_handler(int signal)
 {
     if (runstate_is_running()) {
-        vm_stop(RSTATE_PAUSED);
+        vm_stop(RUN_STATE_PAUSED);
     }
 }
 #endif
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 24bdbc9..7262a4c 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -478,7 +478,7 @@ static int ide_handle_rw_error(IDEState *s, int error, int op)
         s->bus->bmdma->unit = s->unit;
         s->bus->error_status = op;
         bdrv_mon_event(s->bs, BDRV_ACTION_STOP, error, is_read);
-        vm_stop(RSTATE_IO_ERROR);
+        vm_stop(RUN_STATE_IO_ERROR);
     } else {
         if (op & BM_STATUS_DMA_RETRY) {
             dma_buf_commit(s, 0);
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 29256ec..4df2306 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -210,7 +210,7 @@ static int scsi_handle_rw_error(SCSIDiskReq *r, int error, int type)
         r->status |= SCSI_REQ_STATUS_RETRY | type;
 
         bdrv_mon_event(s->bs, BDRV_ACTION_STOP, error, is_read);
-        vm_stop(RSTATE_IO_ERROR);
+        vm_stop(RUN_STATE_IO_ERROR);
     } else {
         switch (error) {
         case ENOMEM:
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index ddce871..0e56611 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -75,7 +75,7 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error,
         req->next = s->rq;
         s->rq = req;
         bdrv_mon_event(s->bs, BDRV_ACTION_STOP, error, is_read);
-        vm_stop(RSTATE_IO_ERROR);
+        vm_stop(RUN_STATE_IO_ERROR);
     } else {
         virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR);
         bdrv_acct_done(s->bs, &req->acct);
diff --git a/hw/watchdog.c b/hw/watchdog.c
index 4e92b06..cdb8cc4 100644
--- a/hw/watchdog.c
+++ b/hw/watchdog.c
@@ -132,7 +132,7 @@ void watchdog_perform_action(void)
 
     case WDT_PAUSE:             /* same as 'stop' command in monitor */
         watchdog_mon_event("pause");
-        vm_stop(RSTATE_WATCHDOG);
+        vm_stop(RUN_STATE_WATCHDOG);
         break;
 
     case WDT_DEBUG:
diff --git a/kvm-all.c b/kvm-all.c
index dea1abf..edcf921 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -696,7 +696,7 @@ int kvm_cpu_exec(CPUState *env)
 #ifdef KVM_CAP_SET_GUEST_DEBUG
             if (kvm_arch_debug(&run->debug.arch)) {
                 gdb_set_stop_cpu(env);
-                vm_stop(RSTATE_DEBUG);
+                vm_stop(RUN_STATE_DEBUG);
                 env->exception_index = EXCP_DEBUG;
                 return 0;
             }
diff --git a/migration.c b/migration.c
index fc26024..869d47e 100644
--- a/migration.c
+++ b/migration.c
@@ -85,7 +85,7 @@ void process_incoming_migration(QEMUFile *f)
     if (autostart) {
         vm_start();
     } else {
-        runstate_set(RSTATE_PRE_LAUNCH);
+        runstate_set(RUN_STATE_PRELAUNCH);
     }
 }
 
@@ -395,7 +395,7 @@ void migrate_fd_put_ready(void *opaque)
         int old_vm_running = runstate_is_running();
 
         dprintf("done iterating\n");
-        vm_stop(RSTATE_PRE_MIGRATE);
+        vm_stop(RUN_STATE_FINISH_MIGRATE);
 
         qemu_aio_flush();
         bdrv_flush_all();
@@ -417,7 +417,7 @@ void migrate_fd_put_ready(void *opaque)
             }
         }
         if (state == MIG_STATE_COMPLETED) {
-            runstate_set(RSTATE_POST_MIGRATE);
+            runstate_set(RUN_STATE_POSTMIGRATE);
         }
         notifier_list_notify(&migration_state_notifiers);
     }
diff --git a/monitor.c b/monitor.c
index 63920ed..f5ee250 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1362,7 +1362,7 @@ static void do_singlestep(Monitor *mon, const QDict *qdict)
  */
 static int do_stop(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
-    vm_stop(RSTATE_PAUSED);
+    vm_stop(RUN_STATE_PAUSED);
     return 0;
 }
 
@@ -1380,11 +1380,11 @@ static int do_cont(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
     struct bdrv_iterate_context context = { mon, 0 };
 
-    if (runstate_check(RSTATE_IN_MIGRATE)) {
+    if (runstate_check(RUN_STATE_INMIGRATE)) {
         qerror_report(QERR_MIGRATION_EXPECTED);
         return -1;
-    } else if (runstate_check(RSTATE_PANICKED) ||
-               runstate_check(RSTATE_SHUTDOWN)) {
+    } else if (runstate_check(RUN_STATE_INTERNAL_ERROR) ||
+               runstate_check(RUN_STATE_SHUTDOWN)) {
         qerror_report(QERR_RESET_REQUIRED);
         return -1;
     }
@@ -2616,7 +2616,7 @@ static void do_loadvm(Monitor *mon, const QDict *qdict)
     int saved_vm_running  = runstate_is_running();
     const char *name = qdict_get_str(qdict, "name");
 
-    vm_stop(RSTATE_RESTORE);
+    vm_stop(RUN_STATE_RESTORE_VM);
 
     if (load_vmstate(name) >= 0 && saved_vm_running)
         vm_start();
diff --git a/qemu-kvm.c b/qemu-kvm.c
index a111fbd..34e9916 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -958,7 +958,7 @@ static int kvm_handle_internal_error(kvm_context_t kvm,
     kvm_show_regs(env);
     if (run->internal.suberror == KVM_INTERNAL_ERROR_EMULATION)
         fprintf(stderr, "emulation failure, check dmesg for details\n");
-    vm_stop(RSTATE_PANICKED);
+    vm_stop(RUN_STATE_INTERNAL_ERROR);
     return 1;
 }
 
@@ -1723,7 +1723,7 @@ int kvm_cpu_exec(CPUState *env)
     r = kvm_run(env);
     if (r < 0) {
         printf("kvm_run returned %d\n", r);
-        vm_stop(RSTATE_PANICKED);
+        vm_stop(RUN_STATE_INTERNAL_ERROR);
     }
 
     return 0;
@@ -2220,7 +2220,7 @@ int kvm_main_loop(void)
             qemu_kill_report();
             monitor_protocol_event(QEVENT_SHUTDOWN, NULL);
             if (qemu_no_shutdown()) {
-                vm_stop(RSTATE_SHUTDOWN);
+                vm_stop(RUN_STATE_SHUTDOWN);
             } else
                 break;
         } else if (qemu_powerdown_requested()) {
@@ -2228,13 +2228,13 @@ int kvm_main_loop(void)
             qemu_irq_raise(qemu_system_powerdown);
         } else if (qemu_reset_requested()) {
             qemu_kvm_system_reset();
-            if (runstate_check(RSTATE_PANICKED) ||
-                runstate_check(RSTATE_SHUTDOWN)) {
-                runstate_set(RSTATE_PAUSED);
+            if (runstate_check(RUN_STATE_INTERNAL_ERROR) ||
+                runstate_check(RUN_STATE_SHUTDOWN)) {
+                runstate_set(RUN_STATE_PAUSED);
             }
         } else if (kvm_debug_cpu_requested) {
             gdb_set_stop_cpu(kvm_debug_cpu_requested);
-            vm_stop(RSTATE_DEBUG);
+            vm_stop(RUN_STATE_DEBUG);
             kvm_debug_cpu_requested = NULL;
         }
     }
diff --git a/savevm.c b/savevm.c
index b3656d6..1a8c189 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1627,7 +1627,7 @@ static int qemu_savevm_state(Monitor *mon, QEMUFile *f)
     int ret;
 
     saved_vm_running = runstate_is_running();
-    vm_stop(RSTATE_SAVEVM);
+    vm_stop(RUN_STATE_SAVE_VM);
 
     bdrv_flush_all();
 
@@ -1960,7 +1960,7 @@ void do_savevm(Monitor *mon, const QDict *qdict)
     qemu_aio_flush();
 
     saved_vm_running = runstate_is_running();
-    vm_stop(RSTATE_SAVEVM);
+    vm_stop(RUN_STATE_SAVE_VM);
 
     memset(sn, 0, sizeof(*sn));
     if (name) {
diff --git a/sysemu.h b/sysemu.h
index cbb1af3..0d4f597 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -15,21 +15,21 @@
 /* vl.c */
 
 typedef enum {
-    RSTATE_NO_STATE,
-    RSTATE_DEBUG,          /* qemu is running under gdb */
-    RSTATE_IN_MIGRATE,     /* paused waiting for an incoming migration */
-    RSTATE_PANICKED,       /* paused due to an internal error */
-    RSTATE_IO_ERROR,       /* paused due to an I/O error */
-    RSTATE_PAUSED,         /* paused by the user (ie. the 'stop' command) */
-    RSTATE_POST_MIGRATE,   /* paused following a successful migration */
-    RSTATE_PRE_LAUNCH,     /* qemu was started with -S and haven't started */
-    RSTATE_PRE_MIGRATE,    /* paused preparing to finish migrate */
-    RSTATE_RESTORE,        /* paused restoring the VM state */
-    RSTATE_RUNNING,        /* qemu is running */
-    RSTATE_SAVEVM,         /* paused saving VM state */
-    RSTATE_SHUTDOWN,       /* guest shut down and -no-shutdown is in use */
-    RSTATE_WATCHDOG,       /* watchdog fired and qemu is configured to pause */
-    RSTATE_MAX
+    RUN_STATE_NO_STATE,
+    RUN_STATE_DEBUG,          /* qemu is running under gdb */
+    RUN_STATE_INMIGRATE,     /* paused waiting for an incoming migration */
+    RUN_STATE_INTERNAL_ERROR,       /* paused due to an internal error */
+    RUN_STATE_IO_ERROR,       /* paused due to an I/O error */
+    RUN_STATE_PAUSED,         /* paused by the user (ie. the 'stop' command) */
+    RUN_STATE_POSTMIGRATE,   /* paused following a successful migration */
+    RUN_STATE_PRELAUNCH,     /* qemu was started with -S and haven't started */
+    RUN_STATE_FINISH_MIGRATE,    /* paused preparing to finish migrate */
+    RUN_STATE_RESTORE_VM,        /* paused restoring the VM state */
+    RUN_STATE_RUNNING,        /* qemu is running */
+    RUN_STATE_SAVE_VM,         /* paused saving VM state */
+    RUN_STATE_SHUTDOWN,       /* guest shut down and -no-shutdown is in use */
+    RUN_STATE_WATCHDOG,       /* watchdog fired and qemu is configured to pause */
+    RUN_STATE_MAX
 } RunState;
 
 extern const char *bios_name;
diff --git a/vl.c b/vl.c
index d6ad447..4fcca63 100644
--- a/vl.c
+++ b/vl.c
@@ -359,7 +359,7 @@ PicState2 *isa_pic;
 
 /* QEMU state */
 
-static RunState current_run_state = RSTATE_NO_STATE;
+static RunState current_run_state = RUN_STATE_NO_STATE;
 
 typedef struct {
     RunState from;
@@ -368,66 +368,66 @@ typedef struct {
 
 static const RunStateTransition runstate_transitions_def[] = {
     /*     from      ->     to      */
-    { RSTATE_NO_STATE, RSTATE_RUNNING },
-    { RSTATE_NO_STATE, RSTATE_IN_MIGRATE },
-    { RSTATE_NO_STATE, RSTATE_PRE_LAUNCH },
+    { RUN_STATE_NO_STATE, RUN_STATE_RUNNING },
+    { RUN_STATE_NO_STATE, RUN_STATE_INMIGRATE },
+    { RUN_STATE_NO_STATE, RUN_STATE_PRELAUNCH },
 
-    { RSTATE_DEBUG, RSTATE_RUNNING },
+    { RUN_STATE_DEBUG, RUN_STATE_RUNNING },
 
-    { RSTATE_IN_MIGRATE, RSTATE_RUNNING },
-    { RSTATE_IN_MIGRATE, RSTATE_PRE_LAUNCH },
+    { RUN_STATE_INMIGRATE, RUN_STATE_RUNNING },
+    { RUN_STATE_INMIGRATE, RUN_STATE_PRELAUNCH },
 
-    { RSTATE_PANICKED, RSTATE_PAUSED },
+    { RUN_STATE_INTERNAL_ERROR, RUN_STATE_PAUSED },
 
-    { RSTATE_IO_ERROR, RSTATE_RUNNING },
+    { RUN_STATE_IO_ERROR, RUN_STATE_RUNNING },
 
-    { RSTATE_PAUSED, RSTATE_RUNNING },
+    { RUN_STATE_PAUSED, RUN_STATE_RUNNING },
 
-    { RSTATE_POST_MIGRATE, RSTATE_RUNNING },
+    { RUN_STATE_POSTMIGRATE, RUN_STATE_RUNNING },
 
-    { RSTATE_PRE_LAUNCH, RSTATE_RUNNING },
-    { RSTATE_PRE_LAUNCH, RSTATE_POST_MIGRATE },
+    { RUN_STATE_PRELAUNCH, RUN_STATE_RUNNING },
+    { RUN_STATE_PRELAUNCH, RUN_STATE_POSTMIGRATE },
 
-    { RSTATE_PRE_MIGRATE, RSTATE_RUNNING },
-    { RSTATE_PRE_MIGRATE, RSTATE_POST_MIGRATE },
+    { RUN_STATE_FINISH_MIGRATE, RUN_STATE_RUNNING },
+    { RUN_STATE_FINISH_MIGRATE, RUN_STATE_POSTMIGRATE },
 
-    { RSTATE_RESTORE, RSTATE_RUNNING },
+    { RUN_STATE_RESTORE_VM, RUN_STATE_RUNNING },
 
-    { RSTATE_RUNNING, RSTATE_DEBUG },
-    { RSTATE_RUNNING, RSTATE_PANICKED },
-    { RSTATE_RUNNING, RSTATE_IO_ERROR },
-    { RSTATE_RUNNING, RSTATE_PAUSED },
-    { RSTATE_RUNNING, RSTATE_PRE_MIGRATE },
-    { RSTATE_RUNNING, RSTATE_RESTORE },
-    { RSTATE_RUNNING, RSTATE_SAVEVM },
-    { RSTATE_RUNNING, RSTATE_SHUTDOWN },
-    { RSTATE_RUNNING, RSTATE_WATCHDOG },
+    { RUN_STATE_RUNNING, RUN_STATE_DEBUG },
+    { RUN_STATE_RUNNING, RUN_STATE_INTERNAL_ERROR },
+    { RUN_STATE_RUNNING, RUN_STATE_IO_ERROR },
+    { RUN_STATE_RUNNING, RUN_STATE_PAUSED },
+    { RUN_STATE_RUNNING, RUN_STATE_FINISH_MIGRATE },
+    { RUN_STATE_RUNNING, RUN_STATE_RESTORE_VM },
+    { RUN_STATE_RUNNING, RUN_STATE_SAVE_VM },
+    { RUN_STATE_RUNNING, RUN_STATE_SHUTDOWN },
+    { RUN_STATE_RUNNING, RUN_STATE_WATCHDOG },
 
-    { RSTATE_SAVEVM, RSTATE_RUNNING },
+    { RUN_STATE_SAVE_VM, RUN_STATE_RUNNING },
 
-    { RSTATE_SHUTDOWN, RSTATE_PAUSED },
+    { RUN_STATE_SHUTDOWN, RUN_STATE_PAUSED },
 
-    { RSTATE_WATCHDOG, RSTATE_RUNNING },
+    { RUN_STATE_WATCHDOG, RUN_STATE_RUNNING },
 
-    { RSTATE_MAX, RSTATE_MAX },
+    { RUN_STATE_MAX, RUN_STATE_MAX },
 };
 
-static bool runstate_valid_transitions[RSTATE_MAX][RSTATE_MAX];
-
-static const char *const runstate_name_tbl[RSTATE_MAX] = {
-    [RSTATE_DEBUG] = "debug",
-    [RSTATE_IN_MIGRATE] = "incoming-migration",
-    [RSTATE_PANICKED] = "internal-error",
-    [RSTATE_IO_ERROR] = "io-error",
-    [RSTATE_PAUSED] = "paused",
-    [RSTATE_POST_MIGRATE] = "post-migrate",
-    [RSTATE_PRE_LAUNCH] = "prelaunch",
-    [RSTATE_PRE_MIGRATE] = "finish-migrate",
-    [RSTATE_RESTORE] = "restore-vm",
-    [RSTATE_RUNNING] = "running",
-    [RSTATE_SAVEVM] = "save-vm",
-    [RSTATE_SHUTDOWN] = "shutdown",
-    [RSTATE_WATCHDOG] = "watchdog",
+static bool runstate_valid_transitions[RUN_STATE_MAX][RUN_STATE_MAX];
+
+static const char *const runstate_name_tbl[RUN_STATE_MAX] = {
+    [RUN_STATE_DEBUG] = "debug",
+    [RUN_STATE_INMIGRATE] = "incoming-migration",
+    [RUN_STATE_INTERNAL_ERROR] = "internal-error",
+    [RUN_STATE_IO_ERROR] = "io-error",
+    [RUN_STATE_PAUSED] = "paused",
+    [RUN_STATE_POSTMIGRATE] = "post-migrate",
+    [RUN_STATE_PRELAUNCH] = "prelaunch",
+    [RUN_STATE_FINISH_MIGRATE] = "finish-migrate",
+    [RUN_STATE_RESTORE_VM] = "restore-vm",
+    [RUN_STATE_RUNNING] = "running",
+    [RUN_STATE_SAVE_VM] = "save-vm",
+    [RUN_STATE_SHUTDOWN] = "shutdown",
+    [RUN_STATE_WATCHDOG] = "watchdog",
 };
 
 bool runstate_check(RunState state)
@@ -441,7 +441,7 @@ void runstate_init(void)
 
     memset(&runstate_valid_transitions, 0, sizeof(runstate_valid_transitions));
 
-    for (p = &runstate_transitions_def[0]; p->from != RSTATE_MAX; p++) {
+    for (p = &runstate_transitions_def[0]; p->from != RUN_STATE_MAX; p++) {
         runstate_valid_transitions[p->from][p->to] = true;
     }
 }
@@ -449,7 +449,7 @@ void runstate_init(void)
 /* This function will abort() on invalid state transitions */
 void runstate_set(RunState new_state)
 {
-    if (new_state >= RSTATE_MAX ||
+    if (new_state >= RUN_STATE_MAX ||
         !runstate_valid_transitions[current_run_state][new_state]) {
         fprintf(stderr, "invalid runstate transition\n");
         abort();
@@ -460,14 +460,14 @@ void runstate_set(RunState new_state)
 
 const char *runstate_as_string(void)
 {
-    assert(current_run_state > RSTATE_NO_STATE &&
-           current_run_state < RSTATE_MAX);
+    assert(current_run_state > RUN_STATE_NO_STATE &&
+           current_run_state < RUN_STATE_MAX);
     return runstate_name_tbl[current_run_state];
 }
 
 int runstate_is_running(void)
 {
-    return runstate_check(RSTATE_RUNNING);
+    return runstate_check(RUN_STATE_RUNNING);
 }
 
 /***********************************************************/
@@ -3246,8 +3246,8 @@ void vm_start(void)
 {
     if (!runstate_is_running()) {
         cpu_enable_ticks();
-        runstate_set(RSTATE_RUNNING);
-        vm_state_notify(1, RSTATE_RUNNING);
+        runstate_set(RUN_STATE_RUNNING);
+        vm_state_notify(1, RUN_STATE_RUNNING);
         qemu_rearm_alarm_timer(alarm_timer);
         resume_all_vcpus();
         monitor_protocol_event(QEVENT_RESUME, NULL);
@@ -3269,7 +3269,7 @@ static int shutdown_requested, shutdown_signal = -1;
 static pid_t shutdown_pid;
 static int powerdown_requested;
 static int debug_requested;
-static int vmstop_requested = RSTATE_NO_STATE;
+static int vmstop_requested = RUN_STATE_NO_STATE;
 
 int qemu_no_shutdown(void)
 {
@@ -3324,7 +3324,7 @@ static int qemu_debug_requested(void)
 static RunState qemu_vmstop_requested(void)
 {
     int r = vmstop_requested;
-    vmstop_requested = RSTATE_NO_STATE;
+    vmstop_requested = RUN_STATE_NO_STATE;
     return r;
 }
 
@@ -4231,12 +4231,12 @@ static void main_loop(void)
         } while (vm_can_run());
 
         if (qemu_debug_requested()) {
-            vm_stop(RSTATE_DEBUG);
+            vm_stop(RUN_STATE_DEBUG);
         }
         if (qemu_shutdown_requested()) {
             monitor_protocol_event(QEVENT_SHUTDOWN, NULL);
             if (no_shutdown) {
-                vm_stop(RSTATE_SHUTDOWN);
+                vm_stop(RUN_STATE_SHUTDOWN);
             } else
                 break;
         }
@@ -4244,9 +4244,9 @@ static void main_loop(void)
             pause_all_vcpus();
             qemu_system_reset();
             resume_all_vcpus();
-            if (runstate_check(RSTATE_PANICKED) ||
-                runstate_check(RSTATE_SHUTDOWN)) {
-                runstate_set(RSTATE_PAUSED);
+            if (runstate_check(RUN_STATE_INTERNAL_ERROR) ||
+                runstate_check(RUN_STATE_SHUTDOWN)) {
+                runstate_set(RUN_STATE_PAUSED);
             }
         }
         if (qemu_powerdown_requested()) {
@@ -6356,7 +6356,7 @@ int main(int argc, char **argv, char **envp)
     }
 
     if (incoming) {
-        runstate_set(RSTATE_IN_MIGRATE);
+        runstate_set(RUN_STATE_INMIGRATE);
         int ret = qemu_start_incoming_migration(incoming);
         if (ret < 0) {
             fprintf(stderr, "Migration failed. Exit code %s(%d), exiting.\n",
@@ -6366,7 +6366,7 @@ int main(int argc, char **argv, char **envp)
     } else if (autostart) {
         vm_start();
     } else {
-        runstate_set(RSTATE_PRE_LAUNCH);
+        runstate_set(RUN_STATE_PRELAUNCH);
     }
 
 #ifndef _WIN32
-- 
1.7.4.4

