diff options
author | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2007-01-19 17:20:57 +0000 |
---|---|---|
committer | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2007-01-19 17:20:57 +0000 |
commit | 115209d91bcd3734ddaaf58a4a1cdbb4c44cd4fa (patch) | |
tree | 2b6454a5f05e6cede6689265f3d28782412a8c3e | |
parent | f272b206703b3e8c5f12683475976dd77e5ecbf7 (diff) | |
download | xen-115209d91bcd3734ddaaf58a4a1cdbb4c44cd4fa.tar.gz xen-115209d91bcd3734ddaaf58a4a1cdbb4c44cd4fa.tar.bz2 xen-115209d91bcd3734ddaaf58a4a1cdbb4c44cd4fa.zip |
[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>
-rw-r--r-- | tools/libxc/xc_evtchn.c | 9 | ||||
-rw-r--r-- | tools/libxc/xenctrl.h | 3 | ||||
-rw-r--r-- | tools/python/xen/lowlevel/xc/xc.c | 24 | ||||
-rw-r--r-- | xen/common/event_channel.c | 31 | ||||
-rw-r--r-- | xen/include/public/event_channel.h | 13 |
5 files changed, 79 insertions, 1 deletions
diff --git a/tools/libxc/xc_evtchn.c b/tools/libxc/xc_evtchn.c index 8c795bce7a..c0f3b9b54c 100644 --- a/tools/libxc/xc_evtchn.c +++ b/tools/libxc/xc_evtchn.c @@ -37,7 +37,7 @@ int xc_evtchn_alloc_unbound(int xc_handle, 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_handle, 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 --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h index 715764ac6e..37d12d5788 100644 --- a/tools/libxc/xenctrl.h +++ b/tools/libxc/xenctrl.h @@ -432,6 +432,9 @@ int xc_evtchn_alloc_unbound(int xc_handle, 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 --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c index a95b7d9bf8..665a61b84a 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -478,6 +478,24 @@ static PyObject *pyxc_evtchn_alloc_unbound(XcObject *self, 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) @@ -1202,6 +1220,12 @@ static PyMethodDef pyxc_methods[] = { " 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, METH_VARARGS | METH_KEYWORDS, "\n" diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index 70665a7e78..0116a9aa91 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -735,6 +735,29 @@ static long evtchn_unmask(evtchn_unmask_t *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; @@ -833,6 +856,14 @@ long do_event_channel_op(int cmd, XEN_GUEST_HANDLE(void) arg) break; } + case EVTCHNOP_reset: { + struct evtchn_reset reset; + if ( copy_from_guest(&reset, arg, 1) != 0 ) + return -EFAULT; + rc = evtchn_reset(&reset); + break; + } + default: rc = -ENOSYS; break; diff --git a/xen/include/public/event_channel.h b/xen/include/public/event_channel.h index 62cf764040..d35cce53e4 100644 --- a/xen/include/public/event_channel.h +++ b/xen/include/public/event_channel.h @@ -217,6 +217,19 @@ struct evtchn_unmask { 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. */ |