ia64/xen-unstable

changeset 13535:62e2e515febe

[XEN] New event-channel reset operation.
Plumbed through libxenctrl to python.

From: Andrei Petrov <andrei.petrov@xensource.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Fri Jan 19 17:20:57 2007 +0000 (2007-01-19)
parents f89126a59073
children 0bf0672528cf
files tools/libxc/xc_evtchn.c tools/libxc/xenctrl.h tools/python/xen/lowlevel/xc/xc.c xen/common/event_channel.c xen/include/public/event_channel.h
line diff
     1.1 --- a/tools/libxc/xc_evtchn.c	Fri Jan 19 16:11:31 2007 +0000
     1.2 +++ b/tools/libxc/xc_evtchn.c	Fri Jan 19 17:20:57 2007 +0000
     1.3 @@ -37,7 +37,7 @@ int xc_evtchn_alloc_unbound(int xc_handl
     1.4                              uint32_t dom,
     1.5                              uint32_t remote_dom)
     1.6  {
     1.7 -    int         rc;
     1.8 +    int rc;
     1.9      struct evtchn_alloc_unbound arg = {
    1.10          .dom = (domid_t)dom,
    1.11          .remote_dom = (domid_t)remote_dom
    1.12 @@ -49,3 +49,10 @@ int xc_evtchn_alloc_unbound(int xc_handl
    1.13  
    1.14      return rc;
    1.15  }
    1.16 +
    1.17 +int xc_evtchn_reset(int xc_handle,
    1.18 +                    uint32_t dom)
    1.19 +{
    1.20 +    struct evtchn_reset arg = { .dom = (domid_t)dom };
    1.21 +    return do_evtchn_op(xc_handle, EVTCHNOP_reset, &arg, sizeof(arg));
    1.22 +}
     2.1 --- a/tools/libxc/xenctrl.h	Fri Jan 19 16:11:31 2007 +0000
     2.2 +++ b/tools/libxc/xenctrl.h	Fri Jan 19 17:20:57 2007 +0000
     2.3 @@ -432,6 +432,9 @@ int xc_evtchn_alloc_unbound(int xc_handl
     2.4                              uint32_t dom,
     2.5                              uint32_t remote_dom);
     2.6  
     2.7 +int xc_evtchn_reset(int xc_handle,
     2.8 +                    uint32_t dom);
     2.9 +
    2.10  int xc_physdev_pci_access_modify(int xc_handle,
    2.11                                   uint32_t domid,
    2.12                                   int bus,
     3.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Fri Jan 19 16:11:31 2007 +0000
     3.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Fri Jan 19 17:20:57 2007 +0000
     3.3 @@ -478,6 +478,24 @@ static PyObject *pyxc_evtchn_alloc_unbou
     3.4      return PyInt_FromLong(port);
     3.5  }
     3.6  
     3.7 +static PyObject *pyxc_evtchn_reset(XcObject *self,
     3.8 +				   PyObject *args,
     3.9 +				   PyObject *kwds)
    3.10 +{
    3.11 +    uint32_t dom;
    3.12 +
    3.13 +    static char *kwd_list[] = { "dom", NULL };
    3.14 +
    3.15 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
    3.16 +        return NULL;
    3.17 +
    3.18 +    if ( xc_evtchn_reset(self->xc_handle, dom) < 0 )
    3.19 +        return pyxc_error_to_exception();
    3.20 +
    3.21 +    Py_INCREF(zero);
    3.22 +    return zero;
    3.23 +}
    3.24 +
    3.25  static PyObject *pyxc_physdev_pci_access_modify(XcObject *self,
    3.26                                                  PyObject *args,
    3.27                                                  PyObject *kwds)
    3.28 @@ -1202,6 +1220,12 @@ static PyMethodDef pyxc_methods[] = {
    3.29        " remote_dom [int]: Remote domain to accept connections from.\n\n"
    3.30        "Returns: [int] Unbound event-channel port.\n" },
    3.31  
    3.32 +    { "evtchn_reset", 
    3.33 +      (PyCFunction)pyxc_evtchn_reset,
    3.34 +      METH_VARARGS | METH_KEYWORDS, "\n"
    3.35 +      "Reset all connections.\n"
    3.36 +      " dom [int]: Domain to reset.\n" },
    3.37 +
    3.38      { "physdev_pci_access_modify",
    3.39        (PyCFunction)pyxc_physdev_pci_access_modify,
    3.40        METH_VARARGS | METH_KEYWORDS, "\n"
     4.1 --- a/xen/common/event_channel.c	Fri Jan 19 16:11:31 2007 +0000
     4.2 +++ b/xen/common/event_channel.c	Fri Jan 19 17:20:57 2007 +0000
     4.3 @@ -735,6 +735,29 @@ static long evtchn_unmask(evtchn_unmask_
     4.4  }
     4.5  
     4.6  
     4.7 +static long evtchn_reset(evtchn_reset_t *r)
     4.8 +{
     4.9 +    domid_t dom = r->dom;
    4.10 +    struct domain *d;
    4.11 +    int i;
    4.12 +
    4.13 +    if ( dom == DOMID_SELF )
    4.14 +        dom = current->domain->domain_id;
    4.15 +    else if ( !IS_PRIV(current->domain) )
    4.16 +        return -EPERM;
    4.17 +
    4.18 +    if ( (d = find_domain_by_id(dom)) == NULL )
    4.19 +        return -ESRCH;
    4.20 +
    4.21 +    for ( i = 0; port_is_valid(d, i); i++ )
    4.22 +        (void)__evtchn_close(d, i);
    4.23 +
    4.24 +    put_domain(d);
    4.25 +
    4.26 +    return 0;
    4.27 +}
    4.28 +
    4.29 +
    4.30  long do_event_channel_op(int cmd, XEN_GUEST_HANDLE(void) arg)
    4.31  {
    4.32      long rc;
    4.33 @@ -833,6 +856,14 @@ long do_event_channel_op(int cmd, XEN_GU
    4.34          break;
    4.35      }
    4.36  
    4.37 +    case EVTCHNOP_reset: {
    4.38 +        struct evtchn_reset reset;
    4.39 +        if ( copy_from_guest(&reset, arg, 1) != 0 )
    4.40 +            return -EFAULT;
    4.41 +        rc = evtchn_reset(&reset);
    4.42 +        break;
    4.43 +    }
    4.44 +
    4.45      default:
    4.46          rc = -ENOSYS;
    4.47          break;
     5.1 --- a/xen/include/public/event_channel.h	Fri Jan 19 16:11:31 2007 +0000
     5.2 +++ b/xen/include/public/event_channel.h	Fri Jan 19 17:20:57 2007 +0000
     5.3 @@ -217,6 +217,19 @@ struct evtchn_unmask {
     5.4  typedef struct evtchn_unmask evtchn_unmask_t;
     5.5  
     5.6  /*
     5.7 + * EVTCHNOP_reset: Close all event channels associated with specified domain.
     5.8 + * NOTES:
     5.9 + *  1. <dom> may be specified as DOMID_SELF.
    5.10 + *  2. Only a sufficiently-privileged domain may specify other than DOMID_SELF.
    5.11 + */
    5.12 +#define EVTCHNOP_reset           10
    5.13 +struct evtchn_reset {
    5.14 +    /* IN parameters. */
    5.15 +    domid_t dom;
    5.16 +};
    5.17 +typedef struct evtchn_reset evtchn_reset_t;
    5.18 +
    5.19 +/*
    5.20   * Argument to event_channel_op_compat() hypercall. Superceded by new
    5.21   * event_channel_op() hypercall since 0x00030202.
    5.22   */