From nobody Fri Dec 19 06:24:22 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548896952315183.84465241816213; Wed, 30 Jan 2019 17:09:12 -0800 (PST) Received: from localhost ([127.0.0.1]:46941 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gp0qj-0006HX-SK for importer@patchew.org; Wed, 30 Jan 2019 20:09:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gp0iq-0000Eo-AC for qemu-devel@nongnu.org; Wed, 30 Jan 2019 20:00:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gp0io-0000Kv-9K for qemu-devel@nongnu.org; Wed, 30 Jan 2019 20:00:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33220) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gp0iZ-0008OT-FC; Wed, 30 Jan 2019 20:00:37 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5D82F81DFE; Thu, 31 Jan 2019 01:00:27 +0000 (UTC) Received: from localhost (ovpn-204-20.brq.redhat.com [10.40.204.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 278F45D96F; Thu, 31 Jan 2019 01:00:24 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Thu, 31 Jan 2019 01:59:43 +0100 Message-Id: <20190131005945.20149-12-mreitz@redhat.com> In-Reply-To: <20190131005945.20149-1-mreitz@redhat.com> References: <20190131005945.20149-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 31 Jan 2019 01:00:27 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 11/13] iotests.py: Add qemu_nbd_pipe() 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: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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 Message-id: 20181221234750.23577-2-mreitz@redhat.com Reviewed-by: John Snow Reviewed-by: Eric Blake Signed-off-by: Max Reitz --- 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)) =20 +def qemu_nbd_pipe(*args): + '''Run qemu-nbd in daemon mode and return both the parent's exit code + and its output''' + subp =3D subprocess.Popen(qemu_nbd_args + ['--fork'] + list(args), + stdout=3Dsubprocess.PIPE, + stderr=3Dsubprocess.STDOUT, + universal_newlines=3DTrue) + exitcode =3D 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=3Dimgfmt, fmt2=3Dimgfmt): '''Return True if two image files are identical''' return qemu_img('compare', '-f', fmt1, --=20 2.20.1