From patchwork Fri Dec 14 09:55:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lei Li X-Patchwork-Id: 206382 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2D9952C0089 for ; Fri, 14 Dec 2012 20:58:03 +1100 (EST) Received: from localhost ([::1]:60706 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjS1p-0002VM-9O for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2012 04:58:01 -0500 Received: from eggs.gnu.org ([208.118.235.92]:57152) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjS0u-0001Wi-S7 for qemu-devel@nongnu.org; Fri, 14 Dec 2012 04:57:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TjS0t-0007mw-9A for qemu-devel@nongnu.org; Fri, 14 Dec 2012 04:57:04 -0500 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:50652) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjS0s-0007ms-JM for qemu-devel@nongnu.org; Fri, 14 Dec 2012 04:57:03 -0500 Received: from /spool/local by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 14 Dec 2012 19:52:02 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp09.au.ibm.com (202.81.31.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 14 Dec 2012 19:52:00 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 4B9D02BB004A for ; Fri, 14 Dec 2012 20:56:54 +1100 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id qBE9jsBP46465128 for ; Fri, 14 Dec 2012 20:45:55 +1100 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id qBE9uqrf030894 for ; Fri, 14 Dec 2012 20:56:53 +1100 Received: from localhost.cn.ibm.com ([9.115.122.89]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id qBE9up8L030875; Fri, 14 Dec 2012 20:56:52 +1100 From: Lei Li To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2012 17:55:34 +0800 Message-Id: <1355478934-18725-1-git-send-email-lilei@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.7.6 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12121409-3568-0000-0000-000002E86380 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 202.81.31.142 Cc: aliguori@us.ibm.com, Lei Li Subject: [Qemu-devel] [PATCH] qemu-char: inheriting ptys and imporve output from -serial pty X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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;