All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] shutdown.c - halt_action
@ 2006-11-03 21:29 Ben Thomas
  2006-11-04  7:46 ` Keir Fraser
  0 siblings, 1 reply; 4+ messages in thread
From: Ben Thomas @ 2006-11-03 21:29 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 976 bytes --]

It's not always desirable for a system to halt.  The hypervisor has a
number of places where it does request a halt, and this might be useful
for debugging, but not always in a production environment. Add a
hypervisor command line parameter, halt_action, which allows the
overriding of any halt requests.  The parameter takes the form of
halt_action=halt, halt_action=reboot or halt_action=reboot:20
for halting, rebooting after a default 10 seconds, or rebooting after
a specified number of seconds. The default is halt_action=halt
and preserves existing behavior.

Signed-off-by: Ben Thomas (ben@virtualiron.com)

-- 
------------------------------------------------------------------------
Ben Thomas                                         Virtual Iron Software
bthomas@virtualiron.com                            Tower 1, Floor 2
978-849-1214                                       900 Chelmsford Street
                                                    Lowell, MA 01851

[-- Attachment #2: 10090-halt_action.patch --]
[-- Type: text/x-patch, Size: 2347 bytes --]

# It's not always desirable for a system to halt.  The hypervisor has a
# number of places where it does request a halt, and this might be useful
# for debugging, but not always in a production environment. Add a
# hypervisor command line parameter, halt_action, which allows the
# overriding of any halt requests.  The parameter takes the form of
# halt_action=halt, halt_action=reboot or halt_action=reboot:20
# for halting, rebooting after a default 10 seconds, or rebooting after
# a specified number of seconds. The default preserves is halt_action=halt
# and preserves existing behavior.
#
# Signed-off-by: Ben Thomas (ben@virtualiron.com)

Index: xen-unstable.hg/xen/arch/x86/shutdown.c
===================================================================
--- xen-unstable.hg.orig/xen/arch/x86/shutdown.c	2006-10-26 10:56:41.000000000 -0400
+++ xen-unstable.hg/xen/arch/x86/shutdown.c	2006-10-30 11:17:59.000000000 -0500
@@ -29,6 +29,29 @@
 static long no_idt[2];
 static int reboot_mode;
 
+void machine_restart(char * __unused);
+
+enum {HALT_ACTION_HALT, HALT_ACTION_REBOOT};
+static int halt_action = HALT_ACTION_HALT;
+static long halt_action_wait = 10;
+
+static void __init halt_action_set(char *str)
+{
+    if (strcmp(str, "halt") == 0)
+        halt_action = HALT_ACTION_HALT;
+     else if (strncmp(str, "reboot", strlen("reboot")) == 0)
+    {
+        halt_action = HALT_ACTION_REBOOT;
+	str += strlen("reboot");
+	if (*str == ':')
+	  halt_action_wait = simple_strtol(++str, NULL, 10);
+	else
+	  halt_action_wait = 10;
+    } else
+        printk("halt_action '%s' not recognized", str);
+}
+custom_param("halt_action", halt_action_set);
+
 static inline void kb_wait(void)
 {
     int i;
@@ -48,6 +71,19 @@
 {
     watchdog_disable();
     console_start_sync();
+    if (halt_action != HALT_ACTION_HALT)
+    {
+    	printk("%s - reboot requested\n", __FUNCTION__);
+	halt_action = HALT_ACTION_HALT;		// We may end up back here - don't loop
+	if (halt_action_wait > 0)
+	{
+	    printk("%s - delay %ld seconds before reboot...\n", __FUNCTION__, halt_action_wait);
+	    mdelay(halt_action_wait * 1000);
+	}
+    	printk("%s - rebooting...\n", __FUNCTION__);
+	machine_restart(0);
+	// We shouldn't get back here, but if we do just halt
+    }
     smp_call_function(__machine_halt, NULL, 1, 0);
     __machine_halt(NULL);
 }

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-11-06 22:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-03 21:29 [PATCH] shutdown.c - halt_action Ben Thomas
2006-11-04  7:46 ` Keir Fraser
2006-11-06 22:06   ` Ben Thomas
2006-11-06 22:16     ` Keir Fraser

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.