]> xenbits.xensource.com Git - mini-os.git/commitdiff
Save/Restore Support: Add fini_shutdown call to app exit flow.
authorBruno Alvisio <bruno.alvisio@gmail.com>
Tue, 27 Mar 2018 15:54:20 +0000 (08:54 -0700)
committerWei Liu <wei.liu2@citrix.com>
Tue, 27 Mar 2018 16:19:36 +0000 (17:19 +0100)
Instead of calling kernel_shutdown() in the exit flow, a call to fini_shutdown()
is added to the existing exit flow.

kernel_shutdown() is removed since it is not used in any part of mini-OS.

Signed-off-by: Bruno Alvisio <bruno.alvisio@gmail.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
include/shutdown.h
main.c
shutdown.c

index a5ec019ee42d71732710fe3bd90796f1ee0e5023..88993cbf2783e44a170697b0e3897115d51d42be 100644 (file)
@@ -4,8 +4,7 @@
 #include <mini-os/hypervisor.h>
 
 void init_shutdown(start_info_t *si);
-
-void kernel_shutdown(int reason) __attribute__((noreturn));
+void fini_shutdown(void);
 void kernel_suspend(void);
 
 #endif
diff --git a/main.c b/main.c
index 4e42f53d14aa67da07fcb4f8e6d8ca1970a83ddf..a93bc9d6714088bcccfe00335ef65ad28a8eb858 100644 (file)
--- a/main.c
+++ b/main.c
@@ -17,6 +17,7 @@
 #include <unistd.h>
 #include <xenbus.h>
 #include <events.h>
+#include <shutdown.h>
 #include <mini-os/lib.h>
 
 extern int main(int argc, char *argv[], char *envp[]);
@@ -176,6 +177,9 @@ void _exit(int ret)
     printk("main returned %d\n", ret);
 #if defined(HAVE_LWIP) && defined(CONFIG_NETFRONT)
     stop_networking();
+#endif
+#ifdef CONFIG_XENBUS
+    fini_shutdown();
 #endif
     stop_kernel();
     if (!ret) {
index 510f6e18761af5ccfe6c2b849a930da931c64b7c..c7c92cbac47fd6687eddf5847f30fd148f6a70d2 100644 (file)
@@ -111,19 +111,6 @@ static void shutdown_thread(void *p)
     }
 }
 
-static void fini_shutdown(void)
-{
-    char *err;
-
-    end_shutdown_thread = 1;
-    xenbus_release_wait_for_watch(&events);
-    err = xenbus_unwatch_path_token(XBT_NIL, path, token);
-    if (err) {
-        free(err);
-        do_exit();
-    }
-}
-
 void init_shutdown(start_info_t *si)
 {
     start_info_ptr = si;
@@ -131,40 +118,20 @@ void init_shutdown(start_info_t *si)
     end_shutdown_thread = 0;
     create_thread("shutdown", shutdown_thread, NULL);
 }
-#endif
 
-void kernel_shutdown(int reason)
+void fini_shutdown(void)
 {
-    char* reason_str = NULL;
-
-    switch(reason) {
-        case SHUTDOWN_poweroff:
-            reason_str = "poweroff";
-            break;
-        case SHUTDOWN_reboot:
-            reason_str = "reboot";
-            break;
-        case SHUTDOWN_crash:
-            reason_str = "crash";
-            break;
-        default:
-            do_exit();
-            break;
-    }
-
-    printk("MiniOS will shutdown (reason = %s) ...\n", reason_str);
-
-#ifdef CONFIG_XENBUS
-    fini_shutdown();
-#endif
-
-    stop_kernel();
+    char *err;
 
-    for ( ;; ) {
-        struct sched_shutdown sched_shutdown = { .reason = reason };
-        HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
+    end_shutdown_thread = 1;
+    xenbus_release_wait_for_watch(&events);
+    err = xenbus_unwatch_path_token(XBT_NIL, path, token);
+    if (err) {
+        free(err);
+        do_exit();
     }
 }
+#endif
 
 void kernel_suspend(void)
 {