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);
}
#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);