From 2434aa5074f5f05f102fd9b0d1a33bc6673dafb0 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Wed, 9 Apr 2008 16:11:34 +0100 Subject: lsevtchn: Simple tool to list event channel states for a domain. Signed-off-by: Ian Campbell --- tools/xcutils/Makefile | 2 +- tools/xcutils/lsevtchn.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 tools/xcutils/lsevtchn.c (limited to 'tools/xcutils') diff --git a/tools/xcutils/Makefile b/tools/xcutils/Makefile index d38e8ac07d..15c0c9758e 100644 --- a/tools/xcutils/Makefile +++ b/tools/xcutils/Makefile @@ -18,7 +18,7 @@ CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore) 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 --git a/tools/xcutils/lsevtchn.c b/tools/xcutils/lsevtchn.c new file mode 100644 index 0000000000..3dc3cb3c42 --- /dev/null +++ b/tools/xcutils/lsevtchn.c @@ -0,0 +1,59 @@ +#include +#include +#include +#include +#include + +#include +#include +#include + +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; +} -- cgit v1.2.3