From patchwork Fri Oct 6 15:54:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 9989963 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CA2BE60247 for ; Fri, 6 Oct 2017 16:17:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7A7228E0C for ; Fri, 6 Oct 2017 16:17:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC91928E0F; Fri, 6 Oct 2017 16:17:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7AEA328E0C for ; Fri, 6 Oct 2017 16:17:33 +0000 (UTC) Received: from localhost ([::1]:45709 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0VJc-0002H4-AU for patchwork-qemu-devel@patchwork.kernel.org; Fri, 06 Oct 2017 12:17:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0UyQ-00019f-52 for qemu-devel@nongnu.org; Fri, 06 Oct 2017 11:55:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e0UyM-0003zY-Mq for qemu-devel@nongnu.org; Fri, 06 Oct 2017 11:55:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36808) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e0UyH-0003o2-4M; Fri, 06 Oct 2017 11:55:29 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 223842578F; Fri, 6 Oct 2017 15:55:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 223842578F Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kwolf@redhat.com Received: from localhost.localdomain.com (unknown [10.36.118.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3338067585; Fri, 6 Oct 2017 15:55:27 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 6 Oct 2017 17:54:08 +0200 Message-Id: <20171006155422.10135-41-kwolf@redhat.com> In-Reply-To: <20171006155422.10135-1-kwolf@redhat.com> References: <20171006155422.10135-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 06 Oct 2017 15:55:28 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 40/54] iotests: Restore stty settings on completion X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Blake Executing qemu with a terminal as stdin will temporarily alter stty settings on that terminal (for example, disabling echo), because of how we run both the monitor and any multiplexing with guest input. Normally, qemu restores the original settings on exit; but if an iotest triggers qemu to abort in the middle, we can be left with the altered terminal setup. This can make life very annoying when debugging an iotest failure (not everyone remembers the trick of blind-typing 'stty sane' without echo, and some people prefer terminal settings that are slightly different than the defaults picked by 'stty sane'). It is possible to avoid qemu corrupting the terminal by not passing a terminal to qemu's stdin in the first place (as in, use './check ... Signed-off-by: Kevin Wolf --- tests/qemu-iotests/check | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check index 176cb8e937..e6b6ff7a04 100755 --- a/tests/qemu-iotests/check +++ b/tests/qemu-iotests/check @@ -134,6 +134,13 @@ export VALGRIND_QEMU= export IMGKEYSECRET= export IMGOPTSSYNTAX=false +# Save current tty settings, since an aborting qemu call may leave things +# screwed up +STTY_RESTORE= +if test -t 0; then + STTY_RESTORE=$(stty -g) +fi + for r do @@ -664,6 +671,9 @@ END { if (NR > 0) { needwrap=false fi + if test -n "$STTY_RESTORE"; then + stty $STTY_RESTORE + fi rm -f "${TEST_DIR}"/*.out "${TEST_DIR}"/*.err "${TEST_DIR}"/*.time rm -f "${TEST_DIR}"/check.pid "${TEST_DIR}"/check.sts rm -f $tmp.*