lsevtchn: Improve this evtchn reporting tool.
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 5 Sep 2008 10:56:35 +0000 (11:56 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 5 Sep 2008 10:56:35 +0000 (11:56 +0100)
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
tools/libxc/xc_evtchn.c
tools/libxc/xenctrl.h
tools/xcutils/lsevtchn.c

index 5e1ca265025aad665820a022b1417c9c7162dcde..204698abe0f509629f44b76e7dbe15d9818ca2af 100644 (file)
@@ -59,17 +59,8 @@ int xc_evtchn_reset(int xc_handle,
     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 xc_evtchn_status(int xc_handle, xc_evtchn_status_t *status)
 {
-    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;
+    return do_evtchn_op(xc_handle, EVTCHNOP_status, status,
+                        sizeof(*status), 1);
 }
index 8b4ed304e51359fe849e389ad502bfdd3ab7a53b..7202e8171decfae91b8dcb3d544b25b6f9c416af 100644 (file)
@@ -502,9 +502,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);
+
+typedef struct evtchn_status xc_evtchn_status_t;
+int xc_evtchn_status(int xc_handle, xc_evtchn_status_t *status);
 
 /*
  * Return a handle to the event channel driver, or -1 on failure, in which case
index 3dc3cb3c425a1fe0494f8cda5b1027047b128426..7e7bcbeff7952a7ceaa7b8a68e9e46407428c871 100644 (file)
@@ -8,49 +8,55 @@
 #include <xenctrl.h>
 #include <xenguest.h>
 
-int
-main(int argc, char **argv)
+int main(int argc, char **argv)
 {
-    int xc_fd;
-    int domid = 0, port = 0, status;
-    const char *msg;
+    int xc_fd, domid, port, rc;
+    xc_evtchn_status_t status;
 
-    if ( argc > 1 )
-        domid = strtol(argv[1], NULL, 10);
+    domid = (argc > 1) ? strtol(argv[1], NULL, 10) : 0;
 
     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 )
+    for ( port = 0; ; port++ )
     {
-        switch ( status )
-        {
-        case EVTCHNSTAT_closed:
-            msg = "Channel is not in use.";
+        status.dom = domid;
+        status.port = port;
+        rc = xc_evtchn_status(xc_fd, &status);
+        if ( rc < 0 )
             break;
+
+        if ( status.status == EVTCHNSTAT_closed )
+            continue;
+
+        printf("%4d: VCPU %u: ", port, status.vcpu);
+
+        switch ( status.status )
+        {
         case EVTCHNSTAT_unbound:
-            msg = "Channel is waiting interdom connection.";
+            printf("Interdomain (Waiting connection) - Remote Domain %u",
+                   status.u.unbound.dom);
             break;
         case EVTCHNSTAT_interdomain:
-            msg = "Channel is connected to remote domain.";
+            printf("Interdomain (Connected) - Remote Domain %u, Port %u",
+                   status.u.interdomain.dom, status.u.interdomain.port);
             break;
         case EVTCHNSTAT_pirq:
-            msg = "Channel is bound to a phys IRQ line.";
+            printf("Physical IRQ %u", status.u.pirq);
             break;
         case EVTCHNSTAT_virq:
-            msg = "Channel is bound to a virtual IRQ line.";
+            printf("Virtual IRQ %u", status.u.virq);
             break;
         case EVTCHNSTAT_ipi:
-            msg = "Channel is bound to a virtual IPI line.";
+            printf("IPI");
             break;
         default:
-            msg = "Unknown.";
+            printf("Unknown");
             break;
-
         }
-        printf("%03d: %d: %s\n", port, status, msg);
-        port++;
+
+        printf("\n");
     }
 
     xc_interface_close(xc_fd);