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