diff -r c1fafdcdb19a tools/console/daemon/io.c --- a/tools/console/daemon/io.c Tue May 01 22:24:01 2007 +0100 +++ b/tools/console/daemon/io.c Wed May 02 11:24:44 2007 +0100 @@ -214,7 +214,7 @@ static int domain_create_tty(struct doma } return master; - out: +out: close(master); return -1; } @@ -253,15 +253,13 @@ int xs_gather(struct xs_handle *xs, cons static int domain_create_ring(struct domain *dom) { - int err, remote_port, ring_ref, rc; + int err, remote_port, rc; err = xs_gather(xs, dom->serialpath, - "ring-ref", "%u", &ring_ref, "port", "%i", &remote_port, NULL); if (err) { err = xs_gather(xs, dom->conspath, - "ring-ref", "%u", &ring_ref, "port", "%i", &remote_port, NULL); if (err) @@ -270,21 +268,18 @@ static int domain_create_ring(struct dom } else dom->use_consolepath = 0; - if ((ring_ref == dom->ring_ref) && (remote_port == dom->remote_port)) + if ((dom->interface != NULL) && (remote_port == dom->remote_port)) goto out; - if (ring_ref != dom->ring_ref) { - if (dom->interface != NULL) - munmap(dom->interface, getpagesize()); - dom->interface = xc_map_foreign_range( - xc, dom->domid, getpagesize(), - PROT_READ|PROT_WRITE, - (unsigned long)ring_ref); + if (dom->interface == NULL) { + dom->interface = xc_gnttab_map_grant_ref(xcg, + dom->domid, + 1, + PROT_READ|PROT_WRITE); if (dom->interface == NULL) { err = EINVAL; goto out; } - dom->ring_ref = ring_ref; } dom->local_port = -1; @@ -301,7 +296,7 @@ static int domain_create_ring(struct dom } rc = xc_evtchn_bind_interdomain(dom->xce_handle, - dom->domid, remote_port); + dom->domid, remote_port); if (rc == -1) { err = errno; @@ -325,7 +320,7 @@ static int domain_create_ring(struct dom } } - out: +out: return err; } @@ -406,7 +401,7 @@ static struct domain *create_domain(int dolog(LOG_DEBUG, "New domain %d", domid); return dom; - out: +out: free(dom->serialpath); free(dom->conspath); free(dom); @@ -462,7 +457,8 @@ static void shutdown_domain(struct domai d->is_dead = true; watch_domain(d, false); if (d->interface != NULL) - munmap(d->interface, getpagesize()); +/* munmap(d->interface, getpagesize()); */ + xc_gnttab_munmap(xcg, d->interface, 1); d->interface = NULL; if (d->xce_handle != -1) xc_evtchn_close(d->xce_handle); diff -r c1fafdcdb19a tools/console/daemon/utils.c --- a/tools/console/daemon/utils.c Tue May 01 22:24:01 2007 +0100 +++ b/tools/console/daemon/utils.c Tue Apr 03 13:29:08 2007 +0100 @@ -38,6 +38,7 @@ struct xs_handle *xs; int xc; +int xcg; static void child_exit(int sig) { @@ -121,6 +122,12 @@ bool xen_setup(void) goto out; } + xcg = xc_gnttab_open(); + if (xcg == -1) { + dolog(LOG_ERR, "Failed to contact gntdev (%m)"); + goto out; + } + if (!xs_watch(xs, "@introduceDomain", "domlist")) { dolog(LOG_ERR, "xenstore watch on @introduceDomain fails."); goto out; @@ -138,6 +145,8 @@ bool xen_setup(void) xs_daemon_close(xs); if (xc != -1) xc_interface_close(xc); + if (xcg != -1) + xc_gnttab_close(xcg); return false; } diff -r c1fafdcdb19a tools/console/daemon/utils.h --- a/tools/console/daemon/utils.h Tue May 01 22:24:01 2007 +0100 +++ b/tools/console/daemon/utils.h Tue Apr 03 13:47:07 2007 +0100 @@ -32,6 +32,7 @@ bool xen_setup(void); extern struct xs_handle *xs; extern int xc; +extern int xcg; #if 1 #define dolog(val, fmt, ...) do { \