ia64/xen-unstable
changeset 6043:0538ec1fe5b2
This patch changes the shutdown driver and xend to use strings instead
of codes for signaling a shutdown request.
Also, we fix the return code for the shutdown notifier, so other
notifiers will get to run ;)
Signed-off-by: Dan Smith <danms@us.ibm.com>
of codes for signaling a shutdown request.
Also, we fix the return code for the shutdown notifier, so other
notifiers will get to run ;)
Signed-off-by: Dan Smith <danms@us.ibm.com>
author | kaf24@firebug.cl.cam.ac.uk |
---|---|
date | Sat Aug 06 09:48:47 2005 +0000 (2005-08-06) |
parents | 69b7c9c3a9fd |
children | 968829eb1783 |
files | linux-2.6-xen-sparse/arch/xen/kernel/reboot.c tools/python/xen/xend/XendDomainInfo.py |
line diff
1.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c Fri Aug 05 15:11:46 2005 +0000 1.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c Sat Aug 06 09:48:47 2005 +0000 1.3 @@ -247,19 +247,31 @@ static void shutdown_handler(struct xenb 1.4 { 1.5 static DECLARE_WORK(shutdown_work, __shutdown_handler, NULL); 1.6 1.7 - int type = -1; 1.8 + char *str; 1.9 + unsigned int len; 1.10 1.11 - if (!xenbus_scanf("control", "shutdown", "%i", &type)) { 1.12 - printk("Unable to read code in control/shutdown\n"); 1.13 + str = (char *)xenbus_read("control", "shutdown", &len); 1.14 + 1.15 + if (! len) { 1.16 return; 1.17 - }; 1.18 + } 1.19 1.20 xenbus_printf("control", "shutdown", "%i", SHUTDOWN_INVALID); 1.21 1.22 - if ((type == SHUTDOWN_POWEROFF) || 1.23 - (type == SHUTDOWN_REBOOT) || 1.24 - (type == SHUTDOWN_SUSPEND)) { 1.25 - shutting_down = type; 1.26 + if (strncmp(str, "poweroff", len) == 0) { 1.27 + shutting_down = SHUTDOWN_POWEROFF; 1.28 + } else if (strncmp(str, "reboot", len) == 0) { 1.29 + shutting_down = SHUTDOWN_REBOOT; 1.30 + } else if (strncmp(str, "suspend", len) == 0) { 1.31 + shutting_down = SHUTDOWN_SUSPEND; 1.32 + } else { 1.33 + printk("Ignoring shutdown request: %s\n", str); 1.34 + shutting_down = SHUTDOWN_INVALID; 1.35 + } 1.36 + 1.37 + kfree(str); 1.38 + 1.39 + if (shutting_down != SHUTDOWN_INVALID) { 1.40 schedule_work(&shutdown_work); 1.41 } 1.42 1.43 @@ -271,7 +283,7 @@ static void sysrq_handler(struct xenbus_ 1.44 char sysrq_key = '\0'; 1.45 1.46 if (!xenbus_scanf("control", "sysrq", "%c", &sysrq_key)) { 1.47 - printk("Unable to read sysrq code in control/sysrq\n"); 1.48 + printk(KERN_ERR "Unable to read sysrq code in control/sysrq\n"); 1.49 return; 1.50 } 1.51 1.52 @@ -319,16 +331,16 @@ static int setup_shutdown_watcher(struct 1.53 up(&xenbus_lock); 1.54 1.55 if (err1) { 1.56 - printk("Failed to set shutdown watcher\n"); 1.57 + printk(KERN_ERR "Failed to set shutdown watcher\n"); 1.58 } 1.59 1.60 #ifdef CONFIG_MAGIC_SYSRQ 1.61 if (err2) { 1.62 - printk("Failed to set sysrq watcher\n"); 1.63 + printk(KERN_ERR "Failed to set sysrq watcher\n"); 1.64 } 1.65 #endif 1.66 1.67 - return NOTIFY_STOP; 1.68 + return NOTIFY_DONE; 1.69 } 1.70 1.71 static int __init setup_shutdown_event(void)
2.1 --- a/tools/python/xen/xend/XendDomainInfo.py Fri Aug 05 15:11:46 2005 +0000 2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py Sat Aug 06 09:48:47 2005 +0000 2.3 @@ -52,14 +52,6 @@ shutdown_reasons = { 2.4 DOMAIN_CRASH : "crash", 2.5 } 2.6 2.7 -"""Map shutdown reasons to codes 2.8 -""" 2.9 -shutdown_codes = { 2.10 - 'poweroff' : DOMAIN_POWEROFF, 2.11 - 'reboot' : DOMAIN_REBOOT, 2.12 - 'suspend' : DOMAIN_SUSPEND, 2.13 - } 2.14 - 2.15 RESTART_ALWAYS = 'always' 2.16 RESTART_ONREBOOT = 'onreboot' 2.17 RESTART_NEVER = 'never' 2.18 @@ -939,11 +931,10 @@ class XendDomainInfo: 2.19 self.channel.writeRequest(msg) 2.20 2.21 def shutdown(self, reason): 2.22 - reasonid = shutdown_codes.get(reason) 2.23 - if reasonid == None: 2.24 + if not reason in shutdown_reasons.values(): 2.25 raise XendError('invalid reason:' + reason) 2.26 db = self.db.addChild("/control"); 2.27 - db['shutdown'] = '%i' % reasonid; 2.28 + db['shutdown'] = reason; 2.29 db.saveDB(save=True); 2.30 if not reason in ['suspend']: 2.31 self.shutdown_pending = {'start':time.time(), 'reason':reason}