From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
"open list:Block layer core" <qemu-block@nongnu.org>,
Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PULL 2/9] iotests.py: Add qemu_nbd_early_pipe()
Date: Thu, 13 Jun 2019 10:48:30 -0500 [thread overview]
Message-ID: <20190613154837.21734-3-eblake@redhat.com> (raw)
In-Reply-To: <20190613154837.21734-1-eblake@redhat.com>
From: Max Reitz <mreitz@redhat.com>
qemu_nbd_pipe() currently unconditionally reads qemu-nbd's output. That
is not ideal because qemu-nbd may keep stderr open after the parent
process has exited.
Currently, the only user of qemu_nbd_pipe() is 147, which discards the
whole output if the parent process returned success and only evaluates
it on error. Therefore, we can replace qemu_nbd_pipe() by
qemu_nbd_early_pipe() that does the same: Discard the output on success,
and return it on error.
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190508211820.17851-3-mreitz@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
---
tests/qemu-iotests/147 | 4 ++--
tests/qemu-iotests/iotests.py | 9 ++++++---
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/tests/qemu-iotests/147 b/tests/qemu-iotests/147
index 82513279b028..2d84fddb0107 100755
--- a/tests/qemu-iotests/147
+++ b/tests/qemu-iotests/147
@@ -24,7 +24,7 @@ import socket
import stat
import time
import iotests
-from iotests import cachemode, imgfmt, qemu_img, qemu_nbd, qemu_nbd_pipe
+from iotests import cachemode, imgfmt, qemu_img, qemu_nbd, qemu_nbd_early_pipe
NBD_PORT_START = 32768
NBD_PORT_END = NBD_PORT_START + 1024
@@ -93,7 +93,7 @@ class QemuNBD(NBDBlockdevAddBase):
pass
def _try_server_up(self, *args):
- status, msg = qemu_nbd_pipe('-f', imgfmt, test_img, *args)
+ status, msg = qemu_nbd_early_pipe('-f', imgfmt, test_img, *args)
if status == 0:
return True
if 'Address already in use' in msg:
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 6bcddd887048..f11482f3dc9b 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -209,9 +209,9 @@ def qemu_nbd(*args):
'''Run qemu-nbd in daemon mode and return the parent's exit code'''
return subprocess.call(qemu_nbd_args + ['--fork'] + list(args))
-def qemu_nbd_pipe(*args):
+def qemu_nbd_early_pipe(*args):
'''Run qemu-nbd in daemon mode and return both the parent's exit code
- and its output'''
+ and its output in case of an error'''
subp = subprocess.Popen(qemu_nbd_args + ['--fork'] + list(args),
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
@@ -221,7 +221,10 @@ def qemu_nbd_pipe(*args):
sys.stderr.write('qemu-nbd received signal %i: %s\n' %
(-exitcode,
' '.join(qemu_nbd_args + ['--fork'] + list(args))))
- return exitcode, subp.communicate()[0]
+ if exitcode == 0:
+ return exitcode, ''
+ else:
+ return exitcode, subp.communicate()[0]
def compare_images(img1, img2, fmt1=imgfmt, fmt2=imgfmt):
'''Return True if two image files are identical'''
--
2.20.1
next prev parent reply other threads:[~2019-06-13 17:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-13 15:48 [Qemu-devel] [PULL 0/9] NBD patches through 2019-06-13 Eric Blake
2019-06-13 15:48 ` [Qemu-devel] [PULL 1/9] qemu-nbd: Add --pid-file option Eric Blake
2019-06-13 15:48 ` Eric Blake [this message]
2019-06-13 15:48 ` [Qemu-devel] [PULL 3/9] qemu-nbd: Do not close stderr Eric Blake
2019-06-13 15:48 ` [Qemu-devel] [PULL 4/9] iotests: Use qemu-nbd's --pid-file Eric Blake
2019-06-13 15:48 ` [Qemu-devel] [PULL 5/9] iotests: Let 233 run concurrently Eric Blake
2019-06-13 15:48 ` [Qemu-devel] [PULL 6/9] nbd/server: Nicer spelling of max BLOCK_STATUS reply length Eric Blake
2019-06-13 15:48 ` [Qemu-devel] [PULL 7/9] block/nbd-client: drop stale logout Eric Blake
2019-06-13 15:48 ` [Qemu-devel] [PULL 8/9] block/nbd: merge nbd-client.* to nbd.c Eric Blake
2019-06-13 15:48 ` [Qemu-devel] [PULL 9/9] block/nbd: merge NBDClientSession struct back to BDRVNBDState Eric Blake
2019-06-13 17:56 ` [Qemu-devel] [PULL 0/9] NBD patches through 2019-06-13 Peter Maydell
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=20190613154837.21734-3-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).