mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
Support new xm command: xm trigger <Domain> <nmi|reset|init> [<VCPU>]
Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com> Signed-off-by: Akio Takebe <takebe_akio@jp.fujitsu.com> Signed-off-by: Zhang Xin <xing.z.zhang@intel.com>
This commit is contained in:
1 parent
83ac3090ec
commit
da97fcd329
13 files changed
+209
-5
No files matched your search
@@ -936,6 +936,26 @@ static PyObject *pyxc_domain_set_time_offset(XcObject *self, PyObject *args)
|
||||
return zero;
|
||||
}
|
||||
|
||||
static PyObject *pyxc_domain_send_trigger(XcObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwds)
|
||||
{
|
||||
uint32_t dom;
|
||||
int trigger, vcpu = 0;
|
||||
|
||||
static char *kwd_list[] = { "domid", "trigger", "vcpu", NULL };
|
||||
|
||||
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii|i", kwd_list,
|
||||
&dom, &trigger, &vcpu) )
|
||||
return NULL;
|
||||
|
||||
if (xc_domain_send_trigger(self->xc_handle, dom, trigger, vcpu) != 0)
|
||||
return pyxc_error_to_exception();
|
||||
|
||||
Py_INCREF(zero);
|
||||
return zero;
|
||||
}
|
||||
|
||||
static PyObject *dom_op(XcObject *self, PyObject *args,
|
||||
int (*fn)(int, uint32_t))
|
||||
{
|
||||
@@ -1339,6 +1359,15 @@ static PyMethodDef pyxc_methods[] = {
|
||||
" dom [int]: Domain whose time offset is being set.\n"
|
||||
"Returns: [int] 0 on success; -1 on error.\n" },
|
||||
|
||||
{ "domain_send_trigger",
|
||||
(PyCFunction)pyxc_domain_send_trigger,
|
||||
METH_VARARGS | METH_KEYWORDS, "\n"
|
||||
"Send trigger to a domain.\n"
|
||||
" dom [int]: Identifier of domain to be sent trigger.\n"
|
||||
" trigger [int]: Trigger type number.\n"
|
||||
" vcpu [int]: VCPU to be sent trigger.\n"
|
||||
"Returns: [int] 0 on success; -1 on error.\n" },
|
||||
|
||||
#ifdef __powerpc__
|
||||
{ "arch_alloc_real_mode_area",
|
||||
(PyCFunction)pyxc_alloc_real_mode_area,
|
||||
|
||||
@@ -82,6 +82,16 @@ MINIMUM_RESTART_TIME = 20
|
||||
RESTART_IN_PROGRESS = 'xend/restart_in_progress'
|
||||
LAST_SHUTDOWN_REASON = 'xend/last_shutdown_reason'
|
||||
|
||||
TRIGGER_NMI = 0
|
||||
TRIGGER_RESET = 1
|
||||
TRIGGER_INIT = 2
|
||||
|
||||
TRIGGER_TYPE = {
|
||||
"nmi" : TRIGGER_NMI,
|
||||
"reset" : TRIGGER_RESET,
|
||||
"init" : TRIGGER_INIT
|
||||
}
|
||||
|
||||
#
|
||||
# Device migration stages (eg. XendDomainInfo, XendCheckpoint, server.tpmif)
|
||||
#
|
||||
|
||||
@@ -43,6 +43,7 @@ from xen.xend.XendConstants import XS_VMROOT
|
||||
from xen.xend.XendConstants import DOM_STATE_HALTED, DOM_STATE_PAUSED
|
||||
from xen.xend.XendConstants import DOM_STATE_RUNNING, DOM_STATE_SUSPENDED
|
||||
from xen.xend.XendConstants import DOM_STATE_SHUTDOWN, DOM_STATE_UNKNOWN
|
||||
from xen.xend.XendConstants import TRIGGER_TYPE
|
||||
from xen.xend.XendDevices import XendDevices
|
||||
|
||||
from xen.xend.xenstore.xstransact import xstransact
|
||||
@@ -1433,6 +1434,33 @@ class XendDomain:
|
||||
except Exception, ex:
|
||||
raise XendError(str(ex))
|
||||
|
||||
def domain_send_trigger(self, domid, trigger_name, vcpu = 0):
|
||||
"""Send trigger to a domain.
|
||||
|
||||
@param domid: Domain ID or Name
|
||||
@type domid: int or string.
|
||||
@param trigger_name: trigger type name
|
||||
@type trigger_name: string
|
||||
@param vcpu: VCPU to send trigger (default is 0)
|
||||
@type vcpu: int
|
||||
@raise XendError: failed to send trigger
|
||||
@raise XendInvalidDomain: Domain is not valid
|
||||
@rtype: 0
|
||||
"""
|
||||
dominfo = self.domain_lookup_nr(domid)
|
||||
if not dominfo:
|
||||
raise XendInvalidDomain(str(domid))
|
||||
if trigger_name.lower() in TRIGGER_TYPE:
|
||||
trigger = TRIGGER_TYPE[trigger_name.lower()]
|
||||
else:
|
||||
raise XendError("Invalid trigger: %s", trigger_name)
|
||||
try:
|
||||
return xc.domain_send_trigger(dominfo.getDomid(),
|
||||
trigger,
|
||||
vcpu)
|
||||
except Exception, ex:
|
||||
raise XendError(str(ex))
|
||||
|
||||
|
||||
def instance():
|
||||
"""Singleton constructor. Use this instead of the class constructor.
|
||||
|
||||
@@ -133,6 +133,8 @@ SUBCOMMAND_HELP = {
|
||||
'sched-credit': ('[-d <Domain> [-w[=WEIGHT]|-c[=CAP]]]',
|
||||
'Get/set credit scheduler parameters.'),
|
||||
'sysrq' : ('<Domain> <letter>', 'Send a sysrq to a domain.'),
|
||||
'trigger' : ('<Domain> <nmi|reset|init> [<VCPU>]',
|
||||
'Send a trigger to a domain.'),
|
||||
'vcpu-list' : ('[<Domain>]',
|
||||
'List the VCPUs for a domain or all domains.'),
|
||||
'vcpu-pin' : ('<Domain> <VCPU> <CPUs>',
|
||||
@@ -255,6 +257,7 @@ common_commands = [
|
||||
"shutdown",
|
||||
"start",
|
||||
"suspend",
|
||||
"trigger",
|
||||
"top",
|
||||
"unpause",
|
||||
"uptime",
|
||||
@@ -284,6 +287,7 @@ domain_commands = [
|
||||
"start",
|
||||
"suspend",
|
||||
"sysrq",
|
||||
"trigger",
|
||||
"top",
|
||||
"unpause",
|
||||
"uptime",
|
||||
@@ -1347,6 +1351,17 @@ def xm_sysrq(args):
|
||||
req = args[1]
|
||||
server.xend.domain.send_sysrq(dom, req)
|
||||
|
||||
def xm_trigger(args):
|
||||
vcpu = 0
|
||||
|
||||
arg_check(args, "trigger", 2, 3)
|
||||
dom = args[0]
|
||||
trigger = args[1]
|
||||
if len(args) == 3:
|
||||
vcpu = int(args[2])
|
||||
|
||||
server.xend.domain.send_trigger(dom, trigger, vcpu)
|
||||
|
||||
def xm_top(args):
|
||||
arg_check(args, "top", 0)
|
||||
|
||||
@@ -1668,6 +1683,7 @@ commands = {
|
||||
"shutdown": xm_shutdown,
|
||||
"start": xm_start,
|
||||
"sysrq": xm_sysrq,
|
||||
"trigger": xm_trigger,
|
||||
"uptime": xm_uptime,
|
||||
"suspend": xm_suspend,
|
||||
"list": xm_list,
|
||||
|
||||