| 1 |
#include <err.h> |
| 2 |
#include <stdlib.h> |
| 3 |
#include <stdint.h> |
| 4 |
#include <string.h> |
| 5 |
#include <stdio.h> |
| 6 |
#include <errno.h> |
| 7 |
|
| 8 |
#include <xenctrl.h> |
| 9 |
|
| 10 |
int main(int argc, char **argv) |
| 11 |
{ |
| 12 |
xc_interface *xch; |
| 13 |
int domid, port, rc; |
| 14 |
xc_evtchn_status_t status; |
| 15 |
|
| 16 |
domid = (argc > 1) ? strtol(argv[1], NULL, 10) : 0; |
| 17 |
|
| 18 |
xch = xc_interface_open(0,0,0); |
| 19 |
if ( !xch ) |
| 20 |
errx(1, "failed to open control interface"); |
| 21 |
|
| 22 |
for ( port = 0; ; port++ ) |
| 23 |
{ |
| 24 |
status.dom = domid; |
| 25 |
status.port = port; |
| 26 |
rc = xc_evtchn_status(xch, &status); |
| 27 |
if ( rc < 0 ) |
| 28 |
{ |
| 29 |
switch ( errno ) |
| 30 |
{ |
| 31 |
case EACCES: /* Xen-owned evtchn */ |
| 32 |
continue; |
| 33 |
|
| 34 |
case EINVAL: /* Port enumeration has ended */ |
| 35 |
rc = 0; |
| 36 |
break; |
| 37 |
|
| 38 |
default: |
| 39 |
perror("xc_evtchn_status"); |
| 40 |
rc = 1; |
| 41 |
break; |
| 42 |
} |
| 43 |
goto out; |
| 44 |
} |
| 45 |
|
| 46 |
if ( status.status == EVTCHNSTAT_closed ) |
| 47 |
continue; |
| 48 |
|
| 49 |
printf("%4d: VCPU %u: ", port, status.vcpu); |
| 50 |
|
| 51 |
switch ( status.status ) |
| 52 |
{ |
| 53 |
case EVTCHNSTAT_unbound: |
| 54 |
printf("Interdomain (Waiting connection) - Remote Domain %u", |
| 55 |
status.u.unbound.dom); |
| 56 |
break; |
| 57 |
case EVTCHNSTAT_interdomain: |
| 58 |
printf("Interdomain (Connected) - Remote Domain %u, Port %u", |
| 59 |
status.u.interdomain.dom, status.u.interdomain.port); |
| 60 |
break; |
| 61 |
case EVTCHNSTAT_pirq: |
| 62 |
printf("Physical IRQ %u", status.u.pirq); |
| 63 |
break; |
| 64 |
case EVTCHNSTAT_virq: |
| 65 |
printf("Virtual IRQ %u", status.u.virq); |
| 66 |
break; |
| 67 |
case EVTCHNSTAT_ipi: |
| 68 |
printf("IPI"); |
| 69 |
break; |
| 70 |
default: |
| 71 |
printf("Unknown"); |
| 72 |
break; |
| 73 |
} |
| 74 |
|
| 75 |
printf("\n"); |
| 76 |
} |
| 77 |
|
| 78 |
out: |
| 79 |
xc_interface_close(xch); |
| 80 |
|
| 81 |
return rc; |
| 82 |
} |