[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] interdomain event channel using libxc
Hi, This stub works well for me, but suppose I have to "move" the domU code at "kernel level" (i.e. as a module) which hypercalls should I invoke and in what order? This is a "stupid" scheme of what I mean to do: domU --> kernel level, using hypercalls dom0 --> user level (see code below), using libxc Thanks -- f Stephan Creutz wrote: > > Hi, > > [... cut] > > Program running in Dom0: > > #include <stdio.h> > #include <time.h> > #include <sys/select.h> > #include <xen/xenctrl.h> > > static int xc_handle = -1; > > static void event_channel(uint32_t domid) > { > int xce_handle = xc_evtchn_open(); > if (xce_handle == -1) { > fprintf(stderr, "opening event channel failed\n"); > return; > } > > int port = xc_evtchn_alloc_unbound(xc_handle, DOMID_SELF, domid); > if (port == -1) > fprintf(stderr, "port allocation failed\n"); > else > printf("allocated port: %d\n", port); > > fd_set rfds; > > FD_ZERO(&rfds); > int evtchn_fd = xc_evtchn_fd(xce_handle); > FD_SET(evtchn_fd, &rfds); > > struct timeval select_timeout = { > .tv_sec = 10, > .tv_usec = 0 > }; > > if (xc_evtchn_unmask(xce_handle, (evtchn_port_t)port) == -1) > fprintf(stderr, "unmasking failed\n"); > > printf(">>> select\n"); > int ret = select(evtchn_fd + 1, &rfds, NULL, NULL, &select_timeout); > > if (ret == -1) > perror("select()"); > else if (ret && FD_ISSET(evtchn_fd, &rfds)) { > printf(">>> event <<<\n"); > evtchn_port_t next_port; > if ((next_port = xc_evtchn_pending(xce_handle)) == > (evtchn_port_t)-1) > perror("xc_evtchn_pending"); > if (xc_evtchn_unmask(xce_handle, next_port) == -1) > fprintf(stderr, "unable to umask\n"); > } else > fprintf(stderr, "select timeout\n"); > > xc_evtchn_close(xce_handle); > printf("eventchannel closed\n"); > } > > int main(void) > { > xc_handle = xc_interface_open(); > if (xc_handle == -1) { > fprintf(stderr, "connection to hypervisor failed\n"); > return 1; > } > > xc_dominfo_t dominfo[2]; > int number_of_domains = xc_domain_getinfo(xc_handle, 0, 2, dominfo); > if (number_of_domains < 2) { > fprintf(stderr, "there is only one domain, but need two\n"); > goto error; > } > > event_channel(dominfo[1].domid); > > error: > xc_interface_close(xc_handle); > return 0; > } > > Program running in DomU: > > #include <stdio.h> > #include <stdlib.h> > #include <time.h> > #include <xen/xenctrl.h> > > static int xc_handle = -1; > static const uint32_t domid = 0; > > int main(int argc, char **argv) > { > if (argc < 2) { > fprintf(stderr, "usage: %s <remote-port>\n", argv[0]); > return 1; > } > > xc_handle = xc_interface_open(); > if (xc_handle == -1) { > fprintf(stderr, "connection to hypervisor failed\n"); > return 1; > } > > int xce_handle = xc_evtchn_open(); > if (xce_handle == -1) { > fprintf(stderr, "opening of event channel failed\n"); > goto error; > } > > evtchn_port_t remote_port = (evtchn_port_t)atoi(argv[1]); > evtchn_port_t local_port; > local_port = xc_evtchn_bind_interdomain(xce_handle, domid, > remote_port); if (local_port == (evtchn_port_t)-1) > fprintf(stderr, "binding to interdomain channel failed\n"); > > if (xc_evtchn_notify(xce_handle, local_port) == -1) > fprintf(stderr, "notify failed\n"); > > struct timespec nano_timespec = { > .tv_sec = 5, > .tv_nsec = 0 > }; > nanosleep(&nano_timespec, NULL); > if (xc_evtchn_unbind(xce_handle, local_port) == -1) > fprintf(stderr, "unbind failed\n"); > xc_evtchn_close(xce_handle); > > error: > xc_interface_close(xc_handle); > return 0; > } > -- View this message in context: http://www.nabble.com/interdomain-event-channel-using-libxc-tf2738572.html#a13709427 Sent from the Xen - Dev mailing list archive at Nabble.com. _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |