diff -r ad9bbd103034 tools/libxc/xc_domain.c --- a/tools/libxc/xc_domain.c Fri Feb 09 18:19:24 2007 +0000 +++ b/tools/libxc/xc_domain.c Tue Feb 13 13:13:01 2007 +0900 @@ -638,6 +638,21 @@ int xc_domain_iomem_permission(int xc_ha domctl.u.iomem_permission.first_mfn = first_mfn; domctl.u.iomem_permission.nr_mfns = nr_mfns; domctl.u.iomem_permission.allow_access = allow_access; + + return do_domctl(xc_handle, &domctl); +} + +int xc_domain_send_trigger(int xc_handle, + uint32_t domid, + uint32_t trigger, + uint32_t vcpu) +{ + DECLARE_DOMCTL; + + domctl.cmd = XEN_DOMCTL_sendtrigger; + domctl.domain = domid; + domctl.u.sendtrigger.trigger = trigger; + domctl.u.sendtrigger.vcpu = vcpu; return do_domctl(xc_handle, &domctl); } diff -r ad9bbd103034 tools/libxc/xenctrl.h --- a/tools/libxc/xenctrl.h Fri Feb 09 18:19:24 2007 +0000 +++ b/tools/libxc/xenctrl.h Tue Feb 13 13:13:22 2007 +0900 @@ -414,6 +414,20 @@ int xc_sched_credit_domain_get(int xc_ha uint32_t domid, struct xen_domctl_sched_credit *sdom); +/** + * This function sends a trigger to a domain. + * + * @parm xc_handle a handle to an open hypervisor interface + * @parm domid the domain id to send trigger + * @parm trigger the trigger type + * @parm vcpu the vcpu number to send trigger + * return 0 on success, -1 on failure + */ +int xc_domain_send_trigger(int xc_handle, + uint32_t domid, + uint32_t trigger, + uint32_t vcpu); + /* * EVENT CHANNEL FUNCTIONS */ diff -r ad9bbd103034 tools/python/xen/lowlevel/xc/xc.c --- a/tools/python/xen/lowlevel/xc/xc.c Fri Feb 09 18:19:24 2007 +0000 +++ b/tools/python/xen/lowlevel/xc/xc.c Tue Feb 13 13:13:39 2007 +0900 @@ -936,6 +936,26 @@ static PyObject *pyxc_domain_set_time_of 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)) { @@ -1338,6 +1358,15 @@ static PyMethodDef pyxc_methods[] = { METH_VARARGS, "\n" "Set a domain's time offset to Dom0's localtime\n" " 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__ diff -r ad9bbd103034 tools/python/xen/xend/XendConstants.py --- a/tools/python/xen/xend/XendConstants.py Fri Feb 09 18:19:24 2007 +0000 +++ b/tools/python/xen/xend/XendConstants.py Tue Feb 13 13:14:09 2007 +0900 @@ -82,6 +82,16 @@ RESTART_IN_PROGRESS = 'xend/restart_in_p 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) # diff -r ad9bbd103034 tools/python/xen/xend/XendDomain.py --- a/tools/python/xen/xend/XendDomain.py Fri Feb 09 18:19:24 2007 +0000 +++ b/tools/python/xen/xend/XendDomain.py Tue Feb 13 13:14:21 2007 +0900 @@ -43,6 +43,7 @@ from xen.xend.XendConstants import DOM_S 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. diff -r ad9bbd103034 tools/python/xen/xm/main.py --- a/tools/python/xen/xm/main.py Fri Feb 09 18:19:24 2007 +0000 +++ b/tools/python/xen/xm/main.py Tue Feb 13 13:14:33 2007 +0900 @@ -133,6 +133,8 @@ SUBCOMMAND_HELP = { 'sched-credit': ('[-d [-w[=WEIGHT]|-c[=CAP]]]', 'Get/set credit scheduler parameters.'), 'sysrq' : (' ', 'Send a sysrq to a domain.'), + 'trigger' : (' []', + 'Send a trigger to a domain.'), 'vcpu-list' : ('[]', 'List the VCPUs for a domain or all domains.'), 'vcpu-pin' : (' ', @@ -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,