[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Do not create the console tty until domain_create_ring has succeeded. This



# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID e6591119fda0e488ece39e007f725ed011709996
# Parent  1c62a4149b11fd3af95eaf97bc35fc26292698ae
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@xxxxxxxxxxxxx>

diff -r 1c62a4149b11 -r e6591119fda0 tools/console/daemon/io.c
--- a/tools/console/daemon/io.c Mon Oct 24 07:04:38 2005
+++ b/tools/console/daemon/io.c Mon Oct 24 13:11:07 2005
@@ -163,6 +163,16 @@
                        tcsetattr(master, TCSAFLUSH, &term);
                }
 
+               success = asprintf(&path, "%s/limit", dom->conspath) != -1;
+               if (!success)
+                       goto out;
+               data = xs_read(xs, NULL, path, &len);
+               if (data) {
+                       dom->buffer.max_capacity = strtoul(data, 0, 0);
+                       free(data);
+               }
+               free(path);
+
                success = asprintf(&path, "%s/tty", dom->conspath) != -1;
                if (!success)
                        goto out;
@@ -170,16 +180,6 @@
                free(path);
                if (!success)
                        goto out;
-
-               success = asprintf(&path, "%s/limit", dom->conspath) != -1;
-               if (!success)
-                       goto out;
-               data = xs_read(xs, NULL, path, &len);
-               if (data) {
-                       dom->buffer.max_capacity = strtoul(data, 0, 0);
-                       free(data);
-               }
-               free(path);
        }
 
        return master;
@@ -269,6 +269,18 @@
        }
        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 @@
        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;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.