aboutsummaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorLuiz Capitulino <lcapitulino@redhat.com>2011-07-29 15:04:45 -0300
committerLuiz Capitulino <lcapitulino@redhat.com>2011-09-15 16:39:32 -0300
commitf5bbfba1ebe8c877ebfe846fc1e73e90da423884 (patch)
treecd395df17a18a35cb4e5a9a8f0d6e378027a7794 /vl.c
parent1dfb4dd993f7122353fb2894f09dfcba894cd7d5 (diff)
RunState: Add additional states
Currently, only vm_start() and vm_stop() change the VM state. That's, the state is only changed when starting or stopping the VM. This commit adds the runstate_set() function, which makes it possible to also do state transitions when the VM is stopped or running. Additional states are also added and the current state is stored. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/vl.c b/vl.c
index 304a499551..059e727cb2 100644
--- a/vl.c
+++ b/vl.c
@@ -323,6 +323,22 @@ static int default_driver_check(QemuOpts *opts, void *opaque)
}
/***********************************************************/
+/* QEMU state */
+
+static RunState current_run_state = RSTATE_NO_STATE;
+
+bool runstate_check(RunState state)
+{
+ return current_run_state == state;
+}
+
+void runstate_set(RunState new_state)
+{
+ assert(new_state < RSTATE_MAX);
+ current_run_state = new_state;
+}
+
+/***********************************************************/
/* real time host monotonic timer */
/***********************************************************/
@@ -1161,6 +1177,7 @@ void vm_start(void)
if (!vm_running) {
cpu_enable_ticks();
vm_running = 1;
+ runstate_set(RSTATE_RUNNING);
vm_state_notify(1, RSTATE_RUNNING);
resume_all_vcpus();
monitor_protocol_event(QEVENT_RESUME, NULL);
@@ -3438,6 +3455,7 @@ int main(int argc, char **argv, char **envp)
}
if (incoming) {
+ runstate_set(RSTATE_IN_MIGRATE);
int ret = qemu_start_incoming_migration(incoming);
if (ret < 0) {
fprintf(stderr, "Migration failed. Exit code %s(%d), exiting.\n",
@@ -3446,6 +3464,8 @@ int main(int argc, char **argv, char **envp)
}
} else if (autostart) {
vm_start();
+ } else {
+ runstate_set(RSTATE_PRE_LAUNCH);
}
os_setup_post();