~ubuntu-branches/ubuntu/intrepid/xen-3.3/intrepid-updates

« back to all changes in this revision

Viewing changes to tools/xcutils/lsevtchn.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2008-08-14 10:28:57 UTC
  • Revision ID: james.westby@ubuntu.com-20080814102857-a832fn5gowurz5do
Tags: upstream-3.3.0
ImportĀ upstreamĀ versionĀ 3.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <err.h>
 
2
#include <stdlib.h>
 
3
#include <stdint.h>
 
4
#include <string.h>
 
5
#include <stdio.h>
 
6
 
 
7
#include <xs.h>
 
8
#include <xenctrl.h>
 
9
#include <xenguest.h>
 
10
 
 
11
int
 
12
main(int argc, char **argv)
 
13
{
 
14
    int xc_fd;
 
15
    int domid = 0, port = 0, status;
 
16
    const char *msg;
 
17
 
 
18
    if ( argc > 1 )
 
19
        domid = strtol(argv[1], NULL, 10);
 
20
 
 
21
    xc_fd = xc_interface_open();
 
22
    if ( xc_fd < 0 )
 
23
        errx(1, "failed to open control interface");
 
24
 
 
25
    while ( (status = xc_evtchn_status(xc_fd, domid, port)) >= 0 )
 
26
    {
 
27
        switch ( status )
 
28
        {
 
29
        case EVTCHNSTAT_closed:
 
30
            msg = "Channel is not in use.";
 
31
            break;
 
32
        case EVTCHNSTAT_unbound:
 
33
            msg = "Channel is waiting interdom connection.";
 
34
            break;
 
35
        case EVTCHNSTAT_interdomain:
 
36
            msg = "Channel is connected to remote domain.";
 
37
            break;
 
38
        case EVTCHNSTAT_pirq:
 
39
            msg = "Channel is bound to a phys IRQ line.";
 
40
            break;
 
41
        case EVTCHNSTAT_virq:
 
42
            msg = "Channel is bound to a virtual IRQ line.";
 
43
            break;
 
44
        case EVTCHNSTAT_ipi:
 
45
            msg = "Channel is bound to a virtual IPI line.";
 
46
            break;
 
47
        default:
 
48
            msg = "Unknown.";
 
49
            break;
 
50
 
 
51
        }
 
52
        printf("%03d: %d: %s\n", port, status, msg);
 
53
        port++;
 
54
    }
 
55
 
 
56
    xc_interface_close(xc_fd);
 
57
 
 
58
    return 0;
 
59
}