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