Exemple #1
0
int libvchan_wait(struct libvchan *ctrl)
{
	int ret;
#ifndef CONFIG_STUBDOM
	ret = xc_evtchn_pending(ctrl->evfd);
#else
	int vchan_fd = libvchan_fd_for_select(ctrl);
	fd_set rfds;

	libvchan_prepare_to_select(ctrl);
	while ((ret = xc_evtchn_pending(ctrl->evfd)) < 0) {
        FD_ZERO(&rfds);
        FD_SET(0, &rfds);
        FD_SET(vchan_fd, &rfds);
        ret = select(vchan_fd + 1, &rfds, NULL, NULL, NULL);
        if (ret < 0 && errno != EINTR) {
            perror("select");
			return ret;
        }
	}
#endif
	if (ret!=-1 && xc_evtchn_unmask(ctrl->evfd, ctrl->evport))
		return -1;
	if (ret!=-1 && libvchan_is_eof(ctrl))
		return -1;
	return ret;
}
Exemple #2
0
static void wait_for_event(void)
{
    int ret;
    fd_set inset;
    evtchn_port_t port;
    struct timeval tv;
    int evtchn_fd;
  
    if (xce_handle < 0) {
        nanosleep(&opts.poll_sleep, NULL);
        return;
    }

    evtchn_fd = xc_evtchn_fd(xce_handle);

    FD_ZERO(&inset);
    FD_SET(evtchn_fd, &inset);
    tv.tv_sec = 1;
    tv.tv_usec = 0;
    // tv = millis_to_timespec(&opts.poll_sleep);
    ret = select(evtchn_fd+1, &inset, NULL, NULL, &tv);
  
    if ( (ret == 1) && FD_ISSET(evtchn_fd, &inset)) {
        if ((port = xc_evtchn_pending(xce_handle)) == -1)
            perror("Failed to read from event fd");
    
        //    if (port == virq_port)
        //      printf("got the event I was looking for\r\n");

        if (xc_evtchn_unmask(xce_handle, port) == -1)
            perror("Failed to write to event fd");
    }
}
Exemple #3
0
static int evtchn_suspend(checkpoint_state* s)
{
    int rc;

    rc = xc_evtchn_notify(s->xce, s->suspend_evtchn);
    if (rc < 0) {
	snprintf(errbuf, sizeof(errbuf),
		 "failed to notify suspend event channel: %d", rc);
	s->errstr = errbuf;

	return -1;
    }

    do
	if (!(rc = pollfd(s, xc_evtchn_fd(s->xce))))
	    rc = xc_evtchn_pending(s->xce);
    while (rc >= 0 && rc != s->suspend_evtchn);
    if (rc <= 0)
	return -1;

    if (xc_evtchn_unmask(s->xce, s->suspend_evtchn) < 0) {
	snprintf(errbuf, sizeof(errbuf),
		 "failed to unmask suspend notification channel: %d", rc);
	s->errstr = errbuf;

	return -1;
    }

    return 0;
}
Exemple #4
0
Fichier : io.c Projet : CPFL/gxen
int libxenvchan_wait(struct libxenvchan *ctrl)
{
	int ret = xc_evtchn_pending(ctrl->event);
	if (ret < 0)
		return -1;
	xc_evtchn_unmask(ctrl->event, ret);
	return 0;
}
CAMLprim value stub_eventchn_pending(value xce)
{
  evtchn_port_or_error_t port;

  port = xc_evtchn_pending(_H(xce));
  if (port == -1)
    caml_failwith("evtchn pending failed");

  return Val_int(port);
}
CAMLprim value stub_eventchn_pending(value xce)
{
	CAMLparam1(xce);
	CAMLlocal1(result);
	evtchn_port_or_error_t port;

	port = xc_evtchn_pending(_H(xce));
	if (port == -1)
		caml_failwith("evtchn pending failed");
	result = Val_int(port);

	CAMLreturn(result);
}
CAMLprim value stub_eventchn_pending(value xce)
{
  CAMLparam1(xce);
  evtchn_port_or_error_t port;

  port = xc_evtchn_pending(_H(xce));
  if (port == -1)
    {
      perror("xc_evtchn_pending");
      caml_failwith(strerror(errno));
    }

  CAMLreturn(Val_int(port));
}
static void xen_be_evtchn_event(void *opaque)
{
    struct XenDevice *xendev = opaque;
    evtchn_port_t port;

    port = xc_evtchn_pending(xendev->evtchndev);
    if (port != xendev->local_port) {
        xen_be_printf(xendev, 0, "xc_evtchn_pending returned %d (expected %d)\n",
                      port, xendev->local_port);
        return;
    }
    xc_evtchn_unmask(xendev->evtchndev, port);

    if (xendev->ops->event) {
        xendev->ops->event(xendev);
    }
}
Exemple #9
0
int xc_await_suspend(xc_interface *xch, xc_evtchn *xce, int suspend_evtchn)
{
    int rc;

    do {
        rc = xc_evtchn_pending(xce);
        if (rc < 0) {
            ERROR("error polling suspend notification channel: %d", rc);
            return -1;
        }
    } while (rc != suspend_evtchn);

    /* harmless for one-off suspend */
    if (xc_evtchn_unmask(xce, suspend_evtchn) < 0)
        ERROR("failed to unmask suspend notification channel: %d", rc);

    return 0;
}
Exemple #10
0
static int await_suspend(void)
{
    int rc;

    do {
        rc = xc_evtchn_pending(si.xce);
        if (rc < 0) {
            warnx("error polling suspend notification channel: %d", rc);
            return -1;
        }
    } while (rc != si.suspend_evtchn);

    /* harmless for one-off suspend */
    if (xc_evtchn_unmask(si.xce, si.suspend_evtchn) < 0)
        warnx("failed to unmask suspend notification channel: %d", rc);

    return 0;
}
Exemple #11
0
/* Process events from the frontend event channel */
static void xenfb_dispatch_channel(void *opaque)
{
	struct xenfb *xenfb = (struct xenfb *)opaque;
	evtchn_port_t port;
	port = xc_evtchn_pending(xenfb->evt_xch);
	if (port == -1) {
		xenfb_shutdown(xenfb);
		exit(1);
	}

	if (port == xenfb->fb.port)
		xenfb_on_fb_event(xenfb);
	else if (port == xenfb->kbd.port)
		xenfb_on_kbd_event(xenfb);

	if (xc_evtchn_unmask(xenfb->evt_xch, port) == -1) {
		xenfb_shutdown(xenfb);
		exit(1);
	}
}
Exemple #12
0
/*
 * XXX only called by tapdisk_xenio_ctx_ring_event
 */
static inline struct td_xenblkif *
xenio_pending_blkif(struct td_xenio_ctx * const ctx)
{
    evtchn_port_or_error_t port;
    struct td_xenblkif *blkif;
    int err;

    ASSERT(ctx);

    /*
     * Get the local port for which there is a pending event.
     */
    port = xc_evtchn_pending(ctx->xce_handle);
    if (port == -1) {
        /* TODO log error */
        return NULL;
    }

    /*
     * Find the block interface with that local port.
     */
    tapdisk_xenio_ctx_find_blkif(ctx, blkif,
            blkif->port == port);
    if (blkif) {
        err = xc_evtchn_unmask(ctx->xce_handle, port);
        if (err) {
            /* TODO log error */
            return NULL;
        }
    }
    /*
     * TODO Is it possible to have an pending event channel but no block
     * interface associated with it?
     */

    return blkif;
}