aboutsummaryrefslogtreecommitdiffstats
path: root/tools/console/daemon
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2009-02-20 17:02:36 +0000
committerKeir Fraser <keir.fraser@citrix.com>2009-02-20 17:02:36 +0000
commit8bb2359cd71870efc23a5980708c47484fa1da53 (patch)
tree715ac0b7894115b12edd5a484b6e93914f8bd7e1 /tools/console/daemon
parentfecfa97c11ce8c0f01ef5d37c5079c7eb2e15c78 (diff)
downloadxen-8bb2359cd71870efc23a5980708c47484fa1da53.tar.gz
xen-8bb2359cd71870efc23a5980708c47484fa1da53.tar.bz2
xen-8bb2359cd71870efc23a5980708c47484fa1da53.zip
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@netbsd.org> Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Diffstat (limited to 'tools/console/daemon')
-rw-r--r--tools/console/daemon/io.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 19e23f2372..de712affe3 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -402,9 +402,7 @@ static int domain_create_tty(struct domain *dom)
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,6 +410,22 @@ static int domain_create_tty(struct domain *dom)
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 "
@@ -420,14 +434,6 @@ static int domain_create_tty(struct domain *dom)
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) {
success = asprintf(&path, "%s/limit", dom->conspath) !=
-1;