ia64/xen-unstable
changeset 3259:631910906413
bitkeeper revision 1.1159.183.47 (41b88be2G5Z3etJanoh9c3CpkN8jSg)
Merge scramble.cl.cam.ac.uk:/auto/groups/xeno-xenod/BK/xen-2.0-testing.bk
into scramble.cl.cam.ac.uk:/auto/groups/xeno-xenod/BK/xen-unstable.bk
Merge scramble.cl.cam.ac.uk:/auto/groups/xeno-xenod/BK/xen-2.0-testing.bk
into scramble.cl.cam.ac.uk:/auto/groups/xeno-xenod/BK/xen-unstable.bk
author | kaf24@scramble.cl.cam.ac.uk |
---|---|
date | Thu Dec 09 17:31:14 2004 +0000 (2004-12-09) |
parents | fff7508e0e56 6bb19295b5d3 |
children | 5088989be882 |
files | .rootkeys linux-2.6.9-xen-sparse/arch/xen/kernel/reboot.c tools/python/xen/xend/XendClient.py tools/python/xen/xend/XendDomain.py tools/python/xen/xend/server/SrvDaemon.py tools/python/xen/xend/server/SrvDomain.py tools/python/xen/xend/server/domain.py tools/python/xen/xend/server/messages.py tools/python/xen/xm/main.py tools/python/xen/xm/sysrq.py |
line diff
1.1 --- a/.rootkeys Tue Dec 07 17:44:21 2004 +0000 1.2 +++ b/.rootkeys Thu Dec 09 17:31:14 2004 +0000 1.3 @@ -527,6 +527,7 @@ 40cf2937isyS250zyd0Q2GuEDoNXfQ tools/pyt 1.4 411b2c1ehdEGO_CwG0tvn85Q-Tfh5g tools/python/xen/xm/migrate.py 1.5 40cf2937PSslwBliN1g7ofDy2H_RhA tools/python/xen/xm/opts.py 1.6 40cf2937Z8WCNOnO2FcWdubvEAF9QQ tools/python/xen/xm/shutdown.py 1.7 +41b88ba6_C4---jeA895Efg9YFZgKA tools/python/xen/xm/sysrq.py 1.8 40fcefb2K1xqVVT4D-p7nL2GzS4scg tools/sv/Main.rpy 1.9 40ffbcb66Dj5F-1kCK9BcgSqCWkt1w tools/sv/Makefile 1.10 4120b0e5L_nW-u0MWRfIdXg4ng4OjA tools/sv/images/destroy.png
2.1 --- a/linux-2.6.9-xen-sparse/arch/xen/kernel/reboot.c Tue Dec 07 17:44:21 2004 +0000 2.2 +++ b/linux-2.6.9-xen-sparse/arch/xen/kernel/reboot.c Thu Dec 09 17:31:14 2004 +0000 2.3 @@ -8,6 +8,7 @@ static int errno; 2.4 #include <linux/unistd.h> 2.5 #include <linux/module.h> 2.6 #include <linux/reboot.h> 2.7 +#include <linux/sysrq.h> 2.8 #include <asm/irq.h> 2.9 #include <asm/mmu_context.h> 2.10 #include <asm-xen/ctrl_if.h> 2.11 @@ -49,10 +50,9 @@ EXPORT_SYMBOL(machine_power_off); 2.12 * Stop/pickle callback handling. 2.13 */ 2.14 2.15 -//#include <asm/suspend.h> 2.16 - 2.17 /* Ignore multiple shutdown requests. */ 2.18 static int shutting_down = -1; 2.19 +static int pending_sysrq = -1; 2.20 2.21 static void __do_suspend(void) 2.22 { 2.23 @@ -214,9 +214,18 @@ static void __shutdown_handler(void *unu 2.24 } 2.25 } 2.26 2.27 +static void __sysrq_handler(void *unused) 2.28 +{ 2.29 +#ifdef CONFIG_MAGIC_SYSRQ 2.30 + handle_sysrq(pending_sysrq, NULL, NULL); 2.31 +#endif 2.32 + pending_sysrq = -1; 2.33 +} 2.34 + 2.35 static void shutdown_handler(ctrl_msg_t *msg, unsigned long id) 2.36 { 2.37 static DECLARE_WORK(shutdown_work, __shutdown_handler, NULL); 2.38 + static DECLARE_WORK(sysrq_work, __sysrq_handler, NULL); 2.39 2.40 if ( (shutting_down == -1) && 2.41 ((msg->subtype == CMSG_SHUTDOWN_POWEROFF) || 2.42 @@ -226,6 +235,12 @@ static void shutdown_handler(ctrl_msg_t 2.43 shutting_down = msg->subtype; 2.44 schedule_work(&shutdown_work); 2.45 } 2.46 + else if ( (pending_sysrq == -1) && 2.47 + (msg->subtype == CMSG_SHUTDOWN_SYSRQ) ) 2.48 + { 2.49 + pending_sysrq = msg->msg[0]; 2.50 + schedule_work(&sysrq_work); 2.51 + } 2.52 else 2.53 { 2.54 printk("Ignore spurious shutdown request\n");
3.1 --- a/tools/python/xen/xend/XendClient.py Tue Dec 07 17:44:21 2004 +0000 3.2 +++ b/tools/python/xen/xend/XendClient.py Thu Dec 09 17:31:14 2004 +0000 3.3 @@ -228,10 +228,11 @@ class Xend: 3.4 return self.xendPost(self.domainurl(id), 3.5 {'op' : 'pause' }) 3.6 3.7 - def xend_domain_shutdown(self, id, reason): 3.8 + def xend_domain_shutdown(self, id, reason, key=None): 3.9 return self.xendPost(self.domainurl(id), 3.10 {'op' : 'shutdown', 3.11 - 'reason' : reason }) 3.12 + 'reason' : reason, 3.13 + 'key' : key }) 3.14 3.15 def xend_domain_destroy(self, id, reason): 3.16 return self.xendPost(self.domainurl(id),
4.1 --- a/tools/python/xen/xend/XendDomain.py Tue Dec 07 17:44:21 2004 +0000 4.2 +++ b/tools/python/xen/xend/XendDomain.py Thu Dec 09 17:31:14 2004 +0000 4.3 @@ -455,7 +455,7 @@ class XendDomain: 4.4 except Exception, ex: 4.5 raise XendError(str(ex)) 4.6 4.7 - def domain_shutdown(self, id, reason='poweroff'): 4.8 + def domain_shutdown(self, id, reason='poweroff', key=None): 4.9 """Shutdown domain (nicely). 4.10 - poweroff: restart according to exit code and restart mode 4.11 - reboot: restart on exit 4.12 @@ -474,7 +474,7 @@ class XendDomain: 4.13 eserver.inject('xend.domain.shutdown', [dominfo.name, dominfo.id, reason]) 4.14 if reason == 'halt': 4.15 reason = 'poweroff' 4.16 - val = xend.domain_shutdown(dominfo.id, reason) 4.17 + val = xend.domain_shutdown(dominfo.id, reason, key) 4.18 self.refresh_schedule() 4.19 return val 4.20
5.1 --- a/tools/python/xen/xend/server/SrvDaemon.py Tue Dec 07 17:44:21 2004 +0000 5.2 +++ b/tools/python/xen/xend/server/SrvDaemon.py Thu Dec 09 17:31:14 2004 +0000 5.3 @@ -711,14 +711,14 @@ class Daemon: 5.4 raise XendError('Invalid console id') 5.5 console.disconnect() 5.6 5.7 - def domain_shutdown(self, dom, reason): 5.8 + def domain_shutdown(self, dom, reason, key=None): 5.9 """Shutdown a domain. 5.10 """ 5.11 dom = int(dom) 5.12 ctrl = self.domainCF.getController(dom) 5.13 if not ctrl: 5.14 raise XendError('No domain controller: %s' % dom) 5.15 - ctrl.shutdown(reason) 5.16 + ctrl.shutdown(reason, key) 5.17 return 0 5.18 5.19 def domain_mem_target_set(self, dom, target):
6.1 --- a/tools/python/xen/xend/server/SrvDomain.py Tue Dec 07 17:44:21 2004 +0000 6.2 +++ b/tools/python/xen/xend/server/SrvDomain.py Thu Dec 09 17:31:14 2004 +0000 6.3 @@ -47,7 +47,8 @@ class SrvDomain(SrvDir): 6.4 def op_shutdown(self, op, req): 6.5 fn = FormFn(self.xd.domain_shutdown, 6.6 [['dom', 'str'], 6.7 - ['reason', 'str']]) 6.8 + ['reason', 'str'], 6.9 + ['key', 'int']]) 6.10 val = fn(req.args, {'dom': self.dom.id}) 6.11 req.setResponseCode(http.ACCEPTED) 6.12 req.setHeader("Location", "%s/.." % req.prePathURL())
7.1 --- a/tools/python/xen/xend/server/domain.py Tue Dec 07 17:44:21 2004 +0000 7.2 +++ b/tools/python/xen/xend/server/domain.py Thu Dec 09 17:31:14 2004 +0000 7.3 @@ -28,7 +28,8 @@ class DomainController(controller.Contro 7.4 """ 7.5 reasons = {'poweroff' : 'shutdown_poweroff_t', 7.6 'reboot' : 'shutdown_reboot_t', 7.7 - 'suspend' : 'shutdown_suspend_t' } 7.8 + 'suspend' : 'shutdown_suspend_t', 7.9 + 'sysrq' : 'shutdown_sysrq_t' } 7.10 7.11 def __init__(self, factory, dom): 7.12 controller.Controller.__init__(self, factory, dom) 7.13 @@ -36,16 +37,19 @@ class DomainController(controller.Contro 7.14 self.addMethod(CMSG_MEM_REQUEST, 0, None) 7.15 self.registerChannel() 7.16 7.17 - def shutdown(self, reason): 7.18 + def shutdown(self, reason, key=None): 7.19 """Shutdown a domain. 7.20 7.21 reason shutdown reason 7.22 + key sysrq key (only if reason is 'sysrq') 7.23 """ 7.24 msgtype = self.reasons.get(reason) 7.25 if not msgtype: 7.26 raise XendError('invalid reason:' + reason) 7.27 - msg = packMsg(msgtype, {}) 7.28 - self.writeRequest(msg) 7.29 + extra = {} 7.30 + if reason == 'sysrq': extra['key'] = key 7.31 + print extra 7.32 + self.writeRequest(packMsg(msgtype, extra)) 7.33 7.34 def mem_target_set(self, target): 7.35 """Set domain memory target in pages.
8.1 --- a/tools/python/xen/xend/server/messages.py Tue Dec 07 17:44:21 2004 +0000 8.2 +++ b/tools/python/xen/xend/server/messages.py Thu Dec 09 17:31:14 2004 +0000 8.3 @@ -197,10 +197,12 @@ CMSG_SHUTDOWN = 6 8.4 CMSG_SHUTDOWN_POWEROFF = 0 8.5 CMSG_SHUTDOWN_REBOOT = 1 8.6 CMSG_SHUTDOWN_SUSPEND = 2 8.7 +CMSG_SHUTDOWN_SYSRQ = 3 8.8 8.9 STOPCODE_shutdown = 0 8.10 STOPCODE_reboot = 1 8.11 STOPCODE_suspend = 2 8.12 +STOPCODE_sysrq = 3 8.13 8.14 shutdown_formats = { 8.15 'shutdown_poweroff_t': 8.16 @@ -211,6 +213,9 @@ shutdown_formats = { 8.17 8.18 'shutdown_suspend_t': 8.19 (CMSG_SHUTDOWN, CMSG_SHUTDOWN_SUSPEND), 8.20 + 8.21 + 'shutdown_sysrq_t': 8.22 + (CMSG_SHUTDOWN, CMSG_SHUTDOWN_SYSRQ) 8.23 } 8.24 8.25 msg_formats.update(shutdown_formats)
9.1 --- a/tools/python/xen/xm/main.py Tue Dec 07 17:44:21 2004 +0000 9.2 +++ b/tools/python/xen/xm/main.py Thu Dec 09 17:31:14 2004 +0000 9.3 @@ -11,7 +11,7 @@ from xen.xend import PrettyPrint 9.4 from xen.xend import sxp 9.5 from xen.xend.XendClient import XendError, server 9.6 from xen.xend.XendClient import main as xend_client_main 9.7 -from xen.xm import create, destroy, migrate, shutdown 9.8 +from xen.xm import create, destroy, migrate, shutdown, sysrq 9.9 from xen.xm.opts import * 9.10 9.11 class Group: 9.12 @@ -401,6 +401,19 @@ class ProgShutdown(Prog): 9.13 9.14 xm.prog(ProgShutdown) 9.15 9.16 +class ProgSysrq(Prog): 9.17 + group = 'domain' 9.18 + name = "sysrq" 9.19 + info = """Send a sysrq to a domain.""" 9.20 + 9.21 + def help(self, args): 9.22 + sysrq.main([args[0], '-h']) 9.23 + 9.24 + def main(self, args): 9.25 + sysrq.main(args) 9.26 + 9.27 +xm.prog(ProgSysrq) 9.28 + 9.29 class ProgPause(Prog): 9.30 group = 'domain' 9.31 name = "pause"
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/tools/python/xen/xm/sysrq.py Thu Dec 09 17:31:14 2004 +0000 10.3 @@ -0,0 +1,39 @@ 10.4 +# (C) Matthew Bloch <matthew@bytemark.co.uk> 2004 10.5 + 10.6 +"""Domain shutdown. 10.7 +""" 10.8 +import string 10.9 +import sys 10.10 +import time 10.11 + 10.12 +from xen.xend.XendClient import server 10.13 +from xen.xm.opts import * 10.14 + 10.15 +DOM0_NAME = 'Domain-0' 10.16 +DOM0_ID = '0' 10.17 + 10.18 +gopts = Opts(use="""[DOM] [letter] 10.19 + 10.20 +Sends a Linux sysrq to a domain. 10.21 +""") 10.22 + 10.23 +gopts.opt('help', short='h', 10.24 + fn=set_true, default=0, 10.25 + use="Print this help.") 10.26 + 10.27 +def sysrq(dom, req): 10.28 + server.xend_domain_shutdown(dom, 'sysrq', req) 10.29 + 10.30 +def main(argv): 10.31 + opts = gopts 10.32 + args = opts.parse(argv) 10.33 + if opts.vals.help: 10.34 + opts.usage() 10.35 + return 10.36 + 10.37 + # no options for the moment 10.38 + if len(args) < 1: opts.err('Missing domain') 10.39 + if len(args) < 2: opts.err('Missing sysrq character') 10.40 + dom = args[0] 10.41 + req = ord(args[1][0]) 10.42 + sysrq(dom, req)