[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] lsevtchn: Simple tool to list event channel states for a domain.
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1207753894 -3600 # Node ID 64f81cd158d44c837b8f8b25a0a7e2b84083c0e4 # Parent 5ffd167d777239aa028beeb13166a3aab1c27574 lsevtchn: Simple tool to list event channel states for a domain. Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxxxxx> --- .hgignore | 1 tools/libxc/xc_evtchn.c | 24 +++++++++++++++---- tools/libxc/xenctrl.h | 3 ++ tools/xcutils/Makefile | 2 - tools/xcutils/lsevtchn.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 84 insertions(+), 5 deletions(-) diff -r 5ffd167d7772 -r 64f81cd158d4 .hgignore --- a/.hgignore Wed Apr 09 16:04:10 2008 +0100 +++ b/.hgignore Wed Apr 09 16:11:34 2008 +0100 @@ -199,6 +199,7 @@ ^tools/vtpm/tpm_emulator/.*$ ^tools/vtpm/vtpm/.*$ ^tools/vtpm_manager/manager/vtpm_managerd$ +^tools/xcutils/lsevtchn$ ^tools/xcutils/xc_restore$ ^tools/xcutils/xc_save$ ^tools/xcutils/readnotes$ diff -r 5ffd167d7772 -r 64f81cd158d4 tools/libxc/xc_evtchn.c --- a/tools/libxc/xc_evtchn.c Wed Apr 09 16:04:10 2008 +0100 +++ b/tools/libxc/xc_evtchn.c Wed Apr 09 16:11:34 2008 +0100 @@ -9,7 +9,8 @@ #include "xc_private.h" -static int do_evtchn_op(int xc_handle, int cmd, void *arg, size_t arg_size) +static int do_evtchn_op(int xc_handle, int cmd, void *arg, + size_t arg_size, int silently_fail) { int ret = -1; DECLARE_HYPERCALL; @@ -24,7 +25,7 @@ static int do_evtchn_op(int xc_handle, i goto out; } - if ((ret = do_xen_hypercall(xc_handle, &hypercall)) < 0) + if ((ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 && !silently_fail) ERROR("do_evtchn_op: HYPERVISOR_event_channel_op failed: %d", ret); unlock_pages(arg, arg_size); @@ -44,7 +45,7 @@ xc_evtchn_alloc_unbound(int xc_handle, .remote_dom = (domid_t)remote_dom }; - rc = do_evtchn_op(xc_handle, EVTCHNOP_alloc_unbound, &arg, sizeof(arg)); + rc = do_evtchn_op(xc_handle, EVTCHNOP_alloc_unbound, &arg, sizeof(arg), 0); if ( rc == 0 ) rc = arg.port; @@ -55,5 +56,20 @@ 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)); + return do_evtchn_op(xc_handle, EVTCHNOP_reset, &arg, sizeof(arg), 0); } + +int xc_evtchn_status(int xc_handle, + uint32_t dom, + uint32_t port) +{ + int rc; + struct evtchn_status arg = { .dom = (domid_t)dom, + .port = (evtchn_port_t)port }; + + rc = do_evtchn_op(xc_handle, EVTCHNOP_status, &arg, sizeof(arg), 1); + if ( rc == 0 ) + rc = arg.status; + + return rc; +} diff -r 5ffd167d7772 -r 64f81cd158d4 tools/libxc/xenctrl.h --- a/tools/libxc/xenctrl.h Wed Apr 09 16:04:10 2008 +0100 +++ b/tools/libxc/xenctrl.h Wed Apr 09 16:11:34 2008 +0100 @@ -470,6 +470,9 @@ xc_evtchn_alloc_unbound(int xc_handle, int xc_evtchn_reset(int xc_handle, uint32_t dom); +int xc_evtchn_status(int xc_handle, + uint32_t dom, + uint32_t port); /* * Return a handle to the event channel driver, or -1 on failure, in which case diff -r 5ffd167d7772 -r 64f81cd158d4 tools/xcutils/Makefile --- a/tools/xcutils/Makefile Wed Apr 09 16:04:10 2008 +0100 +++ b/tools/xcutils/Makefile Wed Apr 09 16:11:34 2008 +0100 @@ -18,7 +18,7 @@ CFLAGS += -Wp,-MD,.$(@F).d CFLAGS += -Wp,-MD,.$(@F).d PROG_DEP = .*.d -PROGRAMS = xc_restore xc_save readnotes +PROGRAMS = xc_restore xc_save readnotes lsevtchn LDLIBS = $(LDFLAGS_libxenctrl) $(LDFLAGS_libxenguest) $(LDFLAGS_libxenstore) diff -r 5ffd167d7772 -r 64f81cd158d4 tools/xcutils/lsevtchn.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/xcutils/lsevtchn.c Wed Apr 09 16:11:34 2008 +0100 @@ -0,0 +1,59 @@ +#include <err.h> +#include <stdlib.h> +#include <stdint.h> +#include <string.h> +#include <stdio.h> + +#include <xs.h> +#include <xenctrl.h> +#include <xenguest.h> + +int +main(int argc, char **argv) +{ + int xc_fd; + int domid = 0, port = 0, status; + const char *msg; + + if ( argc > 1 ) + domid = strtol(argv[1], NULL, 10); + + xc_fd = xc_interface_open(); + if ( xc_fd < 0 ) + errx(1, "failed to open control interface"); + + while ( (status = xc_evtchn_status(xc_fd, domid, port)) >= 0 ) + { + switch ( status ) + { + case EVTCHNSTAT_closed: + msg = "Channel is not in use."; + break; + case EVTCHNSTAT_unbound: + msg = "Channel is waiting interdom connection."; + break; + case EVTCHNSTAT_interdomain: + msg = "Channel is connected to remote domain."; + break; + case EVTCHNSTAT_pirq: + msg = "Channel is bound to a phys IRQ line."; + break; + case EVTCHNSTAT_virq: + msg = "Channel is bound to a virtual IRQ line."; + break; + case EVTCHNSTAT_ipi: + msg = "Channel is bound to a virtual IPI line."; + break; + default: + msg = "Unknown."; + break; + + } + printf("%03d: %d: %s\n", port, status, msg); + port++; + } + + xc_interface_close(xc_fd); + + return 0; +} _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |