[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [XEN] New event-channel reset operation.



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1169227257 0
# Node ID 62e2e515febe4ccdfa60056f0e4210e051bdc3e6
# Parent  f89126a590738ad804463772230dde0b4a6640ba
[XEN] New event-channel reset operation.
Plumbed through libxenctrl to python.

From: Andrei Petrov <andrei.petrov@xxxxxxxxxxxxx>
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 tools/libxc/xc_evtchn.c            |    9 ++++++++-
 tools/libxc/xenctrl.h              |    3 +++
 tools/python/xen/lowlevel/xc/xc.c  |   24 ++++++++++++++++++++++++
 xen/common/event_channel.c         |   31 +++++++++++++++++++++++++++++++
 xen/include/public/event_channel.h |   13 +++++++++++++
 5 files changed, 79 insertions(+), 1 deletion(-)

diff -r f89126a59073 -r 62e2e515febe tools/libxc/xc_evtchn.c
--- a/tools/libxc/xc_evtchn.c   Fri Jan 19 16:11:31 2007 +0000
+++ b/tools/libxc/xc_evtchn.c   Fri Jan 19 17:20:57 2007 +0000
@@ -37,7 +37,7 @@ int xc_evtchn_alloc_unbound(int xc_handl
                             uint32_t dom,
                             uint32_t remote_dom)
 {
-    int         rc;
+    int rc;
     struct evtchn_alloc_unbound arg = {
         .dom = (domid_t)dom,
         .remote_dom = (domid_t)remote_dom
@@ -49,3 +49,10 @@ int xc_evtchn_alloc_unbound(int xc_handl
 
     return rc;
 }
+
+int xc_evtchn_reset(int xc_handle,
+                    uint32_t dom)
+{
+    struct evtchn_reset arg = { .dom = (domid_t)dom };
+    return do_evtchn_op(xc_handle, EVTCHNOP_reset, &arg, sizeof(arg));
+}
diff -r f89126a59073 -r 62e2e515febe tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Fri Jan 19 16:11:31 2007 +0000
+++ b/tools/libxc/xenctrl.h     Fri Jan 19 17:20:57 2007 +0000
@@ -432,6 +432,9 @@ int xc_evtchn_alloc_unbound(int xc_handl
                             uint32_t dom,
                             uint32_t remote_dom);
 
+int xc_evtchn_reset(int xc_handle,
+                    uint32_t dom);
+
 int xc_physdev_pci_access_modify(int xc_handle,
                                  uint32_t domid,
                                  int bus,
diff -r f89126a59073 -r 62e2e515febe tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Fri Jan 19 16:11:31 2007 +0000
+++ b/tools/python/xen/lowlevel/xc/xc.c Fri Jan 19 17:20:57 2007 +0000
@@ -478,6 +478,24 @@ static PyObject *pyxc_evtchn_alloc_unbou
     return PyInt_FromLong(port);
 }
 
+static PyObject *pyxc_evtchn_reset(XcObject *self,
+                                  PyObject *args,
+                                  PyObject *kwds)
+{
+    uint32_t dom;
+
+    static char *kwd_list[] = { "dom", NULL };
+
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
+        return NULL;
+
+    if ( xc_evtchn_reset(self->xc_handle, dom) < 0 )
+        return pyxc_error_to_exception();
+
+    Py_INCREF(zero);
+    return zero;
+}
+
 static PyObject *pyxc_physdev_pci_access_modify(XcObject *self,
                                                 PyObject *args,
                                                 PyObject *kwds)
@@ -1201,6 +1219,12 @@ static PyMethodDef pyxc_methods[] = {
       " dom        [int]: Domain whose port space to allocate from.\n"
       " remote_dom [int]: Remote domain to accept connections from.\n\n"
       "Returns: [int] Unbound event-channel port.\n" },
+
+    { "evtchn_reset", 
+      (PyCFunction)pyxc_evtchn_reset,
+      METH_VARARGS | METH_KEYWORDS, "\n"
+      "Reset all connections.\n"
+      " dom [int]: Domain to reset.\n" },
 
     { "physdev_pci_access_modify",
       (PyCFunction)pyxc_physdev_pci_access_modify,
diff -r f89126a59073 -r 62e2e515febe xen/common/event_channel.c
--- a/xen/common/event_channel.c        Fri Jan 19 16:11:31 2007 +0000
+++ b/xen/common/event_channel.c        Fri Jan 19 17:20:57 2007 +0000
@@ -735,6 +735,29 @@ static long evtchn_unmask(evtchn_unmask_
 }
 
 
+static long evtchn_reset(evtchn_reset_t *r)
+{
+    domid_t dom = r->dom;
+    struct domain *d;
+    int i;
+
+    if ( dom == DOMID_SELF )
+        dom = current->domain->domain_id;
+    else if ( !IS_PRIV(current->domain) )
+        return -EPERM;
+
+    if ( (d = find_domain_by_id(dom)) == NULL )
+        return -ESRCH;
+
+    for ( i = 0; port_is_valid(d, i); i++ )
+        (void)__evtchn_close(d, i);
+
+    put_domain(d);
+
+    return 0;
+}
+
+
 long do_event_channel_op(int cmd, XEN_GUEST_HANDLE(void) arg)
 {
     long rc;
@@ -830,6 +853,14 @@ long do_event_channel_op(int cmd, XEN_GU
         if ( copy_from_guest(&unmask, arg, 1) != 0 )
             return -EFAULT;
         rc = evtchn_unmask(&unmask);
+        break;
+    }
+
+    case EVTCHNOP_reset: {
+        struct evtchn_reset reset;
+        if ( copy_from_guest(&reset, arg, 1) != 0 )
+            return -EFAULT;
+        rc = evtchn_reset(&reset);
         break;
     }
 
diff -r f89126a59073 -r 62e2e515febe xen/include/public/event_channel.h
--- a/xen/include/public/event_channel.h        Fri Jan 19 16:11:31 2007 +0000
+++ b/xen/include/public/event_channel.h        Fri Jan 19 17:20:57 2007 +0000
@@ -217,6 +217,19 @@ typedef struct evtchn_unmask evtchn_unma
 typedef struct evtchn_unmask evtchn_unmask_t;
 
 /*
+ * EVTCHNOP_reset: Close all event channels associated with specified domain.
+ * NOTES:
+ *  1. <dom> may be specified as DOMID_SELF.
+ *  2. Only a sufficiently-privileged domain may specify other than DOMID_SELF.
+ */
+#define EVTCHNOP_reset           10
+struct evtchn_reset {
+    /* IN parameters. */
+    domid_t dom;
+};
+typedef struct evtchn_reset evtchn_reset_t;
+
+/*
  * Argument to event_channel_op_compat() hypercall. Superceded by new
  * event_channel_op() hypercall since 0x00030202.
  */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.