bitkeeper revision 1.1159.187.58 (41b88ba7ZjuJcwYxAL5HR5J_1FXMYw)

sysrq hacks from Matt Bloch
This commit is contained in:
kaf24@scramble.cl.cam.ac.uk committed 2004-12-09 17:30:15 +00:00
1 parent aee8954955
commit bc05bbc8f7
10 files changed
+93 -14

No files matched your search

+1
View File
@@ -521,6 +521,7 @@
411b2c1ehdEGO_CwG0tvn85Q-Tfh5g tools/python/xen/xm/migrate.py
40cf2937PSslwBliN1g7ofDy2H_RhA tools/python/xen/xm/opts.py
40cf2937Z8WCNOnO2FcWdubvEAF9QQ tools/python/xen/xm/shutdown.py
41b88ba6_C4---jeA895Efg9YFZgKA tools/python/xen/xm/sysrq.py
40fcefb2K1xqVVT4D-p7nL2GzS4scg tools/sv/Main.rpy
40ffbcb66Dj5F-1kCK9BcgSqCWkt1w tools/sv/Makefile
4120b0e5L_nW-u0MWRfIdXg4ng4OjA tools/sv/images/destroy.png
@@ -8,6 +8,7 @@ static int errno;
#include <linux/unistd.h>
#include <linux/module.h>
#include <linux/reboot.h>
#include <linux/sysrq.h>
#include <asm/irq.h>
#include <asm/mmu_context.h>
#include <asm-xen/ctrl_if.h>
@@ -49,10 +50,9 @@ EXPORT_SYMBOL(machine_power_off);
* Stop/pickle callback handling.
*/
//#include <asm/suspend.h>
/* Ignore multiple shutdown requests. */
static int shutting_down = -1;
static int pending_sysrq = -1;
static void __do_suspend(void)
{
@@ -214,9 +214,18 @@ static void __shutdown_handler(void *unused)
}
}
static void __sysrq_handler(void *unused)
{
#ifdef CONFIG_MAGIC_SYSRQ
handle_sysrq(pending_sysrq, NULL, NULL);
#endif
pending_sysrq = -1;
}
static void shutdown_handler(ctrl_msg_t *msg, unsigned long id)
{
static DECLARE_WORK(shutdown_work, __shutdown_handler, NULL);
static DECLARE_WORK(sysrq_work, __sysrq_handler, NULL);
if ( (shutting_down == -1) &&
((msg->subtype == CMSG_SHUTDOWN_POWEROFF) ||
@@ -226,6 +235,12 @@ static void shutdown_handler(ctrl_msg_t *msg, unsigned long id)
shutting_down = msg->subtype;
schedule_work(&shutdown_work);
}
else if ( (pending_sysrq == -1) &&
(msg->subtype == CMSG_SHUTDOWN_SYSRQ) )
{
pending_sysrq = msg->msg[0];
schedule_work(&sysrq_work);
}
else
{
printk("Ignore spurious shutdown request\n");
+3 -2
View File
@@ -228,10 +228,11 @@ class Xend:
return self.xendPost(self.domainurl(id),
{'op' : 'pause' })
def xend_domain_shutdown(self, id, reason):
def xend_domain_shutdown(self, id, reason, key=None):
return self.xendPost(self.domainurl(id),
{'op' : 'shutdown',
'reason' : reason })
'reason' : reason,
'key' : key })
def xend_domain_destroy(self, id, reason):
return self.xendPost(self.domainurl(id),
+2 -2
View File
@@ -455,7 +455,7 @@ class XendDomain:
except Exception, ex:
raise XendError(str(ex))
def domain_shutdown(self, id, reason='poweroff'):
def domain_shutdown(self, id, reason='poweroff', key=None):
"""Shutdown domain (nicely).
- poweroff: restart according to exit code and restart mode
- reboot: restart on exit
@@ -474,7 +474,7 @@ class XendDomain:
eserver.inject('xend.domain.shutdown', [dominfo.name, dominfo.id, reason])
if reason == 'halt':
reason = 'poweroff'
val = xend.domain_shutdown(dominfo.id, reason)
val = xend.domain_shutdown(dominfo.id, reason, key)
self.refresh_schedule()
return val
+2 -2
View File
@@ -711,14 +711,14 @@ class Daemon:
raise XendError('Invalid console id')
console.disconnect()
def domain_shutdown(self, dom, reason):
def domain_shutdown(self, dom, reason, key=None):
"""Shutdown a domain.
"""
dom = int(dom)
ctrl = self.domainCF.getController(dom)
if not ctrl:
raise XendError('No domain controller: %s' % dom)
ctrl.shutdown(reason)
ctrl.shutdown(reason, key)
return 0
def domain_mem_target_set(self, dom, target):
+2 -1
View File
@@ -47,7 +47,8 @@ class SrvDomain(SrvDir):
def op_shutdown(self, op, req):
fn = FormFn(self.xd.domain_shutdown,
[['dom', 'str'],
['reason', 'str']])
['reason', 'str'],
['key', 'int']])
val = fn(req.args, {'dom': self.dom.id})
req.setResponseCode(http.ACCEPTED)
req.setHeader("Location", "%s/.." % req.prePathURL())
+8 -4
View File
@@ -28,7 +28,8 @@ class DomainController(controller.Controller):
"""
reasons = {'poweroff' : 'shutdown_poweroff_t',
'reboot' : 'shutdown_reboot_t',
'suspend' : 'shutdown_suspend_t' }
'suspend' : 'shutdown_suspend_t',
'sysrq' : 'shutdown_sysrq_t' }
def __init__(self, factory, dom):
controller.Controller.__init__(self, factory, dom)
@@ -36,16 +37,19 @@ class DomainController(controller.Controller):
self.addMethod(CMSG_MEM_REQUEST, 0, None)
self.registerChannel()
def shutdown(self, reason):
def shutdown(self, reason, key=None):
"""Shutdown a domain.
reason shutdown reason
key sysrq key (only if reason is 'sysrq')
"""
msgtype = self.reasons.get(reason)
if not msgtype:
raise XendError('invalid reason:' + reason)
msg = packMsg(msgtype, {})
self.writeRequest(msg)
extra = {}
if reason == 'sysrq': extra['key'] = key
print extra
self.writeRequest(packMsg(msgtype, extra))
def mem_target_set(self, target):
"""Set domain memory target in pages.
+5
View File
@@ -197,10 +197,12 @@ CMSG_SHUTDOWN = 6
CMSG_SHUTDOWN_POWEROFF = 0
CMSG_SHUTDOWN_REBOOT = 1
CMSG_SHUTDOWN_SUSPEND = 2
CMSG_SHUTDOWN_SYSRQ = 3
STOPCODE_shutdown = 0
STOPCODE_reboot = 1
STOPCODE_suspend = 2
STOPCODE_sysrq = 3
shutdown_formats = {
'shutdown_poweroff_t':
@@ -211,6 +213,9 @@ shutdown_formats = {
'shutdown_suspend_t':
(CMSG_SHUTDOWN, CMSG_SHUTDOWN_SUSPEND),
'shutdown_sysrq_t':
(CMSG_SHUTDOWN, CMSG_SHUTDOWN_SYSRQ)
}
msg_formats.update(shutdown_formats)
+14 -1
View File
@@ -11,7 +11,7 @@ from xen.xend import PrettyPrint
from xen.xend import sxp
from xen.xend.XendClient import XendError, server
from xen.xend.XendClient import main as xend_client_main
from xen.xm import create, destroy, migrate, shutdown
from xen.xm import create, destroy, migrate, shutdown, sysrq
from xen.xm.opts import *
class Group:
@@ -401,6 +401,19 @@ class ProgShutdown(Prog):
xm.prog(ProgShutdown)
class ProgSysrq(Prog):
group = 'domain'
name = "sysrq"
info = """Send a sysrq to a domain."""
def help(self, args):
sysrq.main([args[0], '-h'])
def main(self, args):
sysrq.main(args)
xm.prog(ProgSysrq)
class ProgPause(Prog):
group = 'domain'
name = "pause"
+39
View File
@@ -0,0 +1,39 @@
# (C) Matthew Bloch <matthew@bytemark.co.uk> 2004
"""Domain shutdown.
"""
import string
import sys
import time
from xen.xend.XendClient import server
from xen.xm.opts import *
DOM0_NAME = 'Domain-0'
DOM0_ID = '0'
gopts = Opts(use="""[DOM] [letter]
Sends a Linux sysrq to a domain.
""")
gopts.opt('help', short='h',
fn=set_true, default=0,
use="Print this help.")
def sysrq(dom, req):
server.xend_domain_shutdown(dom, 'sysrq', req)
def main(argv):
opts = gopts
args = opts.parse(argv)
if opts.vals.help:
opts.usage()
return
# no options for the moment
if len(args) < 1: opts.err('Missing domain')
if len(args) < 2: opts.err('Missing sysrq character')
dom = args[0]
req = ord(args[1][0])
sysrq(dom, req)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.