WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xenconsole: Fix pty handling

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xenconsole: Fix pty handling
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 23 Feb 2009 06:40:14 -0800
Delivery-date: Mon, 23 Feb 2009 06:40:22 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1235149356 0
# Node ID f8187a343ad2bdbfe3166d7ee7e3d55a9f157fdc
# Parent  b749d0aba17f71ab58a51bdfc62d0fb71f70fa27
xenconsole: Fix pty handling

I printed the terminal attributes after openpty() and they were
garbage on the first console, valid on the second etc.
openpty() gets garbage in (uninitialized attributes MODIFIED by
cfmakeraw()). It sets the slave to the attributes requested. Using
uninitialized data for cfmakeraw->openpty results in pty attributes
that may even have the receiver disabled. Closing the slave just hides
the bug as these attributes disappear and hope the slave will be
reopened and initialized.

From: Juergen Hannken-Illjes <hannken@xxxxxxxxxx>
Signed-off-by: Christoph Egger <Christoph.Egger@xxxxxxx>
---
 tools/console/daemon/io.c |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

diff -r b749d0aba17f -r f8187a343ad2 tools/console/daemon/io.c
--- a/tools/console/daemon/io.c Fri Feb 20 11:13:11 2009 +0000
+++ b/tools/console/daemon/io.c Fri Feb 20 17:02:36 2009 +0000
@@ -402,9 +402,7 @@ static int domain_create_tty(struct doma
        assert(dom->slave_fd == -1);
        assert(dom->master_fd == -1);
 
-       cfmakeraw(&term);
-
-       if (openpty(&dom->master_fd, &dom->slave_fd, NULL, &term, NULL) < 0) {
+       if (openpty(&dom->master_fd, &dom->slave_fd, NULL, NULL, NULL) < 0) {
                err = errno;
                dolog(LOG_ERR, "Failed to create tty for domain-%d "
                      "(errno = %i, %s)",
@@ -412,20 +410,28 @@ static int domain_create_tty(struct doma
                return 0;
        }
 
+       if (tcgetattr(dom->slave_fd, &term) < 0) {
+               err = errno;
+               dolog(LOG_ERR, "Failed to get tty attributes for domain-%d "
+                       "(errno = %i, %s)",
+                       dom->domid, err, strerror(err));
+               goto out;
+       }
+       cfmakeraw(&term);
+       if (tcsetattr(dom->slave_fd, TCSANOW, &term) < 0) {
+               err = errno;
+               dolog(LOG_ERR, "Failed to set tty attributes for domain-%d "
+                       "(errno = %i, %s)",
+                       dom->domid, err, strerror(err));
+               goto out;
+       }
+
        if ((slave = ptsname(dom->master_fd)) == NULL) {
                err = errno;
                dolog(LOG_ERR, "Failed to get slave name for domain-%d "
                      "(errno = %i, %s)",
                      dom->domid, err, strerror(err));
                goto out;
-       }
-
-       /* Close the slave fd or the guest console output disappears,
-        * otherwise.
-        */
-       if (dom->slave_fd != -1) {
-               close(dom->slave_fd);
-               dom->slave_fd = -1;
        }
 
        if (dom->use_consolepath) {

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xenconsole: Fix pty handling, Xen patchbot-unstable <=