# HG changeset patch
# User Christian Limpach <Christian.Limpach@xxxxxxxxxxxxx>
# Date 1178025421 -3600
# Node ID 650007cf390daca81f65311ef203288b6762d9be
# Parent 9ceacd71949b7847c654347d30069e8e86fe56e1
[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@xxxxxxxxxxxxx>
---
tools/console/daemon/io.c | 70 ++++++++++++++++++++++++++++++++++++++++------
1 files changed, 62 insertions(+), 8 deletions(-)
diff -r 9ceacd71949b -r 650007cf390d tools/console/daemon/io.c
--- a/tools/console/daemon/io.c Tue May 01 14:01:01 2007 +0100
+++ b/tools/console/daemon/io.c Tue May 01 14:17:01 2007 +0100
@@ -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 doma
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,13 +189,25 @@ static int domain_create_tty(struct doma
}
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));
free(path);
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 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 *
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
}
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
return dom;
out:
+ free(dom->serialpath);
free(dom->conspath);
free(dom);
return NULL;
@@ -396,6 +447,9 @@ static void cleanup_domain(struct domain
free(d->buffer.data);
d->buffer.data = NULL;
+
+ free(d->serialpath);
+ d->serialpath = NULL;
free(d->conspath);
d->conspath = NULL;
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|