diff options
author | emellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com> | 2005-10-24 14:11:07 +0100 |
---|---|---|
committer | emellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com> | 2005-10-24 14:11:07 +0100 |
commit | 493b98bf232159bef0a0f8d5955c04562c2c4108 (patch) | |
tree | e8a363db0e434220b1a6f404685989b5bbae6b7c /tools/console | |
parent | 7ce0fde009344d9b18f47d722f998e0d6a110271 (diff) | |
download | xen-493b98bf232159bef0a0f8d5955c04562c2c4108.tar.gz xen-493b98bf232159bef0a0f8d5955c04562c2c4108.tar.bz2 xen-493b98bf232159bef0a0f8d5955c04562c2c4108.zip |
Do not create the console tty until domain_create_ring has succeeded. This
means that any reads attempted on that tty will not cause handle_tty_read to
segfault looking for an interface that does not exist.
Move the writing of the tty node so that it happens after console/limit has
been read, as it is cleaner if the writing is the last thing that happens.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
Diffstat (limited to 'tools/console')
-rw-r--r-- | tools/console/daemon/io.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 60e89267fc..0b55607d50 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -163,14 +163,6 @@ static int domain_create_tty(struct domain *dom) tcsetattr(master, TCSAFLUSH, &term); } - success = asprintf(&path, "%s/tty", dom->conspath) != -1; - if (!success) - goto out; - success = xs_write(xs, NULL, path, slave, strlen(slave)); - free(path); - if (!success) - goto out; - success = asprintf(&path, "%s/limit", dom->conspath) != -1; if (!success) goto out; @@ -180,6 +172,14 @@ static int domain_create_tty(struct domain *dom) free(data); } free(path); + + success = asprintf(&path, "%s/tty", dom->conspath) != -1; + if (!success) + goto out; + success = xs_write(xs, NULL, path, slave, strlen(slave)); + free(path); + if (!success) + goto out; } return master; @@ -269,6 +269,18 @@ static int domain_create_ring(struct domain *dom) } dom->local_port = rc; + if (dom->tty_fd == -1) { + dom->tty_fd = domain_create_tty(dom); + + if (dom->tty_fd == -1) { + err = errno; + close(dom->evtchn_fd); + dom->evtchn_fd = -1; + dom->local_port = -1; + goto out; + } + } + out: return err; } @@ -309,7 +321,7 @@ static struct domain *create_domain(int domid) dom->conspath = s; strcat(dom->conspath, "/console"); - dom->tty_fd = domain_create_tty(dom); + dom->tty_fd = -1; dom->is_dead = false; dom->buffer.data = 0; dom->buffer.size = 0; |