direct-io.hg

changeset 14098:6c938630de54

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>
author Keir Fraser <keir@xensource.com>
date Sat Feb 24 14:10:27 2007 +0000 (2007-02-24)
parents 1e5a83fb928b
children aa1be6f5150e
files linux-2.6-xen-sparse/arch/ia64/xen/xcom_privcmd.c tools/libxc/xc_domain.c tools/libxc/xenctrl.h tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/XendConstants.py tools/python/xen/xend/XendDomain.py tools/python/xen/xm/main.py xen/arch/ia64/vmx/vlsapic.c xen/arch/ia64/vmx/vmx_process.c xen/arch/ia64/xen/dom0_ops.c xen/include/asm-ia64/vmx.h xen/include/asm-ia64/vmx_vpd.h xen/include/public/domctl.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/xcom_privcmd.c	Sat Feb 24 13:57:34 2007 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/xcom_privcmd.c	Sat Feb 24 14:10:27 2007 +0000
     1.3 @@ -303,6 +303,7 @@ xencomm_privcmd_domctl(privcmd_hypercall
     1.4  	case XEN_DOMCTL_hypercall_init:
     1.5  	case XEN_DOMCTL_arch_setup:
     1.6  	case XEN_DOMCTL_settimeoffset:
     1.7 +	case XEN_DOMCTL_sendtrigger:
     1.8  		break;
     1.9  	default:
    1.10  		printk("%s: unknown domctl cmd %d\n", __func__, kern_op.cmd);
     2.1 --- a/tools/libxc/xc_domain.c	Sat Feb 24 13:57:34 2007 +0000
     2.2 +++ b/tools/libxc/xc_domain.c	Sat Feb 24 14:10:27 2007 +0000
     2.3 @@ -642,6 +642,21 @@ int xc_domain_iomem_permission(int xc_ha
     2.4      return do_domctl(xc_handle, &domctl);
     2.5  }
     2.6  
     2.7 +int xc_domain_send_trigger(int xc_handle,
     2.8 +                           uint32_t domid,
     2.9 +                           uint32_t trigger,
    2.10 +                           uint32_t vcpu)
    2.11 +{
    2.12 +    DECLARE_DOMCTL;
    2.13 +
    2.14 +    domctl.cmd = XEN_DOMCTL_sendtrigger;
    2.15 +    domctl.domain = domid;
    2.16 +    domctl.u.sendtrigger.trigger = trigger;
    2.17 +    domctl.u.sendtrigger.vcpu = vcpu;
    2.18 +
    2.19 +    return do_domctl(xc_handle, &domctl);
    2.20 +}
    2.21 +
    2.22  /*
    2.23   * Local variables:
    2.24   * mode: C
     3.1 --- a/tools/libxc/xenctrl.h	Sat Feb 24 13:57:34 2007 +0000
     3.2 +++ b/tools/libxc/xenctrl.h	Sat Feb 24 14:10:27 2007 +0000
     3.3 @@ -414,6 +414,20 @@ int xc_sched_credit_domain_get(int xc_ha
     3.4                                 uint32_t domid,
     3.5                                 struct xen_domctl_sched_credit *sdom);
     3.6  
     3.7 +/**
     3.8 + * This function sends a trigger to a domain.
     3.9 + *
    3.10 + * @parm xc_handle a handle to an open hypervisor interface
    3.11 + * @parm domid the domain id to send trigger
    3.12 + * @parm trigger the trigger type
    3.13 + * @parm vcpu the vcpu number to send trigger 
    3.14 + * return 0 on success, -1 on failure
    3.15 + */
    3.16 +int xc_domain_send_trigger(int xc_handle,
    3.17 +                           uint32_t domid,
    3.18 +                           uint32_t trigger,
    3.19 +                           uint32_t vcpu);
    3.20 +
    3.21  /*
    3.22   * EVENT CHANNEL FUNCTIONS
    3.23   */
     4.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Sat Feb 24 13:57:34 2007 +0000
     4.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Sat Feb 24 14:10:27 2007 +0000
     4.3 @@ -936,6 +936,26 @@ static PyObject *pyxc_domain_set_time_of
     4.4      return zero;
     4.5  }
     4.6  
     4.7 +static PyObject *pyxc_domain_send_trigger(XcObject *self,
     4.8 +                                          PyObject *args,
     4.9 +                                          PyObject *kwds)
    4.10 +{
    4.11 +    uint32_t dom;
    4.12 +    int trigger, vcpu = 0;
    4.13 +
    4.14 +    static char *kwd_list[] = { "domid", "trigger", "vcpu", NULL };
    4.15 +
    4.16 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii|i", kwd_list, 
    4.17 +                                      &dom, &trigger, &vcpu) )
    4.18 +        return NULL;
    4.19 +
    4.20 +    if (xc_domain_send_trigger(self->xc_handle, dom, trigger, vcpu) != 0)
    4.21 +        return pyxc_error_to_exception();
    4.22 +
    4.23 +    Py_INCREF(zero);
    4.24 +    return zero;
    4.25 +}
    4.26 +
    4.27  static PyObject *dom_op(XcObject *self, PyObject *args,
    4.28                          int (*fn)(int, uint32_t))
    4.29  {
    4.30 @@ -1339,6 +1359,15 @@ static PyMethodDef pyxc_methods[] = {
    4.31        " dom        [int]: Domain whose time offset is being set.\n"
    4.32        "Returns: [int] 0 on success; -1 on error.\n" },
    4.33  
    4.34 +    { "domain_send_trigger",
    4.35 +      (PyCFunction)pyxc_domain_send_trigger,
    4.36 +      METH_VARARGS | METH_KEYWORDS, "\n"
    4.37 +      "Send trigger to a domain.\n"
    4.38 +      " dom     [int]: Identifier of domain to be sent trigger.\n"
    4.39 +      " trigger [int]: Trigger type number.\n"
    4.40 +      " vcpu    [int]: VCPU to be sent trigger.\n"
    4.41 +      "Returns: [int] 0 on success; -1 on error.\n" },
    4.42 +
    4.43  #ifdef __powerpc__
    4.44      { "arch_alloc_real_mode_area", 
    4.45        (PyCFunction)pyxc_alloc_real_mode_area, 
     5.1 --- a/tools/python/xen/xend/XendConstants.py	Sat Feb 24 13:57:34 2007 +0000
     5.2 +++ b/tools/python/xen/xend/XendConstants.py	Sat Feb 24 14:10:27 2007 +0000
     5.3 @@ -82,6 +82,16 @@ MINIMUM_RESTART_TIME = 20
     5.4  RESTART_IN_PROGRESS = 'xend/restart_in_progress'
     5.5  LAST_SHUTDOWN_REASON = 'xend/last_shutdown_reason'
     5.6  
     5.7 +TRIGGER_NMI   = 0
     5.8 +TRIGGER_RESET = 1
     5.9 +TRIGGER_INIT  = 2
    5.10 +
    5.11 +TRIGGER_TYPE = {
    5.12 +    "nmi"   : TRIGGER_NMI,
    5.13 +    "reset" : TRIGGER_RESET,
    5.14 +    "init"  : TRIGGER_INIT
    5.15 +}
    5.16 +
    5.17  #
    5.18  # Device migration stages (eg. XendDomainInfo, XendCheckpoint, server.tpmif)
    5.19  #
     6.1 --- a/tools/python/xen/xend/XendDomain.py	Sat Feb 24 13:57:34 2007 +0000
     6.2 +++ b/tools/python/xen/xend/XendDomain.py	Sat Feb 24 14:10:27 2007 +0000
     6.3 @@ -43,6 +43,7 @@ from xen.xend.XendConstants import XS_VM
     6.4  from xen.xend.XendConstants import DOM_STATE_HALTED, DOM_STATE_PAUSED
     6.5  from xen.xend.XendConstants import DOM_STATE_RUNNING, DOM_STATE_SUSPENDED
     6.6  from xen.xend.XendConstants import DOM_STATE_SHUTDOWN, DOM_STATE_UNKNOWN
     6.7 +from xen.xend.XendConstants import TRIGGER_TYPE
     6.8  from xen.xend.XendDevices import XendDevices
     6.9  
    6.10  from xen.xend.xenstore.xstransact import xstransact
    6.11 @@ -1433,6 +1434,33 @@ class XendDomain:
    6.12          except Exception, ex:
    6.13              raise XendError(str(ex))
    6.14  
    6.15 +    def domain_send_trigger(self, domid, trigger_name, vcpu = 0):
    6.16 +        """Send trigger to a domain.
    6.17 +
    6.18 +        @param domid: Domain ID or Name
    6.19 +        @type domid: int or string.
    6.20 +        @param trigger_name: trigger type name
    6.21 +        @type trigger_name: string
    6.22 +        @param vcpu: VCPU to send trigger (default is 0) 
    6.23 +        @type vcpu: int
    6.24 +        @raise XendError: failed to send trigger
    6.25 +        @raise XendInvalidDomain: Domain is not valid        
    6.26 +        @rtype: 0
    6.27 +        """
    6.28 +        dominfo = self.domain_lookup_nr(domid)
    6.29 +        if not dominfo:
    6.30 +            raise XendInvalidDomain(str(domid))
    6.31 +        if trigger_name.lower() in TRIGGER_TYPE: 
    6.32 +            trigger = TRIGGER_TYPE[trigger_name.lower()]
    6.33 +        else:
    6.34 +            raise XendError("Invalid trigger: %s", trigger_name)
    6.35 +        try:
    6.36 +            return xc.domain_send_trigger(dominfo.getDomid(),
    6.37 +                                          trigger,
    6.38 +                                          vcpu)
    6.39 +        except Exception, ex:
    6.40 +            raise XendError(str(ex))
    6.41 + 
    6.42  
    6.43  def instance():
    6.44      """Singleton constructor. Use this instead of the class constructor.
     7.1 --- a/tools/python/xen/xm/main.py	Sat Feb 24 13:57:34 2007 +0000
     7.2 +++ b/tools/python/xen/xm/main.py	Sat Feb 24 14:10:27 2007 +0000
     7.3 @@ -133,6 +133,8 @@ SUBCOMMAND_HELP = {
     7.4      'sched-credit': ('[-d <Domain> [-w[=WEIGHT]|-c[=CAP]]]',
     7.5                       'Get/set credit scheduler parameters.'),
     7.6      'sysrq'       : ('<Domain> <letter>', 'Send a sysrq to a domain.'),
     7.7 +    'trigger'     : ('<Domain> <nmi|reset|init> [<VCPU>]',
     7.8 +                     'Send a trigger to a domain.'),
     7.9      'vcpu-list'   : ('[<Domain>]',
    7.10                       'List the VCPUs for a domain or all domains.'),
    7.11      'vcpu-pin'    : ('<Domain> <VCPU> <CPUs>',
    7.12 @@ -255,6 +257,7 @@ common_commands = [
    7.13      "shutdown",
    7.14      "start",
    7.15      "suspend",
    7.16 +    "trigger",
    7.17      "top",
    7.18      "unpause",
    7.19      "uptime",
    7.20 @@ -284,6 +287,7 @@ domain_commands = [
    7.21      "start",
    7.22      "suspend",
    7.23      "sysrq",
    7.24 +    "trigger",
    7.25      "top",
    7.26      "unpause",
    7.27      "uptime",
    7.28 @@ -1347,6 +1351,17 @@ def xm_sysrq(args):
    7.29      req = args[1]
    7.30      server.xend.domain.send_sysrq(dom, req)    
    7.31  
    7.32 +def xm_trigger(args):
    7.33 +    vcpu = 0
    7.34 +    
    7.35 +    arg_check(args, "trigger", 2, 3)
    7.36 +    dom = args[0]
    7.37 +    trigger = args[1]
    7.38 +    if len(args) == 3:
    7.39 +        vcpu = int(args[2])
    7.40 +    
    7.41 +    server.xend.domain.send_trigger(dom, trigger, vcpu)
    7.42 +
    7.43  def xm_top(args):
    7.44      arg_check(args, "top", 0)
    7.45  
    7.46 @@ -1668,6 +1683,7 @@ commands = {
    7.47      "shutdown": xm_shutdown,
    7.48      "start": xm_start,
    7.49      "sysrq": xm_sysrq,
    7.50 +    "trigger": xm_trigger,
    7.51      "uptime": xm_uptime,
    7.52      "suspend": xm_suspend,
    7.53      "list": xm_list,
     8.1 --- a/xen/arch/ia64/vmx/vlsapic.c	Sat Feb 24 13:57:34 2007 +0000
     8.2 +++ b/xen/arch/ia64/vmx/vlsapic.c	Sat Feb 24 14:10:27 2007 +0000
     8.3 @@ -498,6 +498,18 @@ chk_irq_exit:
     8.4  }
     8.5  
     8.6  /*
     8.7 + * Set a INIT interruption request to vcpu[0] of target domain.
     8.8 + * The INIT interruption is injected into each vcpu by guest firmware.
     8.9 + */
    8.10 +void vmx_pend_pal_init(struct domain *d)
    8.11 +{
    8.12 +    VCPU *vcpu;
    8.13 +
    8.14 +    vcpu = d->vcpu[0];
    8.15 +    vcpu->arch.arch_vmx.pal_init_pending = 1;
    8.16 +}
    8.17 +
    8.18 +/*
    8.19   * Only coming from virtualization fault.
    8.20   */
    8.21  void guest_write_eoi(VCPU *vcpu)
    8.22 @@ -644,6 +656,14 @@ static void vlsapic_deliver_ipi(VCPU *vc
    8.23  }
    8.24  
    8.25  /*
    8.26 + * Deliver the INIT interruption to guest.
    8.27 + */
    8.28 +void deliver_pal_init(VCPU *vcpu)
    8.29 +{
    8.30 +    vlsapic_deliver_ipi(vcpu, SAPIC_INIT, 0);
    8.31 +}
    8.32 +
    8.33 +/*
    8.34   * TODO: Use hash table for the lookup.
    8.35   */
    8.36  static inline VCPU *lid_to_vcpu(struct domain *d, uint8_t id, uint8_t eid)
     9.1 --- a/xen/arch/ia64/vmx/vmx_process.c	Sat Feb 24 13:57:34 2007 +0000
     9.2 +++ b/xen/arch/ia64/vmx/vmx_process.c	Sat Feb 24 14:10:27 2007 +0000
     9.3 @@ -229,6 +229,14 @@ void leave_hypervisor_tail(void)
     9.4          if (v->vcpu_id == 0) {
     9.5              unsigned long callback_irq =
     9.6                  d->arch.hvm_domain.params[HVM_PARAM_CALLBACK_IRQ];
     9.7 +
     9.8 +            if ( v->arch.arch_vmx.pal_init_pending ) {
     9.9 +                /*inject INIT interruption to guest pal*/
    9.10 +                v->arch.arch_vmx.pal_init_pending = 0;
    9.11 +                deliver_pal_init(v);
    9.12 +                return;
    9.13 +            }
    9.14 +
    9.15              /*
    9.16               * val[63:56] == 1: val[55:0] is a delivery PCI INTx line:
    9.17               *                  Domain = val[47:32], Bus  = val[31:16],
    10.1 --- a/xen/arch/ia64/xen/dom0_ops.c	Sat Feb 24 13:57:34 2007 +0000
    10.2 +++ b/xen/arch/ia64/xen/dom0_ops.c	Sat Feb 24 14:10:27 2007 +0000
    10.3 @@ -174,6 +174,46 @@ long arch_do_domctl(xen_domctl_t *op, XE
    10.4          put_domain(d);
    10.5      }
    10.6      break;
    10.7 +
    10.8 +    case XEN_DOMCTL_sendtrigger:
    10.9 +    {
   10.10 +        struct domain *d;
   10.11 +        struct vcpu *v;
   10.12 +
   10.13 +        ret = -ESRCH;
   10.14 +        d = get_domain_by_id(op->domain);
   10.15 +        if ( d == NULL )
   10.16 +            break;
   10.17 +
   10.18 +        ret = -EINVAL;
   10.19 +        if ( op->u.sendtrigger.vcpu >= MAX_VIRT_CPUS )
   10.20 +            goto sendtrigger_out;
   10.21 +
   10.22 +        ret = -ESRCH;
   10.23 +        if ( (v = d->vcpu[op->u.sendtrigger.vcpu]) == NULL )
   10.24 +            goto sendtrigger_out;
   10.25 +
   10.26 +        ret = 0;
   10.27 +        switch (op->u.sendtrigger.trigger)
   10.28 +        {
   10.29 +        case XEN_DOMCTL_SENDTRIGGER_INIT:
   10.30 +        {
   10.31 +            if (VMX_DOMAIN(v))
   10.32 +                vmx_pend_pal_init(d);
   10.33 +            else
   10.34 +                ret = -ENOSYS;
   10.35 +        }
   10.36 +        break;
   10.37 +
   10.38 +        default:
   10.39 +            ret = -ENOSYS;
   10.40 +        }
   10.41 +
   10.42 +    sendtrigger_out:
   10.43 +        put_domain(d);
   10.44 +    }
   10.45 +    break;
   10.46 +
   10.47      default:
   10.48          printk("arch_do_domctl: unrecognized domctl: %d!!!\n",op->cmd);
   10.49          ret = -ENOSYS;
    11.1 --- a/xen/include/asm-ia64/vmx.h	Sat Feb 24 13:57:34 2007 +0000
    11.2 +++ b/xen/include/asm-ia64/vmx.h	Sat Feb 24 14:10:27 2007 +0000
    11.3 @@ -54,6 +54,8 @@ extern void vmx_relinquish_guest_resourc
    11.4  extern void vmx_relinquish_vcpu_resources(struct vcpu *v);
    11.5  extern void vmx_die_if_kernel(char *str, struct pt_regs *regs, long err);
    11.6  extern void vmx_send_assist_req(struct vcpu *v);
    11.7 +extern void deliver_pal_init(struct vcpu *vcpu);
    11.8 +extern void vmx_pend_pal_init(struct domain *d);
    11.9  
   11.10  static inline vcpu_iodata_t *get_vio(struct domain *d, unsigned long cpu)
   11.11  {
    12.1 --- a/xen/include/asm-ia64/vmx_vpd.h	Sat Feb 24 13:57:34 2007 +0000
    12.2 +++ b/xen/include/asm-ia64/vmx_vpd.h	Sat Feb 24 14:10:27 2007 +0000
    12.3 @@ -90,6 +90,7 @@ struct arch_vmx_struct {
    12.4      unsigned long   flags;
    12.5      unsigned long   xen_port;
    12.6      unsigned char   xtp;
    12.7 +    unsigned char   pal_init_pending;
    12.8  #ifdef VTI_DEBUG
    12.9      unsigned long  ivt_current;
   12.10      struct ivt_debug ivt_debug[IVT_DEBUG_MAX];
    13.1 --- a/xen/include/public/domctl.h	Sat Feb 24 13:57:34 2007 +0000
    13.2 +++ b/xen/include/public/domctl.h	Sat Feb 24 14:10:27 2007 +0000
    13.3 @@ -356,6 +356,7 @@ struct xen_domctl_ioport_permission {
    13.4  typedef struct xen_domctl_ioport_permission xen_domctl_ioport_permission_t;
    13.5  DEFINE_XEN_GUEST_HANDLE(xen_domctl_ioport_permission_t);
    13.6  
    13.7 +
    13.8  #define XEN_DOMCTL_hypercall_init    22
    13.9  struct xen_domctl_hypercall_init {
   13.10      uint64_aligned_t  gmfn;           /* GMFN to be initialised */
   13.11 @@ -363,6 +364,7 @@ struct xen_domctl_hypercall_init {
   13.12  typedef struct xen_domctl_hypercall_init xen_domctl_hypercall_init_t;
   13.13  DEFINE_XEN_GUEST_HANDLE(xen_domctl_hypercall_init_t);
   13.14  
   13.15 +
   13.16  #define XEN_DOMCTL_arch_setup        23
   13.17  #define _XEN_DOMAINSETUP_hvm_guest 0
   13.18  #define XEN_DOMAINSETUP_hvm_guest  (1UL<<_XEN_DOMAINSETUP_hvm_guest)
   13.19 @@ -379,15 +381,17 @@ typedef struct xen_domctl_arch_setup {
   13.20  } xen_domctl_arch_setup_t;
   13.21  DEFINE_XEN_GUEST_HANDLE(xen_domctl_arch_setup_t);
   13.22  
   13.23 +
   13.24  #define XEN_DOMCTL_settimeoffset     24
   13.25  struct xen_domctl_settimeoffset {
   13.26      int32_t  time_offset_seconds; /* applied to domain wallclock time */
   13.27  };
   13.28  typedef struct xen_domctl_settimeoffset xen_domctl_settimeoffset_t;
   13.29  DEFINE_XEN_GUEST_HANDLE(xen_domctl_settimeoffset_t);
   13.30 +
   13.31   
   13.32 -#define XEN_DOMCTL_gethvmcontext   33
   13.33 -#define XEN_DOMCTL_sethvmcontext   34
   13.34 +#define XEN_DOMCTL_gethvmcontext     33
   13.35 +#define XEN_DOMCTL_sethvmcontext     34
   13.36  typedef struct xen_domctl_hvmcontext {
   13.37      uint32_t size; /* IN/OUT: size of buffer / bytes filled */
   13.38      XEN_GUEST_HANDLE(uint8_t) buffer; /* IN/OUT: data, or call gethvmcontext 
   13.39 @@ -395,20 +399,35 @@ typedef struct xen_domctl_hvmcontext {
   13.40  } xen_domctl_hvmcontext_t;
   13.41  DEFINE_XEN_GUEST_HANDLE(xen_domctl_hvmcontext_t);
   13.42  
   13.43 -#define XEN_DOMCTL_set_address_size 35
   13.44 -#define XEN_DOMCTL_get_address_size 36
   13.45 +
   13.46 +#define XEN_DOMCTL_set_address_size  35
   13.47 +#define XEN_DOMCTL_get_address_size  36
   13.48  typedef struct xen_domctl_address_size {
   13.49      uint32_t size;
   13.50  } xen_domctl_address_size_t;
   13.51  DEFINE_XEN_GUEST_HANDLE(xen_domctl_address_size_t);
   13.52  
   13.53 -#define XEN_DOMCTL_real_mode_area     26
   13.54 +
   13.55 +#define XEN_DOMCTL_real_mode_area    26
   13.56  struct xen_domctl_real_mode_area {
   13.57      uint32_t log; /* log2 of Real Mode Area size */
   13.58  };
   13.59  typedef struct xen_domctl_real_mode_area xen_domctl_real_mode_area_t;
   13.60  DEFINE_XEN_GUEST_HANDLE(xen_domctl_real_mode_area_t);
   13.61  
   13.62 +
   13.63 +#define XEN_DOMCTL_sendtrigger       28
   13.64 +#define XEN_DOMCTL_SENDTRIGGER_NMI    0
   13.65 +#define XEN_DOMCTL_SENDTRIGGER_RESET  1
   13.66 +#define XEN_DOMCTL_SENDTRIGGER_INIT   2
   13.67 +struct xen_domctl_sendtrigger {
   13.68 +    uint32_t  trigger;  /* IN */
   13.69 +    uint32_t  vcpu;     /* IN */
   13.70 +};
   13.71 +typedef struct xen_domctl_sendtrigger xen_domctl_sendtrigger_t;
   13.72 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_sendtrigger_t);
   13.73 +
   13.74 + 
   13.75  struct xen_domctl {
   13.76      uint32_t cmd;
   13.77      uint32_t interface_version; /* XEN_DOMCTL_INTERFACE_VERSION */
   13.78 @@ -437,6 +456,7 @@ struct xen_domctl {
   13.79          struct xen_domctl_real_mode_area    real_mode_area;
   13.80          struct xen_domctl_hvmcontext        hvmcontext;
   13.81          struct xen_domctl_address_size      address_size;
   13.82 +        struct xen_domctl_sendtrigger       sendtrigger;
   13.83          uint8_t                             pad[128];
   13.84      } u;
   13.85  };