aboutsummaryrefslogtreecommitdiffstats
path: root/tools/console/daemon
diff options
context:
space:
mode:
authorChristian Limpach <Christian.Limpach@xensource.com>2007-05-01 14:17:01 +0100
committerChristian Limpach <Christian.Limpach@xensource.com>2007-05-01 14:17:01 +0100
commit596f933f569b4c0f0d82502bf7e4fbf44c509798 (patch)
tree57f4a5d19dbcb2d70888663b47590934860d65c4 /tools/console/daemon
parent1f2d7a821f44cdb3ec30ab9f0d4fc698609bdcb4 (diff)
downloadxen-596f933f569b4c0f0d82502bf7e4fbf44c509798.tar.gz
xen-596f933f569b4c0f0d82502bf7e4fbf44c509798.tar.bz2
xen-596f933f569b4c0f0d82502bf7e4fbf44c509798.zip
[pv console] Move console information in xenstore to serial/0/.
Support information in console/ in a backwards compatible fashion. This puts the serial port information for pv domains at the same location where it is for hvm domains. Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
Diffstat (limited to 'tools/console/daemon')
-rw-r--r--tools/console/daemon/io.c70
1 files changed, 62 insertions, 8 deletions
diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index ab8ce1280e..bc2b188780 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -61,6 +61,8 @@ struct domain
struct buffer buffer;
struct domain *next;
char *conspath;
+ char *serialpath;
+ int use_consolepath;
int ring_ref;
evtchn_port_t local_port;
evtchn_port_t remote_port;
@@ -164,7 +166,20 @@ static int domain_create_tty(struct domain *dom)
tcsetattr(master, TCSAFLUSH, &term);
}
- success = asprintf(&path, "%s/limit", dom->conspath) != -1;
+ if (dom->use_consolepath) {
+ success = asprintf(&path, "%s/limit", dom->conspath) !=
+ -1;
+ if (!success)
+ goto out;
+ data = xs_read(xs, XBT_NULL, path, &len);
+ if (data) {
+ dom->buffer.max_capacity = strtoul(data, 0, 0);
+ free(data);
+ }
+ free(path);
+ }
+
+ success = asprintf(&path, "%s/limit", dom->serialpath) != -1;
if (!success)
goto out;
data = xs_read(xs, XBT_NULL, path, &len);
@@ -174,7 +189,7 @@ static int domain_create_tty(struct domain *dom)
}
free(path);
- success = asprintf(&path, "%s/tty", dom->conspath) != -1;
+ success = asprintf(&path, "%s/tty", dom->serialpath) != -1;
if (!success)
goto out;
success = xs_write(xs, XBT_NULL, path, slave, strlen(slave));
@@ -182,6 +197,18 @@ static int domain_create_tty(struct domain *dom)
if (!success)
goto out;
+ if (dom->use_consolepath) {
+ success = asprintf(&path, "%s/tty", dom->conspath) !=
+ -1;
+ if (!success)
+ goto out;
+ success = xs_write(xs, XBT_NULL, path, slave,
+ strlen(slave));
+ free(path);
+ if (!success)
+ goto out;
+ }
+
if (fcntl(master, F_SETFL, O_NONBLOCK) == -1)
goto out;
}
@@ -228,12 +255,20 @@ static int domain_create_ring(struct domain *dom)
{
int err, remote_port, ring_ref, rc;
- err = xs_gather(xs, dom->conspath,
+ err = xs_gather(xs, dom->serialpath,
"ring-ref", "%u", &ring_ref,
"port", "%i", &remote_port,
NULL);
- if (err)
- goto out;
+ if (err) {
+ err = xs_gather(xs, dom->conspath,
+ "ring-ref", "%u", &ring_ref,
+ "port", "%i", &remote_port,
+ NULL);
+ if (err)
+ goto out;
+ dom->use_consolepath = 1;
+ } else
+ dom->use_consolepath = 0;
if ((ring_ref == dom->ring_ref) && (remote_port == dom->remote_port))
goto out;
@@ -301,10 +336,16 @@ static bool watch_domain(struct domain *dom, bool watch)
sprintf(domid_str, "dom%u", dom->domid);
if (watch) {
- success = xs_watch(xs, dom->conspath, domid_str);
- if (success)
- domain_create_ring(dom);
+ success = xs_watch(xs, dom->serialpath, domid_str);
+ if (success) {
+ success = xs_watch(xs, dom->conspath, domid_str);
+ if (success)
+ domain_create_ring(dom);
+ else
+ xs_unwatch(xs, dom->serialpath, domid_str);
+ }
} else {
+ success = xs_unwatch(xs, dom->serialpath, domid_str);
success = xs_unwatch(xs, dom->conspath, domid_str);
}
@@ -324,6 +365,15 @@ static struct domain *create_domain(int domid)
}
dom->domid = domid;
+
+ dom->serialpath = xs_get_domain_path(xs, dom->domid);
+ s = realloc(dom->serialpath, strlen(dom->serialpath) +
+ strlen("/serial/0") + 1);
+ if (s == NULL)
+ goto out;
+ dom->serialpath = s;
+ strcat(dom->serialpath, "/serial/0");
+
dom->conspath = xs_get_domain_path(xs, dom->domid);
s = realloc(dom->conspath, strlen(dom->conspath) +
strlen("/console") + 1);
@@ -357,6 +407,7 @@ static struct domain *create_domain(int domid)
return dom;
out:
+ free(dom->serialpath);
free(dom->conspath);
free(dom);
return NULL;
@@ -397,6 +448,9 @@ static void cleanup_domain(struct domain *d)
free(d->buffer.data);
d->buffer.data = NULL;
+ free(d->serialpath);
+ d->serialpath = NULL;
+
free(d->conspath);
d->conspath = NULL;