qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH] qemu: Emit RESET event with -no-reboot option


From: Christian Ludwig
Subject: [Qemu-devel] [PATCH] qemu: Emit RESET event with -no-reboot option
Date: Tue, 29 May 2018 07:53:12 +0200

When -no-reboot is given on the command line, qemu quits when the guest
finishes a system reboot operation. This is done by indicating that the
system should shut down, rather than reset. A user who observes QMP
events only sees a SHUTDOWN event and thus cannot distinguish whether
the guest initiated a shutdown or a reboot operation.

With -no-reboot set, set flags for system shutdown and system reset now.
The system shutdown path will continue to tear down and clean up the
guest to exit the application. But in the shutdown path, emit a REBOOT
event if the reboot flag is set.

Signed-off-by: Christian Ludwig <address@hidden>
---
 vl.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/vl.c b/vl.c
index 038d7f8042..4057d3382c 100644
--- a/vl.c
+++ b/vl.c
@@ -1778,9 +1778,7 @@ void qemu_system_reset_request(ShutdownCause reason)
 {
     if (no_reboot) {
         shutdown_requested = reason;
-    } else {
-        reset_requested = reason;
-    }
+    reset_requested = reason;
     cpu_stop_current();
     qemu_notify_event();
 }
@@ -1885,7 +1883,9 @@ void qemu_system_debug_request(void)
 static bool main_loop_should_exit(void)
 {
     RunState r;
-    ShutdownCause request;
+    ShutdownCause shutdown_request;
+    ShutdownCause reset_request;
+    bool from_guest;
 
     if (qemu_debug_requested()) {
         vm_stop(RUN_STATE_DEBUG);
@@ -1893,21 +1893,27 @@ static bool main_loop_should_exit(void)
     if (qemu_suspend_requested()) {
         qemu_system_suspend();
     }
-    request = qemu_shutdown_requested();
-    if (request) {
+    shutdown_request = qemu_shutdown_requested();
+    if (shutdown_request) {
         qemu_kill_report();
-        qapi_event_send_shutdown(shutdown_caused_by_guest(request),
-                                 &error_abort);
+        reset_request = qemu_reset_requested();
+        if (reset_request) {
+            from_guest = shutdown_caused_by_guest(reset_request);
+            qapi_event_send_reset(from_guest, &error_abort);
+        } else {
+            from_guest = shutdown_caused_by_guest(shutdown_request);
+            qapi_event_send_shutdown(from_guest, &error_abort);
+        }
         if (no_shutdown) {
             vm_stop(RUN_STATE_SHUTDOWN);
         } else {
             return true;
         }
     }
-    request = qemu_reset_requested();
-    if (request) {
+    reset_request = qemu_reset_requested();
+    if (reset_request) {
         pause_all_vcpus();
-        qemu_system_reset(request);
+        qemu_system_reset(reset_request);
         resume_all_vcpus();
         if (!runstate_check(RUN_STATE_RUNNING) &&
                 !runstate_check(RUN_STATE_INMIGRATE)) {
-- 
2.17.0



reply via email to

[Prev in Thread] Current Thread [Next in Thread]