From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, jcody@redhat.com, jsnow@redhat.com,
stefanha@redhat.com, qemu-block@nongnu.org,
Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PATCH v3 3/6] iotests: Restore stty settings on completion
Date: Thu, 5 Oct 2017 14:02:45 -0500 [thread overview]
Message-ID: <20171005190248.5537-4-eblake@redhat.com> (raw)
In-Reply-To: <20171005190248.5537-1-eblake@redhat.com>
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 ... </dev/null'), but that's extra typing to have to
remember. But running 'exec </dev/null' in the harness seems like
it might be too heavy of a hammer. So I instead went the the
solution of saving and restoring the stty settings, only when the
harness detects that it is run interactively.
I tested this patch by forcing an allocation failure (I can't
guarantee that this particular limit will work on all setups, but
it shows the idea):
$ (ulimit -S -v 500000; ./check -qcow2 1)
Signed-off-by: Eric Blake <eblake@redhat.com>
---
v3: new patch
---
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.*
--
2.13.6
next prev parent reply other threads:[~2017-10-05 19:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-05 19:02 [Qemu-devel] [PATCH v3 0/6] block: Avoid copy-on-read assertions Eric Blake
2017-10-05 19:02 ` [Qemu-devel] [PATCH v3 1/6] qemu-io: Add -C for opening with copy-on-read Eric Blake
2017-10-05 19:02 ` [Qemu-devel] [PATCH v3 2/6] block: Uniform handling of 0-length bdrv_get_block_status() Eric Blake
2017-10-05 19:02 ` Eric Blake [this message]
2017-10-05 19:02 ` [Qemu-devel] [PATCH v3 4/6] block: Add blkdebug hook for copy-on-read Eric Blake
2017-10-05 19:02 ` [Qemu-devel] [PATCH v3 5/6] block: Perform copy-on-read in loop Eric Blake
2017-10-05 19:02 ` [Qemu-devel] [PATCH v3 6/6] iotests: Add test 197 for covering copy-on-read Eric Blake
2017-10-06 12:17 ` [Qemu-devel] [PATCH v3 0/6] block: Avoid copy-on-read assertions Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171005190248.5537-4-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=jcody@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).