From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TlhRA-00067H-Dh for qemu-devel@nongnu.org; Thu, 20 Dec 2012 09:49:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TlhR4-0002yZ-As for qemu-devel@nongnu.org; Thu, 20 Dec 2012 09:49:28 -0500 Received: from e28smtp09.in.ibm.com ([122.248.162.9]:37738) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TlhR3-0002xs-Nj for qemu-devel@nongnu.org; Thu, 20 Dec 2012 09:49:22 -0500 Received: from /spool/local by e28smtp09.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 20 Dec 2012 20:18:49 +0530 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp03.in.ibm.com (Postfix) with ESMTP id 260AA125804D for ; Thu, 20 Dec 2012 20:19:11 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id qBKEnBmM37814516 for ; Thu, 20 Dec 2012 20:19:12 +0530 Received: from d28av02.in.ibm.com (loopback [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id qBKEnCH3014806 for ; Fri, 21 Dec 2012 01:49:13 +1100 From: Lei Li Date: Thu, 20 Dec 2012 22:49:08 +0800 Message-Id: <1356014948-13450-1-git-send-email-lilei@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH] qemu-char: inherit ptys and imporve output from -serial pty List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Lei Li When controlling a qemu instance from another program, it's hard to know which serial port or monitor device is redirected to which pty. With more than one device using "pty" a lot of guesswork is involved. $ ./x86_64-softmmu/qemu-system-x86_64 -serial pty -serial pty -monitor pty char device redirected to /dev/pts/5 char device redirected to /dev/pts/6 char device redirected to /dev/pts/7 Although we can find out what everything else is connected to by the "info chardev" with "-monitor stdio" in the command line, It'd be very useful to be able to have qemu inherit pseudo-tty file descriptors so they could just be specified on the command line like: $ ./x86_64-softmmu/qemu-system-x86_64 -serial pty -serial pty -monitor pty char device compat_monitor0 redirected to /dev/pts/5 char device serial0 redirected to /dev/pts/6 char device serial1 redirected to /dev/pts/7 Referred link: https://bugs.launchpad.net/qemu/+bug/938552 Reported-by: Craig Ringer Signed-off-by: Lei Li --- qemu-char.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 242b799..2b0f5f4 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -981,6 +981,7 @@ static CharDriverState *qemu_chr_open_pty(QemuOpts *opts) CharDriverState *chr; PtyCharDriver *s; struct termios tty; + char *label; int master_fd, slave_fd, len; #if defined(__OpenBSD__) || defined(__DragonFly__) char pty_name[PATH_MAX]; @@ -1006,7 +1007,8 @@ static CharDriverState *qemu_chr_open_pty(QemuOpts *opts) chr->filename = g_malloc(len); snprintf(chr->filename, len, "pty:%s", q_ptsname(master_fd)); qemu_opt_set(opts, "path", q_ptsname(master_fd)); - fprintf(stderr, "char device redirected to %s\n", q_ptsname(master_fd)); + label = g_strdup(qemu_opts_id(opts)); + fprintf(stderr, "char device %s redirected to %s\n", label, q_ptsname(master_fd)); s = g_malloc0(sizeof(PtyCharDriver)); chr->opaque = s; -- 1.7.7.6