From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMWyZ-0000Q4-2v for qemu-devel@nongnu.org; Wed, 27 Aug 2014 02:45:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMWyU-0003jG-9I for qemu-devel@nongnu.org; Wed, 27 Aug 2014 02:44:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22325) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMWyU-0003j9-27 for qemu-devel@nongnu.org; Wed, 27 Aug 2014 02:44:54 -0400 From: Markus Armbruster References: <1409115651-3612-1-git-send-email-john.liuli@huawei.com> Date: Wed, 27 Aug 2014 08:44:45 +0200 In-Reply-To: <1409115651-3612-1-git-send-email-john.liuli@huawei.com> (john liuli's message of "Wed, 27 Aug 2014 13:00:51 +0800") Message-ID: <87iolefn36.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH] qemu-char: fix terminal crash when using "-monitor stdio -nographic" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "john.liuli" Cc: qemu-devel@nongnu.org, aliguori@amazon.com "john.liuli" writes: > From: Li Liu > > Eeay to reproduce, just try "qemu -monitor stdio -nographic" > and type "quit", then the terminal will be crashed. > > There are two pathes try to call tcgetattr of stdio in vl.c: > > 1) Monitor_parse(optarg, "readline"); > ..... > qemu_opts_foreach(qemu_find_opts("chardev"), > chardev_init_func, NULL, 1) != 0) > > 2) if (default_serial) > add_device_config(DEV_SERIAL, "stdio"); > .... > if (foreach_device_config(DEV_SERIAL, serial_parse) < 0) > > Both of them will trigger qemu_chr_open_stdio which will disable > ECHO attributes. First one has updated the attributes of stdio > by calling qemu_chr_fe_set_echo(chr, false). And the tty > attributes has been saved in oldtty. Then the second path will > redo such actions, and the oldtty is overlapped. So till "quit", > term_exit can't recove the correct attributes. > > Signed-off-by: Li Liu Yes, failure to restore tty settings is a bug. But is having multiple character devices use the same terminal valid? If no, can we catch and reject the attempt? [...]