[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 11/13] iotests.py: Add qemu_nbd_pipe()
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PULL 11/13] iotests.py: Add qemu_nbd_pipe() |
Date: |
Thu, 31 Jan 2019 01:59:43 +0100 |
In some cases, we may want to deal with qemu-nbd errors (e.g. by
launching it in a different configuration until it no longer throws
any). In that case, we do not want its output ending up in the test
output.
It may still be useful for handling the error, though, so add a new
function that works basically like qemu_nbd(), only that it returns the
qemu-nbd output instead of making it end up in the log. In contrast to
qemu_img_pipe(), it does still return the exit code as well, though,
because that is even more important for error handling.
Signed-off-by: Max Reitz <address@hidden>
Message-id: address@hidden
Reviewed-by: John Snow <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
---
tests/qemu-iotests/iotests.py | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index cbedfaf1df..009c614ef7 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -201,6 +201,20 @@ 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):
+ '''Run qemu-nbd in daemon mode and return both the parent's exit code
+ and its output'''
+ subp = subprocess.Popen(qemu_nbd_args + ['--fork'] + list(args),
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ universal_newlines=True)
+ exitcode = subp.wait()
+ if exitcode < 0:
+ sys.stderr.write('qemu-nbd received signal %i: %s\n' %
+ (-exitcode,
+ ' '.join(qemu_nbd_args + ['--fork'] + list(args))))
+ return exitcode, subp.communicate()[0]
+
def compare_images(img1, img2, fmt1=imgfmt, fmt2=imgfmt):
'''Return True if two image files are identical'''
return qemu_img('compare', '-f', fmt1,
--
2.20.1
- [Qemu-devel] [PULL 01/13] qapi: add x-debug-query-block-graph, (continued)
- [Qemu-devel] [PULL 01/13] qapi: add x-debug-query-block-graph, Max Reitz, 2019/01/30
- [Qemu-devel] [PULL 02/13] scripts: add render_block_graph function for QEMUMachine, Max Reitz, 2019/01/30
- [Qemu-devel] [PULL 03/13] block/ssh: Convert from DPRINTF() macro to trace events, Max Reitz, 2019/01/30
- [Qemu-devel] [PULL 04/13] block/curl: Convert from DPRINTF() macro to trace events, Max Reitz, 2019/01/30
- [Qemu-devel] [PULL 05/13] block/file-posix: Convert from DPRINTF() macro to trace events, Max Reitz, 2019/01/30
- [Qemu-devel] [PULL 07/13] qemu-io: Add generic function for reinitializing optind., Max Reitz, 2019/01/30
- [Qemu-devel] [PULL 06/13] block/sheepdog: Convert from DPRINTF() macro to trace events, Max Reitz, 2019/01/30
- [Qemu-devel] [PULL 08/13] nvme: use TYPE_NVME instead of constant string, Max Reitz, 2019/01/30
- [Qemu-devel] [PULL 09/13] nvme: ensure the num_queues is not zero, Max Reitz, 2019/01/30
- [Qemu-devel] [PULL 10/13] nvme: use pci_dev directly in nvme_realize, Max Reitz, 2019/01/30
- [Qemu-devel] [PULL 11/13] iotests.py: Add qemu_nbd_pipe(),
Max Reitz <=
- [Qemu-devel] [PULL 13/13] iotests: Allow 147 to be run concurrently, Max Reitz, 2019/01/30
- [Qemu-devel] [PULL 12/13] iotests: Bind qemu-nbd to localhost in 147, Max Reitz, 2019/01/30