ia64/xen-unstable

changeset 18444:be573a356c90

lsevtchn: Improve this evtchn reporting tool.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Sep 05 11:56:35 2008 +0100 (2008-09-05)
parents 1a785d213573
children b146f0cf3b8b
files tools/libxc/xc_evtchn.c tools/libxc/xenctrl.h tools/xcutils/lsevtchn.c
line diff
     1.1 --- a/tools/libxc/xc_evtchn.c	Fri Sep 05 11:18:20 2008 +0100
     1.2 +++ b/tools/libxc/xc_evtchn.c	Fri Sep 05 11:56:35 2008 +0100
     1.3 @@ -59,17 +59,8 @@ int xc_evtchn_reset(int xc_handle,
     1.4      return do_evtchn_op(xc_handle, EVTCHNOP_reset, &arg, sizeof(arg), 0);
     1.5  }
     1.6  
     1.7 -int xc_evtchn_status(int xc_handle,
     1.8 -                     uint32_t dom,
     1.9 -                     uint32_t port)
    1.10 +int xc_evtchn_status(int xc_handle, xc_evtchn_status_t *status)
    1.11  {
    1.12 -    int rc;
    1.13 -    struct evtchn_status arg = { .dom = (domid_t)dom,
    1.14 -                                 .port = (evtchn_port_t)port };
    1.15 -
    1.16 -    rc = do_evtchn_op(xc_handle, EVTCHNOP_status, &arg, sizeof(arg), 1);
    1.17 -    if ( rc == 0 )
    1.18 -        rc = arg.status;
    1.19 -
    1.20 -    return rc;
    1.21 +    return do_evtchn_op(xc_handle, EVTCHNOP_status, status,
    1.22 +                        sizeof(*status), 1);
    1.23  }
     2.1 --- a/tools/libxc/xenctrl.h	Fri Sep 05 11:18:20 2008 +0100
     2.2 +++ b/tools/libxc/xenctrl.h	Fri Sep 05 11:56:35 2008 +0100
     2.3 @@ -502,9 +502,9 @@ xc_evtchn_alloc_unbound(int xc_handle,
     2.4  
     2.5  int xc_evtchn_reset(int xc_handle,
     2.6                      uint32_t dom);
     2.7 -int xc_evtchn_status(int xc_handle,
     2.8 -                     uint32_t dom,
     2.9 -                     uint32_t port);
    2.10 +
    2.11 +typedef struct evtchn_status xc_evtchn_status_t;
    2.12 +int xc_evtchn_status(int xc_handle, xc_evtchn_status_t *status);
    2.13  
    2.14  /*
    2.15   * Return a handle to the event channel driver, or -1 on failure, in which case
     3.1 --- a/tools/xcutils/lsevtchn.c	Fri Sep 05 11:18:20 2008 +0100
     3.2 +++ b/tools/xcutils/lsevtchn.c	Fri Sep 05 11:56:35 2008 +0100
     3.3 @@ -8,49 +8,55 @@
     3.4  #include <xenctrl.h>
     3.5  #include <xenguest.h>
     3.6  
     3.7 -int
     3.8 -main(int argc, char **argv)
     3.9 +int main(int argc, char **argv)
    3.10  {
    3.11 -    int xc_fd;
    3.12 -    int domid = 0, port = 0, status;
    3.13 -    const char *msg;
    3.14 +    int xc_fd, domid, port, rc;
    3.15 +    xc_evtchn_status_t status;
    3.16  
    3.17 -    if ( argc > 1 )
    3.18 -        domid = strtol(argv[1], NULL, 10);
    3.19 +    domid = (argc > 1) ? strtol(argv[1], NULL, 10) : 0;
    3.20  
    3.21      xc_fd = xc_interface_open();
    3.22      if ( xc_fd < 0 )
    3.23          errx(1, "failed to open control interface");
    3.24  
    3.25 -    while ( (status = xc_evtchn_status(xc_fd, domid, port)) >= 0 )
    3.26 +    for ( port = 0; ; port++ )
    3.27      {
    3.28 -        switch ( status )
    3.29 +        status.dom = domid;
    3.30 +        status.port = port;
    3.31 +        rc = xc_evtchn_status(xc_fd, &status);
    3.32 +        if ( rc < 0 )
    3.33 +            break;
    3.34 +
    3.35 +        if ( status.status == EVTCHNSTAT_closed )
    3.36 +            continue;
    3.37 +
    3.38 +        printf("%4d: VCPU %u: ", port, status.vcpu);
    3.39 +
    3.40 +        switch ( status.status )
    3.41          {
    3.42 -        case EVTCHNSTAT_closed:
    3.43 -            msg = "Channel is not in use.";
    3.44 -            break;
    3.45          case EVTCHNSTAT_unbound:
    3.46 -            msg = "Channel is waiting interdom connection.";
    3.47 +            printf("Interdomain (Waiting connection) - Remote Domain %u",
    3.48 +                   status.u.unbound.dom);
    3.49              break;
    3.50          case EVTCHNSTAT_interdomain:
    3.51 -            msg = "Channel is connected to remote domain.";
    3.52 +            printf("Interdomain (Connected) - Remote Domain %u, Port %u",
    3.53 +                   status.u.interdomain.dom, status.u.interdomain.port);
    3.54              break;
    3.55          case EVTCHNSTAT_pirq:
    3.56 -            msg = "Channel is bound to a phys IRQ line.";
    3.57 +            printf("Physical IRQ %u", status.u.pirq);
    3.58              break;
    3.59          case EVTCHNSTAT_virq:
    3.60 -            msg = "Channel is bound to a virtual IRQ line.";
    3.61 +            printf("Virtual IRQ %u", status.u.virq);
    3.62              break;
    3.63          case EVTCHNSTAT_ipi:
    3.64 -            msg = "Channel is bound to a virtual IPI line.";
    3.65 +            printf("IPI");
    3.66              break;
    3.67          default:
    3.68 -            msg = "Unknown.";
    3.69 +            printf("Unknown");
    3.70              break;
    3.71 +        }
    3.72  
    3.73 -        }
    3.74 -        printf("%03d: %d: %s\n", port, status, msg);
    3.75 -        port++;
    3.76 +        printf("\n");
    3.77      }
    3.78  
    3.79      xc_interface_close(xc_fd);