From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samuel Thibault Subject: [PATCH] Fix xenconsole's "Could not read tty from store" Date: Mon, 17 Dec 2007 11:22:54 +0000 Message-ID: <20071217112254.GA5240@implementation.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Hello, I was getting intermittent "Could not read tty from store" when creating domains. This is because tools/console/daemon/io.c:domain_create_tty() seems to expect openpty() to initiaze term, but it's the converse: openpty expects to be given term parameters and doesn't touch it, so that term mostly contains random data when given to tcsetattr, and thus console creation failure. Here is a patch that fixes this. Samuel Use tcgetattr to fetch the initial terminal parameters in the console daemon. Signed-off-by: Samuel Thibault diff -r c005937f67d5 tools/console/daemon/io.c --- a/tools/console/daemon/io.c Mon Dec 17 10:55:33 2007 +0000 +++ b/tools/console/daemon/io.c Mon Dec 17 11:17:39 2007 +0000 @@ -282,7 +282,7 @@ static int domain_create_tty(struct doma char *data; unsigned int len; - if (openpty(&master, &slavefd, slave, &term, NULL) < 0) { + if (openpty(&master, &slavefd, slave, NULL, NULL) < 0) { master = -1; err = errno; dolog(LOG_ERR, "Failed to create tty for domain-%d (errno = %i, %s)", @@ -290,10 +290,16 @@ static int domain_create_tty(struct doma return master; } + if (tcgetattr(master, &term) < 0) { + err = errno; + dolog(LOG_ERR, "Failed to get tty attribute for domain-%d (errno = %i, %s)", + dom->domid, err, strerror(err)); + goto out; + } cfmakeraw(&term); if (tcsetattr(master, TCSAFLUSH, &term) < 0) { err = errno; - dolog(LOG_ERR, "Failed to set tty attribute for domain-%d (errno = %i, %s)", + dolog(LOG_ERR, "Failed to set tty attribute for domain-%d (errno = %i, %s)", dom->domid, err, strerror(err)); goto out; }