aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.hgignore1
-rw-r--r--tools/libxc/xc_evtchn.c24
-rw-r--r--tools/libxc/xenctrl.h3
-rw-r--r--tools/xcutils/Makefile2
-rw-r--r--tools/xcutils/lsevtchn.c59
5 files changed, 84 insertions, 5 deletions
diff --git a/.hgignore b/.hgignore
index 4f4b84aa92..5913471871 100644
--- a/.hgignore
+++ b/.hgignore
@@ -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 --git a/tools/libxc/xc_evtchn.c b/tools/libxc/xc_evtchn.c
index 0992a7bdbb..5e1ca26502 100644
--- a/tools/libxc/xc_evtchn.c
+++ b/tools/libxc/xc_evtchn.c
@@ -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, int cmd, void *arg, size_t arg_size)
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 --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h
index 8eb3f5ef6f..8bd5fb4fb8 100644
--- a/tools/libxc/xenctrl.h
+++ b/tools/libxc/xenctrl.h
@@ -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 --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 <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;
+}