aboutsummaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c53
1 files changed, 33 insertions, 20 deletions
diff --git a/vl.c b/vl.c
index b42b0b32a0..d90ae3f20a 100644
--- a/vl.c
+++ b/vl.c
@@ -1597,8 +1597,9 @@ void vm_state_notify(int running, RunState state)
}
}
-static int reset_requested;
-static int shutdown_requested, shutdown_signal;
+static ShutdownCause reset_requested;
+static ShutdownCause shutdown_requested;
+static int shutdown_signal;
static pid_t shutdown_pid;
static int powerdown_requested;
static int debug_requested;
@@ -1612,19 +1613,19 @@ static NotifierList wakeup_notifiers =
NOTIFIER_LIST_INITIALIZER(wakeup_notifiers);
static uint32_t wakeup_reason_mask = ~(1 << QEMU_WAKEUP_REASON_NONE);
-int qemu_shutdown_requested_get(void)
+ShutdownCause qemu_shutdown_requested_get(void)
{
return shutdown_requested;
}
-int qemu_reset_requested_get(void)
+ShutdownCause qemu_reset_requested_get(void)
{
return reset_requested;
}
static int qemu_shutdown_requested(void)
{
- return atomic_xchg(&shutdown_requested, 0);
+ return atomic_xchg(&shutdown_requested, SHUTDOWN_CAUSE_NONE);
}
static void qemu_kill_report(void)
@@ -1647,14 +1648,15 @@ static void qemu_kill_report(void)
}
}
-static int qemu_reset_requested(void)
+static ShutdownCause qemu_reset_requested(void)
{
- int r = reset_requested;
+ ShutdownCause r = reset_requested;
+
if (r && replay_checkpoint(CHECKPOINT_RESET_REQUESTED)) {
- reset_requested = 0;
+ reset_requested = SHUTDOWN_CAUSE_NONE;
return r;
}
- return false;
+ return SHUTDOWN_CAUSE_NONE;
}
static int qemu_suspend_requested(void)
@@ -1686,7 +1688,10 @@ static int qemu_debug_requested(void)
return r;
}
-void qemu_system_reset(bool report)
+/*
+ * Reset the VM. Issue an event unless @reason is SHUTDOWN_CAUSE_NONE.
+ */
+void qemu_system_reset(ShutdownCause reason)
{
MachineClass *mc;
@@ -1699,7 +1704,8 @@ void qemu_system_reset(bool report)
} else {
qemu_devices_reset();
}
- if (report) {
+ if (reason) {
+ /* TODO update event based on reason */
qapi_event_send_reset(&error_abort);
}
cpu_synchronize_all_post_reset();
@@ -1738,9 +1744,10 @@ void qemu_system_guest_panicked(GuestPanicInformation *info)
void qemu_system_reset_request(void)
{
if (no_reboot) {
- shutdown_requested = 1;
+ /* TODO - add a parameter to allow callers to specify reason */
+ shutdown_requested = SHUTDOWN_CAUSE_HOST_ERROR;
} else {
- reset_requested = 1;
+ reset_requested = SHUTDOWN_CAUSE_HOST_ERROR;
}
cpu_stop_current();
qemu_notify_event();
@@ -1807,7 +1814,7 @@ void qemu_system_killed(int signal, pid_t pid)
/* Cannot call qemu_system_shutdown_request directly because
* we are in a signal handler.
*/
- shutdown_requested = 1;
+ shutdown_requested = SHUTDOWN_CAUSE_HOST_SIGNAL;
qemu_notify_event();
}
@@ -1815,7 +1822,8 @@ void qemu_system_shutdown_request(void)
{
trace_qemu_system_shutdown_request();
replay_shutdown_request();
- shutdown_requested = 1;
+ /* TODO - add a parameter to allow callers to specify reason */
+ shutdown_requested = SHUTDOWN_CAUSE_HOST_ERROR;
qemu_notify_event();
}
@@ -1846,14 +1854,18 @@ void qemu_system_debug_request(void)
static bool main_loop_should_exit(void)
{
RunState r;
+ ShutdownCause request;
+
if (qemu_debug_requested()) {
vm_stop(RUN_STATE_DEBUG);
}
if (qemu_suspend_requested()) {
qemu_system_suspend();
}
- if (qemu_shutdown_requested()) {
+ request = qemu_shutdown_requested();
+ if (request) {
qemu_kill_report();
+ /* TODO update event based on request */
qapi_event_send_shutdown(&error_abort);
if (no_shutdown) {
vm_stop(RUN_STATE_SHUTDOWN);
@@ -1861,9 +1873,10 @@ static bool main_loop_should_exit(void)
return true;
}
}
- if (qemu_reset_requested()) {
+ request = qemu_reset_requested();
+ if (request) {
pause_all_vcpus();
- qemu_system_reset(VMRESET_REPORT);
+ qemu_system_reset(request);
resume_all_vcpus();
if (!runstate_check(RUN_STATE_RUNNING) &&
!runstate_check(RUN_STATE_INMIGRATE)) {
@@ -1872,7 +1885,7 @@ static bool main_loop_should_exit(void)
}
if (qemu_wakeup_requested()) {
pause_all_vcpus();
- qemu_system_reset(VMRESET_SILENT);
+ qemu_system_reset(SHUTDOWN_CAUSE_NONE);
notifier_list_notify(&wakeup_notifiers, &wakeup_reason);
wakeup_reason = QEMU_WAKEUP_REASON_NONE;
resume_all_vcpus();
@@ -4696,7 +4709,7 @@ int main(int argc, char **argv, char **envp)
reading from the other reads, because timer polling functions query
clock values from the log. */
replay_checkpoint(CHECKPOINT_RESET);
- qemu_system_reset(VMRESET_SILENT);
+ qemu_system_reset(SHUTDOWN_CAUSE_NONE);
register_global_state();
if (replay_mode != REPLAY_MODE_NONE) {
replay_vmstate_init();