#include #include #include #include int main(int argc, char** argv) { // This test is to check that you can use several handles to evtchn. xc_evtchn *h1, *h2; evtchn_port_or_error_t dest, src; int fd, ret; fd_set fdset; FD_ZERO(&fdset); h1 = xc_evtchn_open(NULL, 0); h2 = xc_evtchn_open(NULL, 0); if (h1 == NULL || h2 == NULL) { perror("xc_evtchn_open"); exit(EXIT_FAILURE); } dest = xc_evtchn_bind_unbound_port(h1, 0); if (dest == -1) { perror("xc_evtchn_bind_unbound_port"); exit(EXIT_FAILURE); } src = xc_evtchn_bind_interdomain(h1, 0, dest); if (src == -1) { perror("xc_evtchn_bind_interdomain"); exit(EXIT_FAILURE); } fd = xc_evtchn_fd(h2); if (fd < 0) { perror("xc_evtchn_fd"); exit(EXIT_FAILURE); } FD_SET(fd, &fdset); ret = xc_evtchn_notify(h1, src); if (ret == -1) { perror("xc_evtchn_notify"); exit(EXIT_FAILURE); } ret = select(fd+1, &fdset, NULL, NULL, NULL); if (ret == -1) { perror("select"); exit(EXIT_FAILURE); } printf("select says there is %d bit set in the bitmask.\n", ret); exit(EXIT_SUCCESS); }