From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647950323615511.9421690663638; Tue, 22 Mar 2022 04:58:43 -0700 (PDT) Received: from localhost ([::1]:34278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWd9t-00055s-B8 for importer@patchew.org; Tue, 22 Mar 2022 07:58:41 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8E-00028I-HE for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:56:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:54553) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8B-0006NK-76 for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:56:57 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-389-fp3RIgu8ObWFooYG2ZdsSw-1; Tue, 22 Mar 2022 07:56:51 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EC2DF3801EC1; Tue, 22 Mar 2022 11:56:50 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A81711121314; Tue, 22 Mar 2022 11:56:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950214; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PE6GhPnAGVHeIj8sAefGZPCuwq6GIsbrGB14+206zZc=; b=T5TAT4OojCWISNn8/MnJEBXV4IpcOWlaTJ5lPEm+wcwsyC1uW5t5Lcc2o9KSQ3NGRqnn8U Yyc9yxf220wjK18ptoSK8fq9wumwm1cxkdFt2xoik0oPDqhpeg3rDbILKaSMj50vaDg9sg G4cXpYyxRZ4wBwOhL6aYEZHj+GSq2TA= X-MC-Unique: fp3RIgu8ObWFooYG2ZdsSw-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 01/25] tests: add (riscv virt) machine mapping to testenv Date: Tue, 22 Mar 2022 12:56:23 +0100 Message-Id: <20220322115647.726044-2-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647950326017100001 Content-Type: text/plain; charset="utf-8" From: laokz Some qemu-iotests(040 etc) use PCI disk to do test. Without the mapping, RISC-V flavor use spike as default machine which has no PCI bus, causing test failure. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/894 Signed-off-by: Kai Zhang Message-Id: Reviewed-by: Alistair Francis Signed-off-by: Hanna Reitz --- tests/qemu-iotests/testenv.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py index b11e943c8a..a864c74b12 100644 --- a/tests/qemu-iotests/testenv.py +++ b/tests/qemu-iotests/testenv.py @@ -235,6 +235,8 @@ def __init__(self, imgfmt: str, imgproto: str, aiomode:= str, ('aarch64', 'virt'), ('avr', 'mega2560'), ('m68k', 'virt'), + ('riscv32', 'virt'), + ('riscv64', 'virt'), ('rx', 'gdbsim-r5f562n8'), ('tricore', 'tricore_testboard') ) --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647950323741227.16978987058405; Tue, 22 Mar 2022 04:58:43 -0700 (PDT) Received: from localhost ([::1]:34268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWd9u-00055Z-7J for importer@patchew.org; Tue, 22 Mar 2022 07:58:42 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8E-00028K-5U for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:56:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:39938) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8C-0006NY-F9 for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:56:57 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-499-lt1Mr7ypNP6EWtcCqEA_9Q-1; Tue, 22 Mar 2022 07:56:52 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8103629DD995; Tue, 22 Mar 2022 11:56:52 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3E4BA403D188; Tue, 22 Mar 2022 11:56:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950216; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T4TT4bbocb2VkrJZ5oa3Bxmdsdqc5CNeeucUIzGVai8=; b=UKihY1gHoqacHxq8a4yKY2UkyDqjCEQH1vAcIAeKwO+tMTSryn1K7tA4uEyRbEheIqmvX+ 868qRSXIKgweImJkEUHPStbpaLRRIXv0cTxDXXLRa4B/d4t/fnwpLkYtfd9HD7aogEpwll 4bGaDvYXAOOu7f3o6ldYdqA2Ikw1lY0= X-MC-Unique: lt1Mr7ypNP6EWtcCqEA_9Q-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 02/25] block/rbd: fix write zeroes with growing images Date: Tue, 22 Mar 2022 12:56:24 +0100 Message-Id: <20220322115647.726044-3-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647950326026100002 Content-Type: text/plain; charset="utf-8" From: Stefano Garzarella Commit d24f80234b ("block/rbd: increase dynamically the image size") added a workaround to support growing images (eg. qcow2), resizing the image before write operations that exceed the current size. We recently added support for write zeroes and without the workaround we can have problems with qcow2. So let's move the resize into qemu_rbd_start_co() and do it when the command is RBD_AIO_WRITE or RBD_AIO_WRITE_ZEROES. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=3D2020993 Fixes: c56ac27d2a ("block/rbd: add write zeroes support") Signed-off-by: Stefano Garzarella Message-Id: <20220317162638.41192-1-sgarzare@redhat.com> Signed-off-by: Hanna Reitz --- block/rbd.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index 8f183eba2a..6caf35cbba 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -1107,6 +1107,20 @@ static int coroutine_fn qemu_rbd_start_co(BlockDrive= rState *bs, =20 assert(!qiov || qiov->size =3D=3D bytes); =20 + if (cmd =3D=3D RBD_AIO_WRITE || cmd =3D=3D RBD_AIO_WRITE_ZEROES) { + /* + * RBD APIs don't allow us to write more than actual size, so in o= rder + * to support growing images, we resize the image before write + * operations that exceed the current size. + */ + if (offset + bytes > s->image_size) { + int r =3D qemu_rbd_resize(bs, offset + bytes); + if (r < 0) { + return r; + } + } + } + r =3D rbd_aio_create_completion(&task, (rbd_callback_t) qemu_rbd_completion_cb,= &c); if (r < 0) { @@ -1182,18 +1196,6 @@ coroutine_fn qemu_rbd_co_pwritev(BlockDriverState *b= s, int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags) { - BDRVRBDState *s =3D bs->opaque; - /* - * RBD APIs don't allow us to write more than actual size, so in order - * to support growing images, we resize the image before write - * operations that exceed the current size. - */ - if (offset + bytes > s->image_size) { - int r =3D qemu_rbd_resize(bs, offset + bytes); - if (r < 0) { - return r; - } - } return qemu_rbd_start_co(bs, offset, bytes, qiov, flags, RBD_AIO_WRITE= ); } =20 --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647950479361435.4772879310201; Tue, 22 Mar 2022 05:01:19 -0700 (PDT) Received: from localhost ([::1]:42822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWdCQ-0002LR-3S for importer@patchew.org; Tue, 22 Mar 2022 08:01:18 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8G-00029O-Cf for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:30371) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8E-0006O2-Uf for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:00 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-433-eUgd5reWNXKD1GiX-rSZxg-1; Tue, 22 Mar 2022 07:56:54 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 103343C16181; Tue, 22 Mar 2022 11:56:54 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C29431121314; Tue, 22 Mar 2022 11:56:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950217; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DehzDUUUL9UTJbER0x1YYX5E/OAx+EakAaCUQuOxVg8=; b=Yx1jEWdFDAZnxbMB06RgpKsvSRX0tLboaPhKC/ffr0XpUE2CV9/fZD+70tAyhxAX3ejbrD wsvkMEIhQ0ejaiIycET3eHGCwoxnZ0gVUUDgrpI+mvvBhhDQx4eFQWmYClTQXS+BUFYMVo mdthG43XOh+2vrk2JPrASTH8non5c8s= X-MC-Unique: eUgd5reWNXKD1GiX-rSZxg-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 03/25] tests/qemu-iotests: Use GNU sed in two more spots where it is necessary Date: Tue, 22 Mar 2022 12:56:25 +0100 Message-Id: <20220322115647.726044-4-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647950481711100001 From: Thomas Huth These two spots have been missed in commit 9086c7639822 ("Rework the checks and spots using GNU sed") - they need GNU sed, too, since they are using the "+" address form. Signed-off-by: Thomas Huth Message-Id: <20220309101626.637836-1-thuth@redhat.com> Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Hanna Reitz --- tests/qemu-iotests/common.filter | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.f= ilter index 9790411bf0..cc9f1a5891 100644 --- a/tests/qemu-iotests/common.filter +++ b/tests/qemu-iotests/common.filter @@ -106,13 +106,13 @@ _filter_hmp() # replace block job offset _filter_block_job_offset() { - sed -e 's/, "offset": [0-9]\+,/, "offset": OFFSET,/' + gsed -e 's/, "offset": [0-9]\+,/, "offset": OFFSET,/' } =20 # replace block job len _filter_block_job_len() { - sed -e 's/, "len": [0-9]\+,/, "len": LEN,/g' + gsed -e 's/, "len": [0-9]\+,/, "len": LEN,/g' } =20 # replace actual image size (depends on the host filesystem) --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647950710255843.4114773353784; Tue, 22 Mar 2022 05:05:10 -0700 (PDT) Received: from localhost ([::1]:52914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWdG8-0000hL-R5 for importer@patchew.org; Tue, 22 Mar 2022 08:05:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8H-00029X-Ta for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:37110) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8F-0006OX-Lw for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:01 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-325-_L69XSR9MF2sl7c-P6_Pag-1; Tue, 22 Mar 2022 07:56:56 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 980A13C16182; Tue, 22 Mar 2022 11:56:55 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 552D4400E881; Tue, 22 Mar 2022 11:56:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950219; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jLErHhAIi5XpZjFmOH1NiP4uXeC/QEa+uKzYplPrjd8=; b=TuqZ2yeZ64NvQHSB7l/rCvLj72KMNdPQ8Arps3fnZZ5Fgja7ZrGiPnEFp888KGDSyGXIeh 3zRPJV7QJZ74H1YIkskaw6zZZWKcNELivUSIVz9T3VDMGs9onYNaAflEpBLgoOQLqhpMJR ri0OH9/N50t4ImH3NYgvScasXMnuWAA= X-MC-Unique: _L69XSR9MF2sl7c-P6_Pag-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 04/25] tests: Do not treat the iotests as separate meson test target anymore Date: Tue, 22 Mar 2022 12:56:26 +0100 Message-Id: <20220322115647.726044-5-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647950713662100001 Content-Type: text/plain; charset="utf-8" From: Thomas Huth If there is a failing iotest, the output is currently not logged to the console anymore. To get this working again, we need to run the meson test runner with "--print-errorlogs" (and without "--verbose" due to a current meson bug that will be fixed here: https://github.com/mesonbuild/meson/commit/c3f145ca2b9f5.patch ). We could update the "meson test" call in tests/Makefile.include, but actually it's nicer and easier if we simply do not treat the iotests as separate test target anymore and integrate them along with the other test suites. This has the disadvantage of not getting the detailed progress indication there anymore, but since that was only working right in single-threaded "make -j1" mode anyway, it's not a huge loss right now. Signed-off-by: Thomas Huth Message-Id: <20220310075048.2303495-1-thuth@redhat.com> Tested-by: Hanna Reitz Signed-off-by: Hanna Reitz --- meson.build | 6 +++--- scripts/mtest2make.py | 4 ---- tests/Makefile.include | 9 +-------- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/meson.build b/meson.build index 282e7c4650..f71e1a1468 100644 --- a/meson.build +++ b/meson.build @@ -3,9 +3,9 @@ project('qemu', ['c'], meson_version: '>=3D0.59.3', 'b_staticpic=3Dfalse', 'stdsplit=3Dfalse'], version: files('VERSION')) =20 -add_test_setup('quick', exclude_suites: ['block', 'slow', 'thorough'], is_= default: true) -add_test_setup('slow', exclude_suites: ['block', 'thorough'], env: ['G_TES= T_SLOW=3D1', 'SPEED=3Dslow']) -add_test_setup('thorough', exclude_suites: ['block'], env: ['G_TEST_SLOW= =3D1', 'SPEED=3Dthorough']) +add_test_setup('quick', exclude_suites: ['slow', 'thorough'], is_default: = true) +add_test_setup('slow', exclude_suites: ['thorough'], env: ['G_TEST_SLOW=3D= 1', 'SPEED=3Dslow']) +add_test_setup('thorough', env: ['G_TEST_SLOW=3D1', 'SPEED=3Dthorough']) =20 not_found =3D dependency('', required: false) keyval =3D import('keyval') diff --git a/scripts/mtest2make.py b/scripts/mtest2make.py index 4d542e8aaa..304634b71e 100644 --- a/scripts/mtest2make.py +++ b/scripts/mtest2make.py @@ -101,10 +101,6 @@ def emit_suite(name, suite, prefix): testsuites =3D defaultdict(Suite) for test in introspect['tests']: process_tests(test, targets, testsuites) -# HACK: check-block is a separate target so that it runs with --verbose; -# only write the dependencies -emit_suite_deps('block', testsuites['block'], 'check') -del testsuites['block'] emit_prolog(testsuites, 'check') for name, suite in testsuites.items(): emit_suite(name, suite, 'check') diff --git a/tests/Makefile.include b/tests/Makefile.include index e7153c8e91..b89018cdcc 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -147,16 +147,9 @@ check-acceptance: check-acceptance-deprecated-warning = | check-avocado =20 # Consolidated targets =20 -.PHONY: check-block check check-clean get-vm-images +.PHONY: check check-clean get-vm-images check: =20 -ifneq ($(.check-block.deps),) -check: check-block -check-block: run-ninja - $(if $(MAKE.n),,+)$(MESON) test $(MTESTARGS) $(.mtestargs) --verbose \ - --logbase iotestslog $(call .speed.$(SPEED), block block-slow block-thor= ough) -endif - check-build: run-ninja =20 check-clean: --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647950524620935.9276071008851; Tue, 22 Mar 2022 05:02:04 -0700 (PDT) Received: from localhost ([::1]:44340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWdD9-0003SA-It for importer@patchew.org; Tue, 22 Mar 2022 08:02:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59056) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8H-00029U-Lg for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27794) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8F-0006ON-E6 for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:01 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-134-i74OlsjaN6KTRn3LPwUOgA-1; Tue, 22 Mar 2022 07:56:57 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 28EDA801E67; Tue, 22 Mar 2022 11:56:57 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D7DA82026614; Tue, 22 Mar 2022 11:56:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950218; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6kH865/rvHzWNES7ZuQWz7/u5rPvys15LgfeL8Xc6gI=; b=jDJv6kjZVY2u+sE7bNpTQoUnOFB4y0icAxR/WNHozENk8bhzP0fv0CvOwose0R1Z73qwDD SVuCwAhKWH9ldQg71wY6Wuf1ekNhfaXEy1B/8fEF8OuCEk/aKIGo9DHlP5S4A9NwlHP8QV BHWR6u3VdsmnDp3XEblb9+hWY6m+3fU= X-MC-Unique: i74OlsjaN6KTRn3LPwUOgA-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 05/25] tests/qemu-iotests/testrunner: Supply a test plan in TAP mode Date: Tue, 22 Mar 2022 12:56:27 +0100 Message-Id: <20220322115647.726044-6-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647950526026100001 From: Thomas Huth Quoting the TAP specification: "The plan tells how many tests will be run [...]. It=E2=80=99s a check that the test file hasn=E2=80=99t stopped p= rematurely." That's a good idea of course, so let's support that in the iotest testrunner, too. Signed-off-by: Thomas Huth Message-Id: <20220223095816.2663005-1-thuth@redhat.com> Signed-off-by: Hanna Reitz --- tests/qemu-iotests/testrunner.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunn= er.py index 5c207225b1..aae70a8341 100644 --- a/tests/qemu-iotests/testrunner.py +++ b/tests/qemu-iotests/testrunner.py @@ -388,6 +388,7 @@ def run_tests(self, tests: List[str], jobs: int =3D 1) = -> bool: =20 if self.tap: self.env.print_env('# ') + print('1..%d' % len(tests)) else: self.env.print_env() =20 --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647950929652236.768240056359; Tue, 22 Mar 2022 05:08:49 -0700 (PDT) Received: from localhost ([::1]:33914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWdJi-00071M-52 for importer@patchew.org; Tue, 22 Mar 2022 08:08:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8L-0002Lj-Rd for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:34154) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8I-0006PN-Og for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:05 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-481-Afv1CTmWNuKUJZbJdtZ1DQ-1; Tue, 22 Mar 2022 07:56:59 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B8C983801EC0; Tue, 22 Mar 2022 11:56:58 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 749892166B2D; Tue, 22 Mar 2022 11:56:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950222; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q7mWX3ewa0GFrrGrYKJuTZRzmNYcVKgxkgBQO6sPKaU=; b=MoigazrnIjxOOEzJzyPm6TzFXzyzgiId+Qfx2ndE+6OG/CJFdpRZrwO9WuE0/YVTBWT698 IVelxGHJYeHxzehKzDv2bTjZXUtS16OEBm5vHYnZED3andtoA6XAzsNY7UgZZmmxd3OkBw 5x6NGX3qAwDtijaErSwptTYEoHW3nDE= X-MC-Unique: Afv1CTmWNuKUJZbJdtZ1DQ-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 06/25] python/utils: add add_visual_margin() text decoration utility Date: Tue, 22 Mar 2022 12:56:28 +0100 Message-Id: <20220322115647.726044-7-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647950931976100002 From: John Snow >>> print(add_visual_margin(msg, width=3D72, name=3D"Commit Message")) =E2=94=8F=E2=94=81 Commit Message =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2= =94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81= =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2= =94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81= =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81 =E2=94=83 add_visual_margin() takes a chunk of text and wraps it in a visual =E2=94=83 container that force-wraps to a specified width. An optional title =E2=94=83 label may be given, and any of the individual glyphs used to draw= the =E2=94=83 box may be replaced or specified as well. =E2=94=97=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2= =94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81= =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2= =94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81= =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2= =94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81 Signed-off-by: John Snow Reviewed-by: Eric Blake Acked-by: Hanna Reitz Message-Id: <20220321201618.903471-2-jsnow@redhat.com> Signed-off-by: Hanna Reitz --- python/qemu/utils/__init__.py | 78 +++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/python/qemu/utils/__init__.py b/python/qemu/utils/__init__.py index 7f1a5138c4..b84c86d004 100644 --- a/python/qemu/utils/__init__.py +++ b/python/qemu/utils/__init__.py @@ -15,7 +15,10 @@ # the COPYING file in the top-level directory. # =20 +import os import re +import shutil +import textwrap from typing import Optional =20 # pylint: disable=3Dimport-error @@ -23,6 +26,7 @@ =20 =20 __all__ =3D ( + 'add_visual_margin', 'get_info_usernet_hostfwd_port', 'kvm_available', 'list_accel', @@ -43,3 +47,77 @@ def get_info_usernet_hostfwd_port(info_usernet_output: s= tr) -> Optional[int]: if match is not None: return int(match[1]) return None + + +# pylint: disable=3Dtoo-many-arguments +def add_visual_margin( + content: str =3D '', + width: Optional[int] =3D None, + name: Optional[str] =3D None, + padding: int =3D 1, + upper_left: str =3D '=E2=94=8F', + lower_left: str =3D '=E2=94=97', + horizontal: str =3D '=E2=94=81', + vertical: str =3D '=E2=94=83', +) -> str: + """ + Decorate and wrap some text with a visual decoration around it. + + This function assumes that the text decoration characters are single + characters that display using a single monospace column. + + =E2=94=8F=E2=94=81 Example =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81= =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2= =94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81= =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2= =94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81 + =E2=94=83 This is what this function looks like with text content that= 's + =E2=94=83 wrapped to 66 characters. The right-hand margin is left open= to + =E2=94=83 accommodate the occasional unicode character that might make + =E2=94=83 predicting the total "visual" width of a line difficult. This + =E2=94=83 provides a visual distinction that's good-enough, though. + =E2=94=97=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81= =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2= =94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81= =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2= =94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81 + + :param content: The text to wrap and decorate. + :param width: + The number of columns to use, including for the decoration + itself. The default (None) uses the the available width of the + current terminal, or a fallback of 72 lines. A negative number + subtracts a fixed-width from the default size. The default obeys + the COLUMNS environment variable, if set. + :param name: A label to apply to the upper-left of the box. + :param padding: How many columns of padding to apply inside. + :param upper_left: Upper-left single-width text decoration character. + :param lower_left: Lower-left single-width text decoration character. + :param horizontal: Horizontal single-width text decoration character. + :param vertical: Vertical single-width text decoration character. + """ + if width is None or width < 0: + avail =3D shutil.get_terminal_size(fallback=3D(72, 24))[0] + if width is None: + _width =3D avail + else: + _width =3D avail + width + else: + _width =3D width + + prefix =3D vertical + (' ' * padding) + + def _bar(name: Optional[str], top: bool =3D True) -> str: + ret =3D upper_left if top else lower_left + if name is not None: + ret +=3D f"{horizontal} {name} " + + filler_len =3D _width - len(ret) + ret +=3D f"{horizontal * filler_len}" + return ret + + def _wrap(line: str) -> str: + return os.linesep.join( + textwrap.wrap( + line, width=3D_width - padding, initial_indent=3Dprefix, + subsequent_indent=3Dprefix, replace_whitespace=3DFalse, + drop_whitespace=3DTrue, break_on_hyphens=3DFalse) + ) + + return os.linesep.join(( + _bar(name, top=3DTrue), + os.linesep.join(_wrap(line) for line in content.splitlines()), + _bar(None, top=3DFalse), + )) --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16479505260085.688036101728585; Tue, 22 Mar 2022 05:02:06 -0700 (PDT) Received: from localhost ([::1]:44388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWdDA-0003UJ-CE for importer@patchew.org; Tue, 22 Mar 2022 08:02:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8L-0002L8-Iv for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55353) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8J-0006Pd-6X for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:05 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-400-_ADpLGY6PFKjTe5Zkde7yw-1; Tue, 22 Mar 2022 07:57:00 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 75811802E5B; Tue, 22 Mar 2022 11:57:00 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 302A42024CB6; Tue, 22 Mar 2022 11:57:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950222; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yW+kN9HZV+ZAc9TUWVMRFN2Q1VjClQJEtA5UxYRl7H0=; b=F9TMSFAKpswqwl0YQyPRKy9Txsm/v3G7k9/VZMBN0CckrFIZXil6/bQVtqO2nb/4heoK+k CePz6U0cn0VrRqQ5Ri9DUIEm4wAPbj7d3tKkOLLh+brZ0cArFBK2jcTvCJ2G1ZhH5rrIs0 M1Y7MrcKVQFfhS2LvBCHVYGKOI8RD1M= X-MC-Unique: _ADpLGY6PFKjTe5Zkde7yw-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 07/25] python/utils: add VerboseProcessError Date: Tue, 22 Mar 2022 12:56:29 +0100 Message-Id: <20220322115647.726044-8-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647950528129100001 Content-Type: text/plain; charset="utf-8" From: John Snow This adds an Exception that extends the Python stdlib subprocess.CalledProcessError. The difference is that the str() method of this exception also adds the stdout/stderr logs. In effect, if this exception goes unhandled, Python will print the output in a visually distinct wrapper to the terminal so that it's easy to spot in a sea of traceback information. Signed-off-by: John Snow Reviewed-by: Eric Blake Reviewed-by: Hanna Reitz Message-Id: <20220321201618.903471-3-jsnow@redhat.com> Signed-off-by: Hanna Reitz --- python/qemu/utils/__init__.py | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/python/qemu/utils/__init__.py b/python/qemu/utils/__init__.py index b84c86d004..9fb273b13d 100644 --- a/python/qemu/utils/__init__.py +++ b/python/qemu/utils/__init__.py @@ -18,6 +18,7 @@ import os import re import shutil +from subprocess import CalledProcessError import textwrap from typing import Optional =20 @@ -26,6 +27,7 @@ =20 =20 __all__ =3D ( + 'VerboseProcessError', 'add_visual_margin', 'get_info_usernet_hostfwd_port', 'kvm_available', @@ -121,3 +123,40 @@ def _wrap(line: str) -> str: os.linesep.join(_wrap(line) for line in content.splitlines()), _bar(None, top=3DFalse), )) + + +class VerboseProcessError(CalledProcessError): + """ + The same as CalledProcessError, but more verbose. + + This is useful for debugging failed calls during test executions. + The return code, signal (if any), and terminal output will be displayed + on unhandled exceptions. + """ + def summary(self) -> str: + """Return the normal CalledProcessError str() output.""" + return super().__str__() + + def __str__(self) -> str: + lmargin =3D ' ' + width =3D -len(lmargin) + sections =3D [] + + # Does self.stdout contain both stdout and stderr? + has_combined_output =3D self.stderr is None + + name =3D 'output' if has_combined_output else 'stdout' + if self.stdout: + sections.append(add_visual_margin(self.stdout, width, name)) + else: + sections.append(f"{name}: N/A") + + if self.stderr: + sections.append(add_visual_margin(self.stderr, width, 'stderr'= )) + elif not has_combined_output: + sections.append("stderr: N/A") + + return os.linesep.join(( + self.summary(), + textwrap.indent(os.linesep.join(sections), prefix=3Dlmargin), + )) --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647950332106798.9943891507288; Tue, 22 Mar 2022 04:58:52 -0700 (PDT) Received: from localhost ([::1]:35058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWdA2-0005bZ-Ut for importer@patchew.org; Tue, 22 Mar 2022 07:58:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8M-0002PZ-T6 for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36435) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8K-0006Pm-Bt for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:06 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-466-Vt9TjdlpP4e-GFAQEAHjkg-1; Tue, 22 Mar 2022 07:57:02 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2FD66185A79C; Tue, 22 Mar 2022 11:57:02 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BD5B32166B46; Tue, 22 Mar 2022 11:57:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950223; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GAUcZpGxn3cALqQpreMOVHf913k5Ksj3zFOJW/B61/g=; b=a8g6zWYaBNsyLxxgIzv2Pq3ydrS/G/p7jdQ8NZ/NQbv4mXFRZRHKgIxOFdd0VZI02hdWHv skI2c1p5nIscft8rbsx0BzXtksHbeqGXmiFIjgKNxPBzO/qXzTO7JUq6jr0AAqQwJpSEVp 7QEz9XlpjIvVWis3Mx4RA1G1/wdzqyg= X-MC-Unique: Vt9TjdlpP4e-GFAQEAHjkg-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 08/25] iotests: Remove explicit checks for qemu_img() == 0 Date: Tue, 22 Mar 2022 12:56:30 +0100 Message-Id: <20220322115647.726044-9-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647950334162100003 Content-Type: text/plain; charset="utf-8" From: John Snow qemu_img() returning zero ought to be the rule, not the exception. Remove all explicit checks against the condition in preparation for making non-zero returns an Exception. Signed-off-by: John Snow Reviewed-by: Eric Blake Reviewed-by: Hanna Reitz Message-Id: <20220321201618.903471-4-jsnow@redhat.com> Signed-off-by: Hanna Reitz --- tests/qemu-iotests/163 | 9 +++------ tests/qemu-iotests/216 | 6 +++--- tests/qemu-iotests/218 | 2 +- tests/qemu-iotests/224 | 11 +++++------ tests/qemu-iotests/228 | 12 ++++++------ tests/qemu-iotests/257 | 3 +-- tests/qemu-iotests/258 | 4 ++-- tests/qemu-iotests/310 | 13 ++++++------- tests/qemu-iotests/tests/block-status-cache | 3 +-- tests/qemu-iotests/tests/graph-changes-while-io | 7 +++---- tests/qemu-iotests/tests/image-fleecing | 10 +++++----- tests/qemu-iotests/tests/mirror-ready-cancel-error | 6 ++---- tests/qemu-iotests/tests/mirror-top-perms | 3 +-- tests/qemu-iotests/tests/remove-bitmap-from-backing | 8 ++++---- tests/qemu-iotests/tests/stream-error-on-reset | 4 ++-- 15 files changed, 45 insertions(+), 56 deletions(-) diff --git a/tests/qemu-iotests/163 b/tests/qemu-iotests/163 index b8bfc95358..e4cd4b230f 100755 --- a/tests/qemu-iotests/163 +++ b/tests/qemu-iotests/163 @@ -107,8 +107,7 @@ class ShrinkBaseClass(iotests.QMPTestCase): =20 if iotests.imgfmt =3D=3D 'raw': return - self.assertEqual(qemu_img('check', test_img), 0, - "Verifying image corruption") + qemu_img('check', test_img) =20 def test_empty_image(self): qemu_img('resize', '-f', iotests.imgfmt, '--shrink', test_img, @@ -130,8 +129,7 @@ class ShrinkBaseClass(iotests.QMPTestCase): qemu_img('resize', '-f', iotests.imgfmt, '--shrink', test_img, self.shrink_size) =20 - self.assertEqual(qemu_img("compare", test_img, check_img), 0, - "Verifying image content") + qemu_img("compare", test_img, check_img) =20 self.image_verify() =20 @@ -146,8 +144,7 @@ class ShrinkBaseClass(iotests.QMPTestCase): qemu_img('resize', '-f', iotests.imgfmt, '--shrink', test_img, self.shrink_size) =20 - self.assertEqual(qemu_img("compare", test_img, check_img), 0, - "Verifying image content") + qemu_img("compare", test_img, check_img) =20 self.image_verify() =20 diff --git a/tests/qemu-iotests/216 b/tests/qemu-iotests/216 index c02f8d2880..88b385afa3 100755 --- a/tests/qemu-iotests/216 +++ b/tests/qemu-iotests/216 @@ -51,10 +51,10 @@ with iotests.FilePath('base.img') as base_img_path, \ log('--- Setting up images ---') log('') =20 - assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') = =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') assert qemu_io_silent(base_img_path, '-c', 'write -P 1 0M 1M') =3D=3D 0 - assert qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path, - '-F', iotests.imgfmt, top_img_path) =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path, + '-F', iotests.imgfmt, top_img_path) assert qemu_io_silent(top_img_path, '-c', 'write -P 2 1M 1M') =3D=3D 0 =20 log('Done') diff --git a/tests/qemu-iotests/218 b/tests/qemu-iotests/218 index 4922b4d3b6..853ed52b34 100755 --- a/tests/qemu-iotests/218 +++ b/tests/qemu-iotests/218 @@ -145,7 +145,7 @@ log('') with iotests.VM() as vm, \ iotests.FilePath('src.img') as src_img_path: =20 - assert qemu_img('create', '-f', iotests.imgfmt, src_img_path, '64M') = =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, src_img_path, '64M') assert qemu_io_silent('-f', iotests.imgfmt, src_img_path, '-c', 'write -P 42 0M 64M') =3D=3D 0 =20 diff --git a/tests/qemu-iotests/224 b/tests/qemu-iotests/224 index 38dd153625..c31c55b49d 100755 --- a/tests/qemu-iotests/224 +++ b/tests/qemu-iotests/224 @@ -47,12 +47,11 @@ for filter_node_name in False, True: iotests.FilePath('top.img') as top_img_path, \ iotests.VM() as vm: =20 - assert qemu_img('create', '-f', iotests.imgfmt, - base_img_path, '64M') =3D=3D 0 - assert qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_pat= h, - '-F', iotests.imgfmt, mid_img_path) =3D=3D 0 - assert qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path, - '-F', iotests.imgfmt, top_img_path) =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') + qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path, + '-F', iotests.imgfmt, mid_img_path) + qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path, + '-F', iotests.imgfmt, top_img_path) =20 # Something to commit assert qemu_io_silent(mid_img_path, '-c', 'write -P 1 0 1M') =3D= =3D 0 diff --git a/tests/qemu-iotests/228 b/tests/qemu-iotests/228 index a5eda2e149..f79bae0267 100755 --- a/tests/qemu-iotests/228 +++ b/tests/qemu-iotests/228 @@ -54,11 +54,11 @@ with iotests.FilePath('base.img') as base_img_path, \ iotests.FilePath('top.img') as top_img_path, \ iotests.VM() as vm: =20 - assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') = =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') # Choose a funny way to describe the backing filename - assert qemu_img('create', '-f', iotests.imgfmt, '-b', - 'file:' + base_img_path, '-F', iotests.imgfmt, - top_img_path) =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, '-b', + 'file:' + base_img_path, '-F', iotests.imgfmt, + top_img_path) =20 vm.launch() =20 @@ -172,8 +172,8 @@ with iotests.FilePath('base.img') as base_img_path, \ # (because qemu cannot "canonicalize"/"resolve" the backing # filename unless the backing file is opened implicitly with the # overlay) - assert qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path, - '-F', iotests.imgfmt, top_img_path) =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path, + '-F', iotests.imgfmt, top_img_path) =20 # You can only reliably override backing options by using a node # reference (or by specifying file.filename, but, well...) diff --git a/tests/qemu-iotests/257 b/tests/qemu-iotests/257 index c72c82a171..fb5359c581 100755 --- a/tests/qemu-iotests/257 +++ b/tests/qemu-iotests/257 @@ -240,8 +240,7 @@ def compare_images(image, reference, baseimg=3DNone, ex= pected_match=3DTrue): """ expected_ret =3D 0 if expected_match else 1 if baseimg: - assert qemu_img("rebase", "-u", "-b", baseimg, '-F', iotests.imgfm= t, - image) =3D=3D 0 + qemu_img("rebase", "-u", "-b", baseimg, '-F', iotests.imgfmt, imag= e) ret =3D qemu_img("compare", image, reference) log('qemu_img compare "{:s}" "{:s}" =3D=3D> {:s}, {:s}'.format( image, reference, diff --git a/tests/qemu-iotests/258 b/tests/qemu-iotests/258 index a6618208a8..7798a04d7d 100755 --- a/tests/qemu-iotests/258 +++ b/tests/qemu-iotests/258 @@ -75,13 +75,13 @@ def test_concurrent_finish(write_to_stream_node): =20 # It is important to use raw for the base layer (so that # permissions are just handed through to the protocol layer) - assert qemu_img('create', '-f', 'raw', node0_path, '64M') =3D=3D 0 + qemu_img('create', '-f', 'raw', node0_path, '64M') =20 stream_throttle=3DNone commit_throttle=3DNone =20 for path in [node1_path, node2_path, node3_path, node4_path]: - assert qemu_img('create', '-f', iotests.imgfmt, path, '64M') = =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, path, '64M') =20 if write_to_stream_node: # This is what (most of the time) makes commit finish diff --git a/tests/qemu-iotests/310 b/tests/qemu-iotests/310 index 33c3411869..e3bfedc7fd 100755 --- a/tests/qemu-iotests/310 +++ b/tests/qemu-iotests/310 @@ -43,15 +43,15 @@ with iotests.FilePath('base.img') as base_img_path, \ log('--- Setting up images ---') log('') =20 - assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') = =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') assert qemu_io_silent(base_img_path, '-c', 'write -P 1 0M 1M') =3D=3D 0 assert qemu_io_silent(base_img_path, '-c', 'write -P 1 3M 1M') =3D=3D 0 - assert qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path, - '-F', iotests.imgfmt, mid_img_path) =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path, + '-F', iotests.imgfmt, mid_img_path) assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 2M 1M') =3D=3D 0 assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 4M 1M') =3D=3D 0 - assert qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path, - '-F', iotests.imgfmt, top_img_path) =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path, + '-F', iotests.imgfmt, top_img_path) assert qemu_io_silent(top_img_path, '-c', 'write -P 2 1M 1M') =3D=3D 0 =20 # 0 1 2 3 4 @@ -105,8 +105,7 @@ with iotests.FilePath('base.img') as base_img_path, \ log('') =20 # Detach backing to check that we can read the data from the top level= now - assert qemu_img('rebase', '-u', '-b', '', '-f', iotests.imgfmt, - top_img_path) =3D=3D 0 + qemu_img('rebase', '-u', '-b', '', '-f', iotests.imgfmt, top_img_path) =20 assert qemu_io_silent(top_img_path, '-c', 'read -P 0 0 1M') =3D=3D 0 assert qemu_io_silent(top_img_path, '-c', 'read -P 2 1M 1M') =3D=3D 0 diff --git a/tests/qemu-iotests/tests/block-status-cache b/tests/qemu-iotes= ts/tests/block-status-cache index 6fa10bb8f8..40e648e251 100755 --- a/tests/qemu-iotests/tests/block-status-cache +++ b/tests/qemu-iotests/tests/block-status-cache @@ -35,8 +35,7 @@ nbd_sock =3D os.path.join(iotests.sock_dir, 'nbd.sock') class TestBscWithNbd(iotests.QMPTestCase): def setUp(self) -> None: """Just create an empty image with a read-only NBD server on it""" - assert qemu_img_create('-f', iotests.imgfmt, test_img, - str(image_size)) =3D=3D 0 + qemu_img_create('-f', iotests.imgfmt, test_img, str(image_size)) =20 # Pass --allocation-depth to enable the qemu:allocation-depth cont= ext, # which we are going to query to provoke a block-status inquiry wi= th diff --git a/tests/qemu-iotests/tests/graph-changes-while-io b/tests/qemu-i= otests/tests/graph-changes-while-io index 567e8cf21e..7664f33689 100755 --- a/tests/qemu-iotests/tests/graph-changes-while-io +++ b/tests/qemu-iotests/tests/graph-changes-while-io @@ -34,16 +34,15 @@ def do_qemu_img_bench() -> None: """ Do some I/O requests on `nbd_sock`. """ - assert qemu_img('bench', '-f', 'raw', '-c', '2000000', - f'nbd+unix:///node0?socket=3D{nbd_sock}') =3D=3D 0 + qemu_img('bench', '-f', 'raw', '-c', '2000000', + f'nbd+unix:///node0?socket=3D{nbd_sock}') =20 =20 class TestGraphChangesWhileIO(QMPTestCase): def setUp(self) -> None: # Create an overlay that can be added at runtime on top of the # null-co block node that will receive I/O - assert qemu_img_create('-f', imgfmt, '-F', 'raw', '-b', 'null-co:/= /', - top) =3D=3D 0 + qemu_img_create('-f', imgfmt, '-F', 'raw', '-b', 'null-co://', top) =20 # QSD instance with a null-co block node in an I/O thread, # exported over NBD (on `nbd_sock`, export name "node0") diff --git a/tests/qemu-iotests/tests/image-fleecing b/tests/qemu-iotests/t= ests/image-fleecing index c56278639c..b7e5076104 100755 --- a/tests/qemu-iotests/tests/image-fleecing +++ b/tests/qemu-iotests/tests/image-fleecing @@ -63,18 +63,18 @@ def do_test(vm, use_cbw, use_snapshot_access_filter, ba= se_img_path, log('--- Setting up images ---') log('') =20 - assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') = =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') if bitmap: - assert qemu_img('bitmap', '--add', base_img_path, 'bitmap0') =3D= =3D 0 + qemu_img('bitmap', '--add', base_img_path, 'bitmap0') =20 if use_snapshot_access_filter: assert use_cbw - assert qemu_img('create', '-f', 'raw', fleece_img_path, '64M') =3D= =3D 0 + qemu_img('create', '-f', 'raw', fleece_img_path, '64M') else: - assert qemu_img('create', '-f', 'qcow2', fleece_img_path, '64M') = =3D=3D 0 + qemu_img('create', '-f', 'qcow2', fleece_img_path, '64M') =20 if push_backup: - assert qemu_img('create', '-f', 'qcow2', target_img_path, '64M') = =3D=3D 0 + qemu_img('create', '-f', 'qcow2', target_img_path, '64M') =20 for p in patterns: qemu_io('-f', iotests.imgfmt, diff --git a/tests/qemu-iotests/tests/mirror-ready-cancel-error b/tests/qem= u-iotests/tests/mirror-ready-cancel-error index 770ffca379..1d0e333b5e 100755 --- a/tests/qemu-iotests/tests/mirror-ready-cancel-error +++ b/tests/qemu-iotests/tests/mirror-ready-cancel-error @@ -31,10 +31,8 @@ target =3D os.path.join(iotests.test_dir, 'target.img') =20 class TestMirrorReadyCancelError(iotests.QMPTestCase): def setUp(self) -> None: - assert iotests.qemu_img_create('-f', iotests.imgfmt, source, - str(image_size)) =3D=3D 0 - assert iotests.qemu_img_create('-f', iotests.imgfmt, target, - str(image_size)) =3D=3D 0 + iotests.qemu_img_create('-f', iotests.imgfmt, source, str(image_si= ze)) + iotests.qemu_img_create('-f', iotests.imgfmt, target, str(image_si= ze)) =20 # Ensure that mirror will copy something before READY so the # target format layer will forward the pre-READY flush to its diff --git a/tests/qemu-iotests/tests/mirror-top-perms b/tests/qemu-iotests= /tests/mirror-top-perms index b5849978c4..6ac8d5efcc 100755 --- a/tests/qemu-iotests/tests/mirror-top-perms +++ b/tests/qemu-iotests/tests/mirror-top-perms @@ -34,8 +34,7 @@ source =3D os.path.join(iotests.test_dir, 'source.img') =20 class TestMirrorTopPerms(iotests.QMPTestCase): def setUp(self): - assert qemu_img('create', '-f', iotests.imgfmt, source, - str(image_size)) =3D=3D 0 + qemu_img('create', '-f', iotests.imgfmt, source, str(image_size)) self.vm =3D iotests.VM() self.vm.add_drive(source) self.vm.add_blockdev(f'null-co,node-name=3Dnull,size=3D{image_size= }') diff --git a/tests/qemu-iotests/tests/remove-bitmap-from-backing b/tests/qe= mu-iotests/tests/remove-bitmap-from-backing index 3c397b08ea..fee3141340 100755 --- a/tests/qemu-iotests/tests/remove-bitmap-from-backing +++ b/tests/qemu-iotests/tests/remove-bitmap-from-backing @@ -27,11 +27,11 @@ iotests.script_initialize(supported_fmts=3D['qcow2'], top, base =3D iotests.file_path('top', 'base') size =3D '1M' =20 -assert qemu_img_create('-f', iotests.imgfmt, base, size) =3D=3D 0 -assert qemu_img_create('-f', iotests.imgfmt, '-b', base, - '-F', iotests.imgfmt, top, size) =3D=3D 0 +qemu_img_create('-f', iotests.imgfmt, base, size) +qemu_img_create('-f', iotests.imgfmt, '-b', base, + '-F', iotests.imgfmt, top, size) =20 -assert qemu_img('bitmap', '--add', base, 'bitmap0') =3D=3D 0 +qemu_img('bitmap', '--add', base, 'bitmap0') # Just assert that our method of checking bitmaps in the image works. assert 'bitmaps' in qemu_img_pipe('info', base) =20 diff --git a/tests/qemu-iotests/tests/stream-error-on-reset b/tests/qemu-io= tests/tests/stream-error-on-reset index 7eaedb24d7..389ae822b8 100755 --- a/tests/qemu-iotests/tests/stream-error-on-reset +++ b/tests/qemu-iotests/tests/stream-error-on-reset @@ -54,9 +54,9 @@ class TestStreamErrorOnReset(QMPTestCase): to it will result in an error - top image is attached to a virtio-scsi device """ - assert qemu_img_create('-f', imgfmt, base, str(image_size)) =3D=3D= 0 + qemu_img_create('-f', imgfmt, base, str(image_size)) assert qemu_io_silent('-c', f'write 0 {data_size}', base) =3D=3D 0 - assert qemu_img_create('-f', imgfmt, top, str(image_size)) =3D=3D 0 + qemu_img_create('-f', imgfmt, top, str(image_size)) =20 self.vm =3D iotests.VM() self.vm.add_args('-accel', 'tcg') # Make throttling work properly --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647950727475933.8401231150085; Tue, 22 Mar 2022 05:05:27 -0700 (PDT) Received: from localhost ([::1]:53708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWdGQ-0001Fr-Fv for importer@patchew.org; Tue, 22 Mar 2022 08:05:26 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59244) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8P-0002Vb-CQ for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:21998) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8N-0006R6-Ia for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:09 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-205-xUFdXmQlOnyG2fBQR8ygTw-1; Tue, 22 Mar 2022 07:57:04 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B923310726A2; Tue, 22 Mar 2022 11:57:03 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 74A1740C1257; Tue, 22 Mar 2022 11:57:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950227; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wqblbdJG8EXnEEaUUXvkX6he6g8dvJIBwPCGjhEE7wQ=; b=BnMHW3sO0QtS+ojO62v361p5kT1sVvOt/NR7sfrSLGgpZTorWX4i36hCCgb/fRzdkjDLRp prK5jEUesHniSpSWsOoxi5GqiXlYRwpM91cI1dZrJNSMeGQh+QthZ9gbBTCmnL139eJcg0 W/mskE2MrxDg7DCo+XYRZCrxB1Nnyh0= X-MC-Unique: xUFdXmQlOnyG2fBQR8ygTw-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 09/25] iotests: make qemu_img raise on non-zero rc by default Date: Tue, 22 Mar 2022 12:56:31 +0100 Message-Id: <20220322115647.726044-10-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647950729639100001 Content-Type: text/plain; charset="utf-8" From: John Snow re-write qemu_img() as a function that will by default raise a VerboseProcessException (extended from CalledProcessException) on non-zero return codes. This will produce a stack trace that will show the command line arguments and return code from the failed process run. Users that want something more flexible (there appears to be only one) can use check=3DFalse and manage the return themselves. However, when the return code is negative, the Exception will be raised no matter what. This is done under the belief that there's no legitimate reason, even in negative tests, to see a crash from qemu-img. Signed-off-by: John Snow Reviewed-by: Eric Blake Reviewed-by: Hanna Reitz Message-Id: <20220321201618.903471-5-jsnow@redhat.com> Signed-off-by: Hanna Reitz --- tests/qemu-iotests/257 | 8 +++-- tests/qemu-iotests/iotests.py | 57 ++++++++++++++++++++++++++++++----- 2 files changed, 55 insertions(+), 10 deletions(-) diff --git a/tests/qemu-iotests/257 b/tests/qemu-iotests/257 index fb5359c581..e7e7a2317e 100755 --- a/tests/qemu-iotests/257 +++ b/tests/qemu-iotests/257 @@ -241,11 +241,13 @@ def compare_images(image, reference, baseimg=3DNone, = expected_match=3DTrue): expected_ret =3D 0 if expected_match else 1 if baseimg: qemu_img("rebase", "-u", "-b", baseimg, '-F', iotests.imgfmt, imag= e) - ret =3D qemu_img("compare", image, reference) + + sub =3D qemu_img("compare", image, reference, check=3DFalse) + log('qemu_img compare "{:s}" "{:s}" =3D=3D> {:s}, {:s}'.format( image, reference, - "Identical" if ret =3D=3D 0 else "Mismatch", - "OK!" if ret =3D=3D expected_ret else "ERROR!"), + "Identical" if sub.returncode =3D=3D 0 else "Mismatch", + "OK!" if sub.returncode =3D=3D expected_ret else "ERROR!"), filters=3D[iotests.filter_testfiles]) =20 def test_bitmap_sync(bsync_mode, msync_mode=3D'bitmap', failure=3DNone): diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 508adade9e..4afe63df07 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -37,9 +37,10 @@ =20 from contextlib import contextmanager =20 +from qemu.aqmp.legacy import QEMUMonitorProtocol from qemu.machine import qtest from qemu.qmp import QMPMessage -from qemu.aqmp.legacy import QEMUMonitorProtocol +from qemu.utils import VerboseProcessError =20 # Use this logger for logging messages directly from the iotests module logger =3D logging.getLogger('qemu.iotests') @@ -215,9 +216,50 @@ def qemu_img_pipe_and_status(*args: str) -> Tuple[str,= int]: return qemu_tool_pipe_and_status('qemu-img', full_args, drop_successful_output=3Dis_create) =20 -def qemu_img(*args: str) -> int: - '''Run qemu-img and return the exit code''' - return qemu_img_pipe_and_status(*args)[1] +def qemu_img(*args: str, check: bool =3D True, combine_stdio: bool =3D True + ) -> 'subprocess.CompletedProcess[str]': + """ + Run qemu_img and return the status code and console output. + + This function always prepends QEMU_IMG_OPTIONS and may further alter + the args for 'create' commands. + + :param args: command-line arguments to qemu-img. + :param check: Enforce a return code of zero. + :param combine_stdio: set to False to keep stdout/stderr separated. + + :raise VerboseProcessError: + When the return code is negative, or on any non-zero exit code + when 'check=3DTrue' was provided (the default). This exception has + 'stdout', 'stderr', and 'returncode' properties that may be + inspected to show greater detail. If this exception is not + handled, the command-line, return code, and all console output + will be included at the bottom of the stack trace. + + :return: + a CompletedProcess. This object has args, returncode, and stdout + properties. If streams are not combined, it will also have a + stderr property. + """ + full_args =3D qemu_img_args + qemu_img_create_prepare_args(list(args)) + + subp =3D subprocess.run( + full_args, + stdout=3Dsubprocess.PIPE, + stderr=3Dsubprocess.STDOUT if combine_stdio else subprocess.PIPE, + universal_newlines=3DTrue, + check=3DFalse + ) + + if check and subp.returncode or (subp.returncode < 0): + raise VerboseProcessError( + subp.returncode, full_args, + output=3Dsubp.stdout, + stderr=3Dsubp.stderr, + ) + + return subp + =20 def ordered_qmp(qmsg, conv_keys=3DTrue): # Dictionaries are not ordered prior to 3.6, therefore: @@ -232,7 +274,7 @@ def ordered_qmp(qmsg, conv_keys=3DTrue): return od return qmsg =20 -def qemu_img_create(*args): +def qemu_img_create(*args: str) -> 'subprocess.CompletedProcess[str]': return qemu_img('create', *args) =20 def qemu_img_measure(*args): @@ -467,8 +509,9 @@ def qemu_nbd_popen(*args): =20 def compare_images(img1, img2, fmt1=3Dimgfmt, fmt2=3Dimgfmt): '''Return True if two image files are identical''' - return qemu_img('compare', '-f', fmt1, - '-F', fmt2, img1, img2) =3D=3D 0 + res =3D qemu_img('compare', '-f', fmt1, + '-F', fmt2, img1, img2, check=3DFalse) + return res.returncode =3D=3D 0 =20 def create_image(name, size): '''Create a fully-allocated raw image with sector markers''' --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647950549294340.43586036508145; Tue, 22 Mar 2022 05:02:29 -0700 (PDT) Received: from localhost ([::1]:46524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWdDY-0004uU-79 for importer@patchew.org; Tue, 22 Mar 2022 08:02:28 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8Q-0002WX-T1 for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23201) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8P-0006Rc-AM for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:10 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-258-61DzY8d6MZud2VVt7pp73A-1; Tue, 22 Mar 2022 07:57:05 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4C2E410726A5; Tue, 22 Mar 2022 11:57:05 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 086D740CF8EF; Tue, 22 Mar 2022 11:57:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950228; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LnsVSFfaeMRLkFpVUnMbr/ry+iO9MWG5xODvgji4WfE=; b=YcIBNgSkApKsVXMaK9UPAVV0Kxg5x/Wj1XuluibN8Stp48fCU5291NztQVH6HBlSNp6RjB f9Qj+bLs9wQSY3wOnS8c0kW1qgQfJ+snmRsQrXY01PxozFrQ+IZG61D0K3eC1WIUgF2XOP NRNEc2dLauN9RY4UASLIIb3T7wVUHVI= X-MC-Unique: 61DzY8d6MZud2VVt7pp73A-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 10/25] iotests: fortify compare_images() against crashes Date: Tue, 22 Mar 2022 12:56:32 +0100 Message-Id: <20220322115647.726044-11-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647950550323100001 Content-Type: text/plain; charset="utf-8" From: John Snow Fortify compare_images() to be more discerning about the status codes it receives. If qemu_img() returns an exit code that implies it didn't actually perform the comparison, treat that as an exceptional circumstance and force the caller to be aware of the peril. If a negative test is desired (perhaps to test how qemu_img compare behaves on malformed images, for instance), it is still possible to catch the exception in the test and deal with that circumstance manually. Signed-off-by: John Snow Reviewed-by: Eric Blake Reviewed-by: Hanna Reitz Message-Id: <20220321201618.903471-6-jsnow@redhat.com> Signed-off-by: Hanna Reitz --- tests/qemu-iotests/iotests.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 4afe63df07..9351f9c6ac 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -507,11 +507,22 @@ def qemu_nbd_popen(*args): p.kill() p.wait() =20 -def compare_images(img1, img2, fmt1=3Dimgfmt, fmt2=3Dimgfmt): - '''Return True if two image files are identical''' - res =3D qemu_img('compare', '-f', fmt1, - '-F', fmt2, img1, img2, check=3DFalse) - return res.returncode =3D=3D 0 +def compare_images(img1: str, img2: str, + fmt1: str =3D imgfmt, fmt2: str =3D imgfmt) -> bool: + """ + Compare two images with QEMU_IMG; return True if they are identical. + + :raise CalledProcessError: + when qemu-img crashes or returns a status code of anything other + than 0 (identical) or 1 (different). + """ + try: + qemu_img('compare', '-f', fmt1, '-F', fmt2, img1, img2) + return True + except subprocess.CalledProcessError as exc: + if exc.returncode =3D=3D 1: + return False + raise =20 def create_image(name, size): '''Create a fully-allocated raw image with sector markers''' --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647950769064464.5469263396693; Tue, 22 Mar 2022 05:06:09 -0700 (PDT) Received: from localhost ([::1]:55856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWdH7-0002mk-Mi for importer@patchew.org; Tue, 22 Mar 2022 08:06:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59328) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8S-0002YT-Dp for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33327) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8R-0006S7-0V for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:12 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-64-PaVa0EArM2-I6U1WDeFQhw-1; Tue, 22 Mar 2022 07:57:07 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F05843C16181; Tue, 22 Mar 2022 11:57:06 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ACD8D40C1257; Tue, 22 Mar 2022 11:57:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950230; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WogYTUP1vS1ERQbFHwX1HKelUZkM4XJNsONZrTURogA=; b=YEhZb/WgnyUcGJVO8j6LIZts1oWA+6qNTQLj35GJvwU0ytzwTH4Eog+Qvmtp5v8FnnObT7 0lzO4bNUVneyDqHOVEe52GitPK2KHjoJHwjcV3JAoR5Ug1JNTow/tX8RY2SF3uXnrtURGo hloDg8jSikwjHM6ByEXdgJwdgKnreno= X-MC-Unique: PaVa0EArM2-I6U1WDeFQhw-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 11/25] iotests: add qemu_img_json() Date: Tue, 22 Mar 2022 12:56:33 +0100 Message-Id: <20220322115647.726044-12-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647950771276100001 Content-Type: text/plain; charset="utf-8"; x-default="true" From: John Snow qemu_img_json() is a new helper built on top of qemu_img() that tries to pull a valid JSON document out of the stdout stream. In the event that the return code is negative (the program crashed), or the code is greater than zero and did not produce valid JSON output, the VerboseProcessError raised by qemu_img() is re-raised. In the event that the return code is zero but we can't parse valid JSON, allow the JSON deserialization error to be raised. Signed-off-by: John Snow Reviewed-by: Eric Blake Message-Id: <20220321201618.903471-7-jsnow@redhat.com> Signed-off-by: Hanna Reitz --- tests/qemu-iotests/iotests.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 9351f9c6ac..56aa068277 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -277,6 +277,38 @@ def ordered_qmp(qmsg, conv_keys=3DTrue): def qemu_img_create(*args: str) -> 'subprocess.CompletedProcess[str]': return qemu_img('create', *args) =20 +def qemu_img_json(*args: str) -> Any: + """ + Run qemu-img and return its output as deserialized JSON. + + :raise CalledProcessError: + When qemu-img crashes, or returns a non-zero exit code without + producing a valid JSON document to stdout. + :raise JSONDecoderError: + When qemu-img returns 0, but failed to produce a valid JSON docume= nt. + + :return: A deserialized JSON object; probably a dict[str, Any]. + """ + try: + res =3D qemu_img(*args, combine_stdio=3DFalse) + except subprocess.CalledProcessError as exc: + # Terminated due to signal. Don't bother. + if exc.returncode < 0: + raise + + # Commands like 'check' can return failure (exit codes 2 and 3) + # to indicate command completion, but with errors found. For + # multi-command flexibility, ignore the exact error codes and + # *try* to load JSON. + try: + return json.loads(exc.stdout) + except json.JSONDecodeError: + # Nope. This thing is toast. Raise the /process/ error. + pass + raise + + return json.loads(res.stdout) + def qemu_img_measure(*args): return json.loads(qemu_img_pipe("measure", "--output", "json", *args)) =20 --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647951175933849.8992128968683; Tue, 22 Mar 2022 05:12:55 -0700 (PDT) Received: from localhost ([::1]:43890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWdNe-0005SF-Rk for importer@patchew.org; Tue, 22 Mar 2022 08:12:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59352) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8U-0002aU-4W for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28152) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8S-0006Si-Gm for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:13 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-402-ul28e0yvM66rDvSkmBQwTw-1; Tue, 22 Mar 2022 07:57:08 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8351D1C00B85; Tue, 22 Mar 2022 11:57:08 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 404B540CF8EF; Tue, 22 Mar 2022 11:57:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950231; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nRSM/KNz4Xwb4AyJF08UreEKrOM8m9mxxYcAGrtL8ZU=; b=dQQRSaf88CpH1Zo/xOQnpE5s7Gd2lCwpLkwix7r63XzP1rKcnADqV0LoR4X7Lm52LZQ0TC T+Mlyc87XcJvuaxjegzyuF0NpgqDYIP3dXo9p+4dqTDPTV0gAZNHPnnU34wLKITo11sNtG Qzzix1Qichg/ZJSUAKUlNCtc9F16TJo= X-MC-Unique: ul28e0yvM66rDvSkmBQwTw-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 12/25] iotests: use qemu_img_json() when applicable Date: Tue, 22 Mar 2022 12:56:34 +0100 Message-Id: <20220322115647.726044-13-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647951176326100001 Content-Type: text/plain; charset="utf-8" From: John Snow qemu_img_json() gives better diagnostic information on failure. Signed-off-by: John Snow Reviewed-by: Hanna Reitz Message-Id: <20220321201618.903471-8-jsnow@redhat.com> Signed-off-by: Hanna Reitz --- tests/qemu-iotests/iotests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 56aa068277..4725313150 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -309,11 +309,11 @@ def qemu_img_json(*args: str) -> Any: =20 return json.loads(res.stdout) =20 -def qemu_img_measure(*args): - return json.loads(qemu_img_pipe("measure", "--output", "json", *args)) +def qemu_img_measure(*args: str) -> Any: + return qemu_img_json("measure", "--output", "json", *args) =20 -def qemu_img_check(*args): - return json.loads(qemu_img_pipe("check", "--output", "json", *args)) +def qemu_img_check(*args: str) -> Any: + return qemu_img_json("check", "--output", "json", *args) =20 def qemu_img_pipe(*args: str) -> str: '''Run qemu-img and return its output''' --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647951572784265.826648144469; Tue, 22 Mar 2022 05:19:32 -0700 (PDT) Received: from localhost ([::1]:52428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWdU1-00038e-Uk for importer@patchew.org; Tue, 22 Mar 2022 08:19:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59380) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8V-0002f6-Rq for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:31823) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8U-0006T0-3w for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:15 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-536-jn9a0DPeNgGSjtU8ewRNTA-1; Tue, 22 Mar 2022 07:57:10 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1B1B329DD989; Tue, 22 Mar 2022 11:57:10 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CC248403D1C5; Tue, 22 Mar 2022 11:57:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950233; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n8TWpjZyrcziqfvMPKSVJiBJRcKJb7ZvjksXc7mFqJw=; b=CAm9fBFilMFiDikVZebYfhmh+i7tZjmEGhCHVxgA+5sSiD9ejNB57aBfh0ZVk8c8sq0m5G W0LSRkdyOzx53KJn9OR7DtsjjIhmYWwuCivUjpEgFSa6pOMqllLNnc9RUT+yvrCSff/Vs0 kKsxgBJwlHNPAkXdOC/wjtkfTbvtNtw= X-MC-Unique: jn9a0DPeNgGSjtU8ewRNTA-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 13/25] iotests: add qemu_img_info() Date: Tue, 22 Mar 2022 12:56:35 +0100 Message-Id: <20220322115647.726044-14-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647951574234100001 Content-Type: text/plain; charset="utf-8" From: John Snow Add qemu_img_info() by analogy with qemu_img_measure() and qemu_img_check(). Modify image_size() to use this function instead to take advantage of the better diagnostic information on failure provided (ultimately) by qemu_img(). Signed-off-by: John Snow Reviewed-by: Hanna Reitz Message-Id: <20220321201618.903471-9-jsnow@redhat.com> Signed-off-by: Hanna Reitz --- tests/qemu-iotests/065 | 5 ++--- tests/qemu-iotests/242 | 5 ++--- tests/qemu-iotests/iotests.py | 15 +++++++++++---- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/tests/qemu-iotests/065 b/tests/qemu-iotests/065 index f7c1b68dad..9466ce7df4 100755 --- a/tests/qemu-iotests/065 +++ b/tests/qemu-iotests/065 @@ -24,7 +24,7 @@ import os import re import json import iotests -from iotests import qemu_img, qemu_img_pipe +from iotests import qemu_img, qemu_img_info, qemu_img_pipe import unittest =20 test_img =3D os.path.join(iotests.test_dir, 'test.img') @@ -49,8 +49,7 @@ class TestQemuImgInfo(TestImageInfoSpecific): human_compare =3D None =20 def test_json(self): - data =3D json.loads(qemu_img_pipe('info', '--output=3Djson', test_= img)) - data =3D data['format-specific'] + data =3D qemu_img_info(test_img)['format-specific'] self.assertEqual(data['type'], iotests.imgfmt) self.assertEqual(data['data'], self.json_compare) =20 diff --git a/tests/qemu-iotests/242 b/tests/qemu-iotests/242 index 96a30152b0..547bf382e3 100755 --- a/tests/qemu-iotests/242 +++ b/tests/qemu-iotests/242 @@ -22,7 +22,7 @@ import iotests import json import struct -from iotests import qemu_img_create, qemu_io, qemu_img_pipe, \ +from iotests import qemu_img_create, qemu_io, qemu_img_info, \ file_path, img_info_log, log, filter_qemu_io =20 iotests.script_initialize(supported_fmts=3D['qcow2'], @@ -39,8 +39,7 @@ flag_offset =3D 0x5000f def print_bitmap(extra_args): log('qemu-img info dump:\n') img_info_log(disk, extra_args=3Dextra_args) - result =3D json.loads(qemu_img_pipe('info', '--force-share', - '--output=3Djson', disk)) + result =3D qemu_img_info('--force-share', disk) if 'bitmaps' in result['format-specific']['data']: bitmaps =3D result['format-specific']['data']['bitmaps'] log('The same bitmaps in JSON format:') diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 4725313150..2a1c589b76 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -315,6 +315,9 @@ def qemu_img_measure(*args: str) -> Any: def qemu_img_check(*args: str) -> Any: return qemu_img_json("check", "--output", "json", *args) =20 +def qemu_img_info(*args: str) -> Any: + return qemu_img_json('info', "--output", "json", *args) + def qemu_img_pipe(*args: str) -> str: '''Run qemu-img and return its output''' return qemu_img_pipe_and_status(*args)[0] @@ -565,10 +568,14 @@ def create_image(name, size): file.write(sector) i =3D i + 512 =20 -def image_size(img): - '''Return image's virtual size''' - r =3D qemu_img_pipe('info', '--output=3Djson', '-f', imgfmt, img) - return json.loads(r)['virtual-size'] +def image_size(img: str) -> int: + """Return image's virtual size""" + value =3D qemu_img_info('-f', imgfmt, img)['virtual-size'] + if not isinstance(value, int): + type_name =3D type(value).__name__ + raise TypeError("Expected 'int' for 'virtual-size', " + f"got '{value}' of type '{type_name}'") + return value =20 def is_str(val): return isinstance(val, str) --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164795093161077.4980463642886; Tue, 22 Mar 2022 05:08:51 -0700 (PDT) Received: from localhost ([::1]:33910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWdJi-00071E-JD for importer@patchew.org; Tue, 22 Mar 2022 08:08:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8Y-0002oF-JH for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28747) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8V-0006TL-WF for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:18 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-482-XhOF1CghNF-hreH5XaNF-A-1; Tue, 22 Mar 2022 07:57:12 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A5A213801EC0; Tue, 22 Mar 2022 11:57:11 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5EDD5400E881; Tue, 22 Mar 2022 11:57:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950235; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LnAmIL+mm8A/gjbie9aY1jj1w9RDoBehvmvsqzMjPSo=; b=KxsfomzDP2Aksn5imzab16Zq4ftzksPkHlcBIrAElXroNqaGfxpC3Hop+YRz9zhcODzV1u 6vZuA90qdsjhqhIbHQKf6gtKDcbUmph+T3KbtLBcNkoFh4RCFybHHWGd4KUJYBfzsaKpzm fdnDgicBarFGBQiumgOMEnfXpKKdN3E= X-MC-Unique: XhOF1CghNF-hreH5XaNF-A-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 14/25] iotests/remove-bitmap-from-backing: use qemu_img_info() Date: Tue, 22 Mar 2022 12:56:36 +0100 Message-Id: <20220322115647.726044-15-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647950931956100001 Content-Type: text/plain; charset="utf-8" From: John Snow This removes two more usages of qemu_img_pipe() and replaces them with calls to qemu_img(), which provides better diagnostic information on failure. Signed-off-by: John Snow Reviewed-by: Hanna Reitz Message-Id: <20220321201618.903471-10-jsnow@redhat.com> Signed-off-by: Hanna Reitz --- tests/qemu-iotests/tests/remove-bitmap-from-backing | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/qemu-iotests/tests/remove-bitmap-from-backing b/tests/qe= mu-iotests/tests/remove-bitmap-from-backing index fee3141340..15be32dcb9 100755 --- a/tests/qemu-iotests/tests/remove-bitmap-from-backing +++ b/tests/qemu-iotests/tests/remove-bitmap-from-backing @@ -19,7 +19,7 @@ # =20 import iotests -from iotests import log, qemu_img_create, qemu_img, qemu_img_pipe +from iotests import log, qemu_img_create, qemu_img, qemu_img_info =20 iotests.script_initialize(supported_fmts=3D['qcow2'], unsupported_imgopts=3D['compat']) @@ -33,7 +33,7 @@ qemu_img_create('-f', iotests.imgfmt, '-b', base, =20 qemu_img('bitmap', '--add', base, 'bitmap0') # Just assert that our method of checking bitmaps in the image works. -assert 'bitmaps' in qemu_img_pipe('info', base) +assert 'bitmaps' in qemu_img_info(base)['format-specific']['data'] =20 vm =3D iotests.VM().add_drive(top, 'backing.node-name=3Dbase') vm.launch() @@ -68,5 +68,5 @@ if result !=3D {'return': {}}: =20 vm.shutdown() =20 -if 'bitmaps' in qemu_img_pipe('info', base): +if 'bitmaps' in qemu_img_info(base)['format-specific']['data']: log('ERROR: Bitmap is still in the base image') --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647951723988826.2367555590998; Tue, 22 Mar 2022 05:22:03 -0700 (PDT) Received: from localhost ([::1]:56250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWdWW-0005xg-6h for importer@patchew.org; Tue, 22 Mar 2022 08:22:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59858) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8r-0003Vf-Fc for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29982) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8p-0006ZB-HQ for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:37 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-641-vXeJdMIwNbau2IeqP0mqTg-1; Tue, 22 Mar 2022 07:57:13 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5E1FD811E90; Tue, 22 Mar 2022 11:57:13 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F11F22166B2D; Tue, 22 Mar 2022 11:57:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950255; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VWCrENiyWJM9cry0gGVnTJOzSRziA60ognUlZOfbQes=; b=MZm/0/E4Bvs2cbudhdJbAIAsLEHcgNrVmQyCTsV5dFWco5DsHJeTr3hwPfK6ySdaFkqO87 ipXtqCyV4ktVeXmzxR4X5Fg3lL+W57oOHk5ijY6qgiMcwR4OKkW9kK2PVq/IQyKHaqsy07 PShhVfZFrOKTXz4sNwVm4QZMK0Su/Pg= X-MC-Unique: vXeJdMIwNbau2IeqP0mqTg-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 15/25] iotests: add qemu_img_map() function Date: Tue, 22 Mar 2022 12:56:37 +0100 Message-Id: <20220322115647.726044-16-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647951736799100003 Content-Type: text/plain; charset="utf-8" From: John Snow Add a qemu_img_map() function by analogy with qemu_img_measure(), qemu_img_check(), and qemu_img_info() that all return JSON information. Replace calls to qemu_img_pipe('map', '--output=3Djson', ...) with this new function, which provides better diagnostic information on failure. Note: The output for iotest 211 changes, because logging JSON after it was deserialized by Python behaves a little differently than logging the raw JSON document string itself. (iotests.log() sorts the keys for Python 3.6 support.) Signed-off-by: John Snow Reviewed-by: Eric Blake Message-Id: <20220321201618.903471-11-jsnow@redhat.com> Signed-off-by: Hanna Reitz --- tests/qemu-iotests/041 | 5 ++--- tests/qemu-iotests/211 | 6 +++--- tests/qemu-iotests/211.out | 10 +++------- tests/qemu-iotests/iotests.py | 3 +++ tests/qemu-iotests/tests/block-status-cache | 11 ++++------- tests/qemu-iotests/tests/parallels-read-bitmap | 6 ++---- 6 files changed, 17 insertions(+), 24 deletions(-) diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 index db9f5dc540..3e16acee56 100755 --- a/tests/qemu-iotests/041 +++ b/tests/qemu-iotests/041 @@ -24,7 +24,7 @@ import os import re import json import iotests -from iotests import qemu_img, qemu_img_pipe, qemu_io +from iotests import qemu_img, qemu_img_map, qemu_io =20 backing_img =3D os.path.join(iotests.test_dir, 'backing.img') target_backing_img =3D os.path.join(iotests.test_dir, 'target-backing.img') @@ -1360,8 +1360,7 @@ class TestFilters(iotests.QMPTestCase): =20 self.vm.qmp('blockdev-del', node_name=3D'target') =20 - target_map =3D qemu_img_pipe('map', '--output=3Djson', target_img) - target_map =3D json.loads(target_map) + target_map =3D qemu_img_map(target_img) =20 assert target_map[0]['start'] =3D=3D 0 assert target_map[0]['length'] =3D=3D 512 * 1024 diff --git a/tests/qemu-iotests/211 b/tests/qemu-iotests/211 index f52cadade1..1a3b4596c8 100755 --- a/tests/qemu-iotests/211 +++ b/tests/qemu-iotests/211 @@ -59,7 +59,7 @@ with iotests.FilePath('t.vdi') as disk_path, \ vm.shutdown() =20 iotests.img_info_log(disk_path) - iotests.log(iotests.qemu_img_pipe('map', '--output=3Djson', disk_path)) + iotests.log(iotests.qemu_img_map(disk_path)) =20 # # Successful image creation (explicit defaults) @@ -83,7 +83,7 @@ with iotests.FilePath('t.vdi') as disk_path, \ vm.shutdown() =20 iotests.img_info_log(disk_path) - iotests.log(iotests.qemu_img_pipe('map', '--output=3Djson', disk_path)) + iotests.log(iotests.qemu_img_map(disk_path)) =20 # # Successful image creation (with non-default options) @@ -107,7 +107,7 @@ with iotests.FilePath('t.vdi') as disk_path, \ vm.shutdown() =20 iotests.img_info_log(disk_path) - iotests.log(iotests.qemu_img_pipe('map', '--output=3Djson', disk_path)) + iotests.log(iotests.qemu_img_map(disk_path)) =20 # # Invalid BlockdevRef diff --git a/tests/qemu-iotests/211.out b/tests/qemu-iotests/211.out index c4425b5982..f02c75409c 100644 --- a/tests/qemu-iotests/211.out +++ b/tests/qemu-iotests/211.out @@ -17,8 +17,7 @@ file format: IMGFMT virtual size: 128 MiB (134217728 bytes) cluster_size: 1048576 =20 -[{ "start": 0, "length": 134217728, "depth": 0, "present": true, "zero": t= rue, "data": false}] - +[{"data": false, "depth": 0, "length": 134217728, "present": true, "start"= : 0, "zero": true}] =3D=3D=3D Successful image creation (explicit defaults) =3D=3D=3D =20 {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "file", "filename": "TEST_DIR/PID-t.vdi", "size": 0}}} @@ -36,8 +35,7 @@ file format: IMGFMT virtual size: 64 MiB (67108864 bytes) cluster_size: 1048576 =20 -[{ "start": 0, "length": 67108864, "depth": 0, "present": true, "zero": tr= ue, "data": false}] - +[{"data": false, "depth": 0, "length": 67108864, "present": true, "start":= 0, "zero": true}] =3D=3D=3D Successful image creation (with non-default options) =3D=3D=3D =20 {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "file", "filename": "TEST_DIR/PID-t.vdi", "size": 0}}} @@ -55,9 +53,7 @@ file format: IMGFMT virtual size: 32 MiB (33554432 bytes) cluster_size: 1048576 =20 -[{ "start": 0, "length": 3072, "depth": 0, "present": true, "zero": false,= "data": true, "offset": 1024}, -{ "start": 3072, "length": 33551360, "depth": 0, "present": true, "zero": = true, "data": true, "offset": 4096}] - +[{"data": true, "depth": 0, "length": 3072, "offset": 1024, "present": tru= e, "start": 0, "zero": false}, {"data": true, "depth": 0, "length": 3355136= 0, "offset": 4096, "present": true, "start": 3072, "zero": true}] =3D=3D=3D Invalid BlockdevRef =3D=3D=3D =20 {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "vdi", "file": "this doesn't exist", "size": 33554432}}} diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 2a1c589b76..b3e793f78a 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -318,6 +318,9 @@ def qemu_img_check(*args: str) -> Any: def qemu_img_info(*args: str) -> Any: return qemu_img_json('info', "--output", "json", *args) =20 +def qemu_img_map(*args: str) -> Any: + return qemu_img_json('map', "--output", "json", *args) + def qemu_img_pipe(*args: str) -> str: '''Run qemu-img and return its output''' return qemu_img_pipe_and_status(*args)[0] diff --git a/tests/qemu-iotests/tests/block-status-cache b/tests/qemu-iotes= ts/tests/block-status-cache index 40e648e251..5a7bc2c149 100755 --- a/tests/qemu-iotests/tests/block-status-cache +++ b/tests/qemu-iotests/tests/block-status-cache @@ -22,7 +22,7 @@ import os import signal import iotests -from iotests import qemu_img_create, qemu_img_pipe, qemu_nbd +from iotests import qemu_img_create, qemu_img_map, qemu_nbd =20 =20 image_size =3D 1 * 1024 * 1024 @@ -76,8 +76,7 @@ class TestBscWithNbd(iotests.QMPTestCase): # to allocate the first sector to facilitate alignment probing), a= nd # then the rest to be zero. The BSC will thus contain (if anythin= g) # one range covering the first sector. - map_pre =3D qemu_img_pipe('map', '--output=3Djson', '--image-opts', - nbd_img_opts) + map_pre =3D qemu_img_map('--image-opts', nbd_img_opts) =20 # qemu:allocation-depth maps for want_zero=3Dfalse. # want_zero=3Dfalse should (with the file driver, which the server= is @@ -111,14 +110,12 @@ class TestBscWithNbd(iotests.QMPTestCase): # never loop too many times here. for _ in range(2): # (Ignore the result, this is just to contaminate the cache) - qemu_img_pipe('map', '--output=3Djson', '--image-opts', - nbd_img_opts_alloc_depth) + qemu_img_map('--image-opts', nbd_img_opts_alloc_depth) =20 # Now let's see whether the cache reports everything as data, or # whether we get correct information (i.e. the same as we got on o= ur # first attempt). - map_post =3D qemu_img_pipe('map', '--output=3Djson', '--image-opts= ', - nbd_img_opts) + map_post =3D qemu_img_map('--image-opts', nbd_img_opts) =20 if map_pre !=3D map_post: print('ERROR: Map information differs before and after queryin= g ' + diff --git a/tests/qemu-iotests/tests/parallels-read-bitmap b/tests/qemu-io= tests/tests/parallels-read-bitmap index af6b9c5db3..38ab5fa5b2 100755 --- a/tests/qemu-iotests/tests/parallels-read-bitmap +++ b/tests/qemu-iotests/tests/parallels-read-bitmap @@ -18,9 +18,8 @@ # along with this program. If not, see . # =20 -import json import iotests -from iotests import qemu_nbd_popen, qemu_img_pipe, log, file_path +from iotests import qemu_nbd_popen, qemu_img_map, log, file_path =20 iotests.script_initialize(supported_fmts=3D['parallels']) =20 @@ -36,8 +35,7 @@ iotests.unarchive_sample_image('parallels-with-bitmap', d= isk) =20 with qemu_nbd_popen('--read-only', f'--socket=3D{nbd_sock}', f'--bitmap=3D{bitmap}', '-f', iotests.imgfmt, disk): - out =3D qemu_img_pipe('map', '--output=3Djson', '--image-opts', nbd_op= ts) - chunks =3D json.loads(out) + chunks =3D qemu_img_map('--image-opts', nbd_opts) cluster =3D 64 * 1024 =20 log('dirty clusters (cluster size is 64K):') --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16479507570051009.0566398185579; Tue, 22 Mar 2022 05:05:57 -0700 (PDT) Received: from localhost ([::1]:55398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWdGv-0002P9-8K for importer@patchew.org; Tue, 22 Mar 2022 08:05:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8b-0002yt-Vi for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41337) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8a-0006UO-Do for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:21 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-664-KPdxQnWANCGzMC1jtW9JqA-1; Tue, 22 Mar 2022 07:57:16 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 63E8F899EC1; Tue, 22 Mar 2022 11:57:16 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A3F3753D8; Tue, 22 Mar 2022 11:57:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950239; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7NBzGSCxVE6BIksBoT14ueJAaPwi/hOC+aUN8yHHKWI=; b=QR7BW6+fIQhFefKTa5j7tyYR+W5Rt+gwG7Jiq8hNyLC5EPoinY6iyN+tMQ1JbwZEtMCNIu 01InE4iSb8eZCEeEf/WWsj+Kyhri3xtDItNfIXoPW2ZVEYOAZKCodTB0t7/te4ZaaZjTTa TQcuzeAyHZB+X/noXkW12IEo0zBu7is= X-MC-Unique: KPdxQnWANCGzMC1jtW9JqA-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 16/25] iotests: change supports_quorum to use qemu_img Date: Tue, 22 Mar 2022 12:56:38 +0100 Message-Id: <20220322115647.726044-17-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647950759087100001 Content-Type: text/plain; charset="utf-8" From: John Snow Similar to other recent changes: use the qemu_img() invocation that supports throwing loud, nasty exceptions when it fails for surprising reasons. (Why would "--help" ever fail? I don't know, but eliminating *all* calls to qemu-img that do not go through qemu_img() is my goal, so qemu_img_pipe() has to be removed.) Signed-off-by: John Snow Reviewed-by: Hanna Reitz Message-Id: <20220321201618.903471-12-jsnow@redhat.com> Signed-off-by: Hanna Reitz --- tests/qemu-iotests/iotests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index b3e793f78a..aaf4da8be4 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -1428,8 +1428,8 @@ def _verify_imgopts(unsupported: Sequence[str] =3D ()= ) -> None: notrun(f'not suitable for this imgopts: {imgopts}') =20 =20 -def supports_quorum(): - return 'quorum' in qemu_img_pipe('--help') +def supports_quorum() -> bool: + return 'quorum' in qemu_img('--help').stdout =20 def verify_quorum(): '''Skip test suite if quorum support is not available''' --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647950975284641.4790880243286; Tue, 22 Mar 2022 05:09:35 -0700 (PDT) Received: from localhost ([::1]:35646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWdKP-0008B3-Tn for importer@patchew.org; Tue, 22 Mar 2022 08:09:33 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8e-00036W-78 for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:44997) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8c-0006Ui-Ba for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:23 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-669-ffzfCvG_OzikwuHKEV0kKw-1; Tue, 22 Mar 2022 07:57:18 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1BFE785A5BE; Tue, 22 Mar 2022 11:57:18 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C9F7D20296A5; Tue, 22 Mar 2022 11:57:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950241; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+UXEIB4YYv4tNHiA06z3+C9u1zINzlTQ67aMxlUHRTM=; b=ipsXNJeRDpnb6n30EbLzG9Y10IgkfUeExtkav2pLc2xeas2jJvts1ZmecNHcnSinPRZwzF iHYu3m4iC7Eyj5Bcr8etFZhoLFlVjlf0DqF53kCegALKDjE2Hq0Cj8Mhuwg0JtvJySVE1L LXOdYvZyBcclqg3d3+7euiVDlDxPIE8= X-MC-Unique: ffzfCvG_OzikwuHKEV0kKw-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 17/25] iotests: replace unchecked calls to qemu_img_pipe() Date: Tue, 22 Mar 2022 12:56:39 +0100 Message-Id: <20220322115647.726044-18-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647950976483100003 Content-Type: text/plain; charset="utf-8" From: John Snow qemu_img_pipe() discards the return code from qemu-img in favor of returning just its output. Some tests using this function don't save, log, or check the output either, though, which is unsafe. Replace all of these calls with a checked version. Tests affected are 194, 202, 203, 234, 262, and 303. Signed-off-by: John Snow Reviewed-by: Hanna Reitz Message-Id: <20220321201618.903471-13-jsnow@redhat.com> Signed-off-by: Hanna Reitz --- tests/qemu-iotests/194 | 4 ++-- tests/qemu-iotests/202 | 4 ++-- tests/qemu-iotests/203 | 4 ++-- tests/qemu-iotests/234 | 4 ++-- tests/qemu-iotests/262 | 2 +- tests/qemu-iotests/303 | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/qemu-iotests/194 b/tests/qemu-iotests/194 index e44b8df728..68894371f5 100755 --- a/tests/qemu-iotests/194 +++ b/tests/qemu-iotests/194 @@ -33,8 +33,8 @@ with iotests.FilePath('source.img') as source_img_path, \ iotests.VM('dest') as dest_vm: =20 img_size =3D '1G' - iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, source_img_path,= img_size) - iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, dest_img_path, i= mg_size) + iotests.qemu_img_create('-f', iotests.imgfmt, source_img_path, img_siz= e) + iotests.qemu_img_create('-f', iotests.imgfmt, dest_img_path, img_size) =20 iotests.log('Launching VMs...') (source_vm.add_drive(source_img_path) diff --git a/tests/qemu-iotests/202 b/tests/qemu-iotests/202 index 8eb5f32d15..b784dcd791 100755 --- a/tests/qemu-iotests/202 +++ b/tests/qemu-iotests/202 @@ -35,8 +35,8 @@ with iotests.FilePath('disk0.img') as disk0_img_path, \ iotests.VM() as vm: =20 img_size =3D '10M' - iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, disk0_img_path, = img_size) - iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, disk1_img_path, = img_size) + iotests.qemu_img_create('-f', iotests.imgfmt, disk0_img_path, img_size) + iotests.qemu_img_create('-f', iotests.imgfmt, disk1_img_path, img_size) =20 iotests.log('Launching VM...') vm.launch() diff --git a/tests/qemu-iotests/203 b/tests/qemu-iotests/203 index ea30e50497..ab80fd0e44 100755 --- a/tests/qemu-iotests/203 +++ b/tests/qemu-iotests/203 @@ -33,8 +33,8 @@ with iotests.FilePath('disk0.img') as disk0_img_path, \ iotests.VM() as vm: =20 img_size =3D '10M' - iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, disk0_img_path, = img_size) - iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, disk1_img_path, = img_size) + iotests.qemu_img_create('-f', iotests.imgfmt, disk0_img_path, img_size) + iotests.qemu_img_create('-f', iotests.imgfmt, disk1_img_path, img_size) =20 iotests.log('Launching VM...') (vm.add_object('iothread,id=3Diothread0') diff --git a/tests/qemu-iotests/234 b/tests/qemu-iotests/234 index cb5f1753e0..a9f764bb2c 100755 --- a/tests/qemu-iotests/234 +++ b/tests/qemu-iotests/234 @@ -34,8 +34,8 @@ with iotests.FilePath('img') as img_path, \ iotests.VM(path_suffix=3D'a') as vm_a, \ iotests.VM(path_suffix=3D'b') as vm_b: =20 - iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, backing_path, '6= 4M') - iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, img_path, '64M') + iotests.qemu_img_create('-f', iotests.imgfmt, backing_path, '64M') + iotests.qemu_img_create('-f', iotests.imgfmt, img_path, '64M') =20 os.mkfifo(fifo_a) os.mkfifo(fifo_b) diff --git a/tests/qemu-iotests/262 b/tests/qemu-iotests/262 index 32d69988ef..2294fd5ecb 100755 --- a/tests/qemu-iotests/262 +++ b/tests/qemu-iotests/262 @@ -51,7 +51,7 @@ with iotests.FilePath('img') as img_path, \ =20 vm.add_device('virtio-blk,drive=3D%s,iothread=3Diothread0' % root) =20 - iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, img_path, '64M') + iotests.qemu_img_create('-f', iotests.imgfmt, img_path, '64M') =20 os.mkfifo(fifo) =20 diff --git a/tests/qemu-iotests/303 b/tests/qemu-iotests/303 index 16c2e10827..93aa5ce9b7 100755 --- a/tests/qemu-iotests/303 +++ b/tests/qemu-iotests/303 @@ -38,7 +38,7 @@ def create_bitmap(bitmap_number, disabled): if disabled: args.append('--disable') =20 - iotests.qemu_img_pipe(*args) + iotests.qemu_img(*args) =20 =20 def write_to_disk(offset, size): --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647951902271677.2926290697528; Tue, 22 Mar 2022 05:25:02 -0700 (PDT) Received: from localhost ([::1]:33456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWdZM-0001Df-4j for importer@patchew.org; Tue, 22 Mar 2022 08:25:00 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8e-00036V-79 for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24173) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8b-0006Ua-OU for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:23 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-638-l6LszUsKP5KN0ftiLEzRpQ-1; Tue, 22 Mar 2022 07:57:20 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BC67E1044561; Tue, 22 Mar 2022 11:57:19 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5A6212166B2D; Tue, 22 Mar 2022 11:57:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950241; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SZzMVTip4gjaDKoK3aJSqqIrn3D4aoY7OzkEHXCr+6w=; b=NZEVFlVbCRcpGXCV09r/0ro9OU6wWV0xjRhZwvRHfJaHtqyO/AZxnajoQ6ktywWCQIK9zZ NPJJ+xt9T6DNJ5BEiBHcCn+vViS+YKJ9OEc0U6lOrXuQBr0takpH+vG+GVhKy8x+uPlJ1T Ru2j+LKU6Qw0sZ8rj/ezBwbKLJnKsGE= X-MC-Unique: l6LszUsKP5KN0ftiLEzRpQ-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 18/25] iotests/149: Remove qemu_img_pipe() call Date: Tue, 22 Mar 2022 12:56:40 +0100 Message-Id: <20220322115647.726044-19-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647951904338100001 Content-Type: text/plain; charset="utf-8" From: John Snow qemu_img_pipe calls blank their output when the command being run is a 'create' call and the command succeeds. Thus, the normative output for this command in iotest 149 is to print a blank line. We can remove the logging from this invocation and use a checked invocation, but we still need to inspect the actual output to see if we want to retroactively skip the test due to missing cipher support. Signed-off-by: John Snow Reviewed-by: Hanna Reitz Message-Id: <20220321201618.903471-14-jsnow@redhat.com> Signed-off-by: Hanna Reitz --- tests/qemu-iotests/149 | 7 +++++-- tests/qemu-iotests/149.out | 21 --------------------- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/tests/qemu-iotests/149 b/tests/qemu-iotests/149 index d49646ca60..9bb96d6a1d 100755 --- a/tests/qemu-iotests/149 +++ b/tests/qemu-iotests/149 @@ -265,8 +265,11 @@ def qemu_img_create(config, size_mb): "%dM" % size_mb] =20 iotests.log("qemu-img " + " ".join(args), filters=3D[iotests.filter_te= st_dir]) - iotests.log(check_cipher_support(config, iotests.qemu_img_pipe(*args)), - filters=3D[iotests.filter_test_dir]) + try: + iotests.qemu_img(*args) + except subprocess.CalledProcessError as exc: + check_cipher_support(config, exc.output) + raise =20 def qemu_io_image_args(config, dev=3DFalse): """Get the args for access an image or device with qemu-io""" diff --git a/tests/qemu-iotests/149.out b/tests/qemu-iotests/149.out index ab879596ce..2cc5b82f7c 100644 --- a/tests/qemu-iotests/149.out +++ b/tests/qemu-iotests/149.out @@ -61,7 +61,6 @@ unlink TEST_DIR/luks-aes-256-xts-plain64-sha1.img # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D qemu-img aes-256-xts= -plain64-sha1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Create image qemu-img create -f luks --object secret,id=3Dsec0,data=3DMTIzNDU2,format= =3Dbase64 -o key-secret=3Dsec0,iter-time=3D10,cipher-alg=3Daes-256,cipher-m= ode=3Dxts,ivgen-alg=3Dplain64,hash-alg=3Dsha1 TEST_DIR/luks-aes-256-xts-pla= in64-sha1.img 4194304M - # Open dev sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha1.img = qiotest-145-aes-256-xts-plain64-sha1 # Write test pattern 0xa7 @@ -180,7 +179,6 @@ unlink TEST_DIR/luks-twofish-256-xts-plain64-sha1.img # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D qemu-img twofish-256= -xts-plain64-sha1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Create image qemu-img create -f luks --object secret,id=3Dsec0,data=3DMTIzNDU2,format= =3Dbase64 -o key-secret=3Dsec0,iter-time=3D10,cipher-alg=3Dtwofish-256,ciph= er-mode=3Dxts,ivgen-alg=3Dplain64,hash-alg=3Dsha1 TEST_DIR/luks-twofish-256= -xts-plain64-sha1.img 4194304M - # Open dev sudo cryptsetup -q -v luksOpen TEST_DIR/luks-twofish-256-xts-plain64-sha1.= img qiotest-145-twofish-256-xts-plain64-sha1 # Write test pattern 0xa7 @@ -299,7 +297,6 @@ unlink TEST_DIR/luks-serpent-256-xts-plain64-sha1.img # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D qemu-img serpent-256= -xts-plain64-sha1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Create image qemu-img create -f luks --object secret,id=3Dsec0,data=3DMTIzNDU2,format= =3Dbase64 -o key-secret=3Dsec0,iter-time=3D10,cipher-alg=3Dserpent-256,ciph= er-mode=3Dxts,ivgen-alg=3Dplain64,hash-alg=3Dsha1 TEST_DIR/luks-serpent-256= -xts-plain64-sha1.img 4194304M - # Open dev sudo cryptsetup -q -v luksOpen TEST_DIR/luks-serpent-256-xts-plain64-sha1.= img qiotest-145-serpent-256-xts-plain64-sha1 # Write test pattern 0xa7 @@ -418,7 +415,6 @@ unlink TEST_DIR/luks-cast5-128-cbc-plain64-sha1.img # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D qemu-img cast5-128-c= bc-plain64-sha1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Create image qemu-img create -f luks --object secret,id=3Dsec0,data=3DMTIzNDU2,format= =3Dbase64 -o key-secret=3Dsec0,iter-time=3D10,cipher-alg=3Dcast5-128,cipher= -mode=3Dcbc,ivgen-alg=3Dplain64,hash-alg=3Dsha1 TEST_DIR/luks-cast5-128-cbc= -plain64-sha1.img 4194304M - # Open dev sudo cryptsetup -q -v luksOpen TEST_DIR/luks-cast5-128-cbc-plain64-sha1.im= g qiotest-145-cast5-128-cbc-plain64-sha1 # Write test pattern 0xa7 @@ -538,7 +534,6 @@ unlink TEST_DIR/luks-aes-256-cbc-plain-sha1.img # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D qemu-img aes-256-cbc= -plain-sha1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Create image qemu-img create -f luks --object secret,id=3Dsec0,data=3DMTIzNDU2,format= =3Dbase64 -o key-secret=3Dsec0,iter-time=3D10,cipher-alg=3Daes-256,cipher-m= ode=3Dcbc,ivgen-alg=3Dplain,hash-alg=3Dsha1 TEST_DIR/luks-aes-256-cbc-plain= -sha1.img 4194304M - # Open dev sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-plain-sha1.img qi= otest-145-aes-256-cbc-plain-sha1 # Write test pattern 0xa7 @@ -657,7 +652,6 @@ unlink TEST_DIR/luks-aes-256-cbc-plain64-sha1.img # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D qemu-img aes-256-cbc= -plain64-sha1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Create image qemu-img create -f luks --object secret,id=3Dsec0,data=3DMTIzNDU2,format= =3Dbase64 -o key-secret=3Dsec0,iter-time=3D10,cipher-alg=3Daes-256,cipher-m= ode=3Dcbc,ivgen-alg=3Dplain64,hash-alg=3Dsha1 TEST_DIR/luks-aes-256-cbc-pla= in64-sha1.img 4194304M - # Open dev sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-plain64-sha1.img = qiotest-145-aes-256-cbc-plain64-sha1 # Write test pattern 0xa7 @@ -776,7 +770,6 @@ unlink TEST_DIR/luks-aes-256-cbc-essiv-sha256-sha1.img # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D qemu-img aes-256-cbc= -essiv-sha256-sha1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Create image qemu-img create -f luks --object secret,id=3Dsec0,data=3DMTIzNDU2,format= =3Dbase64 -o key-secret=3Dsec0,iter-time=3D10,cipher-alg=3Daes-256,cipher-m= ode=3Dcbc,ivgen-alg=3Dessiv,hash-alg=3Dsha1,ivgen-hash-alg=3Dsha256 TEST_DI= R/luks-aes-256-cbc-essiv-sha256-sha1.img 4194304M - # Open dev sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-essiv-sha256-sha1= .img qiotest-145-aes-256-cbc-essiv-sha256-sha1 # Write test pattern 0xa7 @@ -895,7 +888,6 @@ unlink TEST_DIR/luks-aes-256-xts-essiv-sha256-sha1.img # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D qemu-img aes-256-xts= -essiv-sha256-sha1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Create image qemu-img create -f luks --object secret,id=3Dsec0,data=3DMTIzNDU2,format= =3Dbase64 -o key-secret=3Dsec0,iter-time=3D10,cipher-alg=3Daes-256,cipher-m= ode=3Dxts,ivgen-alg=3Dessiv,hash-alg=3Dsha1,ivgen-hash-alg=3Dsha256 TEST_DI= R/luks-aes-256-xts-essiv-sha256-sha1.img 4194304M - # Open dev sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-essiv-sha256-sha1= .img qiotest-145-aes-256-xts-essiv-sha256-sha1 # Write test pattern 0xa7 @@ -1014,7 +1006,6 @@ unlink TEST_DIR/luks-aes-128-xts-plain64-sha256-sha1.= img # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D qemu-img aes-128-xts= -plain64-sha256-sha1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Create image qemu-img create -f luks --object secret,id=3Dsec0,data=3DMTIzNDU2,format= =3Dbase64 -o key-secret=3Dsec0,iter-time=3D10,cipher-alg=3Daes-128,cipher-m= ode=3Dxts,ivgen-alg=3Dplain64,hash-alg=3Dsha1 TEST_DIR/luks-aes-128-xts-pla= in64-sha256-sha1.img 4194304M - # Open dev sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-128-xts-plain64-sha256-sh= a1.img qiotest-145-aes-128-xts-plain64-sha256-sha1 # Write test pattern 0xa7 @@ -1133,7 +1124,6 @@ unlink TEST_DIR/luks-aes-192-xts-plain64-sha256-sha1.= img # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D qemu-img aes-192-xts= -plain64-sha256-sha1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Create image qemu-img create -f luks --object secret,id=3Dsec0,data=3DMTIzNDU2,format= =3Dbase64 -o key-secret=3Dsec0,iter-time=3D10,cipher-alg=3Daes-192,cipher-m= ode=3Dxts,ivgen-alg=3Dplain64,hash-alg=3Dsha1 TEST_DIR/luks-aes-192-xts-pla= in64-sha256-sha1.img 4194304M - # Open dev sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-192-xts-plain64-sha256-sh= a1.img qiotest-145-aes-192-xts-plain64-sha256-sha1 # Write test pattern 0xa7 @@ -1252,7 +1242,6 @@ unlink TEST_DIR/luks-twofish-128-xts-plain64-sha1.img # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D qemu-img twofish-128= -xts-plain64-sha1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Create image qemu-img create -f luks --object secret,id=3Dsec0,data=3DMTIzNDU2,format= =3Dbase64 -o key-secret=3Dsec0,iter-time=3D10,cipher-alg=3Dtwofish-128,ciph= er-mode=3Dxts,ivgen-alg=3Dplain64,hash-alg=3Dsha1 TEST_DIR/luks-twofish-128= -xts-plain64-sha1.img 4194304M - # Open dev sudo cryptsetup -q -v luksOpen TEST_DIR/luks-twofish-128-xts-plain64-sha1.= img qiotest-145-twofish-128-xts-plain64-sha1 # Write test pattern 0xa7 @@ -1372,7 +1361,6 @@ unlink TEST_DIR/luks-serpent-128-xts-plain64-sha1.img # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D qemu-img serpent-128= -xts-plain64-sha1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Create image qemu-img create -f luks --object secret,id=3Dsec0,data=3DMTIzNDU2,format= =3Dbase64 -o key-secret=3Dsec0,iter-time=3D10,cipher-alg=3Dserpent-128,ciph= er-mode=3Dxts,ivgen-alg=3Dplain64,hash-alg=3Dsha1 TEST_DIR/luks-serpent-128= -xts-plain64-sha1.img 4194304M - # Open dev sudo cryptsetup -q -v luksOpen TEST_DIR/luks-serpent-128-xts-plain64-sha1.= img qiotest-145-serpent-128-xts-plain64-sha1 # Write test pattern 0xa7 @@ -1491,7 +1479,6 @@ unlink TEST_DIR/luks-serpent-192-xts-plain64-sha1.img # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D qemu-img serpent-192= -xts-plain64-sha1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Create image qemu-img create -f luks --object secret,id=3Dsec0,data=3DMTIzNDU2,format= =3Dbase64 -o key-secret=3Dsec0,iter-time=3D10,cipher-alg=3Dserpent-192,ciph= er-mode=3Dxts,ivgen-alg=3Dplain64,hash-alg=3Dsha1 TEST_DIR/luks-serpent-192= -xts-plain64-sha1.img 4194304M - # Open dev sudo cryptsetup -q -v luksOpen TEST_DIR/luks-serpent-192-xts-plain64-sha1.= img qiotest-145-serpent-192-xts-plain64-sha1 # Write test pattern 0xa7 @@ -1612,7 +1599,6 @@ unlink TEST_DIR/luks-aes-256-xts-plain64-sha224.img # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D qemu-img aes-256-xts= -plain64-sha224 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Create image qemu-img create -f luks --object secret,id=3Dsec0,data=3DMTIzNDU2,format= =3Dbase64 -o key-secret=3Dsec0,iter-time=3D10,cipher-alg=3Daes-256,cipher-m= ode=3Dxts,ivgen-alg=3Dplain64,hash-alg=3Dsha224 TEST_DIR/luks-aes-256-xts-p= lain64-sha224.img 4194304M - # Open dev sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha224.im= g qiotest-145-aes-256-xts-plain64-sha224 # Write test pattern 0xa7 @@ -1731,7 +1717,6 @@ unlink TEST_DIR/luks-aes-256-xts-plain64-sha256.img # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D qemu-img aes-256-xts= -plain64-sha256 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Create image qemu-img create -f luks --object secret,id=3Dsec0,data=3DMTIzNDU2,format= =3Dbase64 -o key-secret=3Dsec0,iter-time=3D10,cipher-alg=3Daes-256,cipher-m= ode=3Dxts,ivgen-alg=3Dplain64,hash-alg=3Dsha256 TEST_DIR/luks-aes-256-xts-p= lain64-sha256.img 4194304M - # Open dev sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha256.im= g qiotest-145-aes-256-xts-plain64-sha256 # Write test pattern 0xa7 @@ -1850,7 +1835,6 @@ unlink TEST_DIR/luks-aes-256-xts-plain64-sha384.img # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D qemu-img aes-256-xts= -plain64-sha384 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Create image qemu-img create -f luks --object secret,id=3Dsec0,data=3DMTIzNDU2,format= =3Dbase64 -o key-secret=3Dsec0,iter-time=3D10,cipher-alg=3Daes-256,cipher-m= ode=3Dxts,ivgen-alg=3Dplain64,hash-alg=3Dsha384 TEST_DIR/luks-aes-256-xts-p= lain64-sha384.img 4194304M - # Open dev sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha384.im= g qiotest-145-aes-256-xts-plain64-sha384 # Write test pattern 0xa7 @@ -1969,7 +1953,6 @@ unlink TEST_DIR/luks-aes-256-xts-plain64-sha512.img # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D qemu-img aes-256-xts= -plain64-sha512 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Create image qemu-img create -f luks --object secret,id=3Dsec0,data=3DMTIzNDU2,format= =3Dbase64 -o key-secret=3Dsec0,iter-time=3D10,cipher-alg=3Daes-256,cipher-m= ode=3Dxts,ivgen-alg=3Dplain64,hash-alg=3Dsha512 TEST_DIR/luks-aes-256-xts-p= lain64-sha512.img 4194304M - # Open dev sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha512.im= g qiotest-145-aes-256-xts-plain64-sha512 # Write test pattern 0xa7 @@ -2088,7 +2071,6 @@ unlink TEST_DIR/luks-aes-256-xts-plain64-ripemd160.img # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D qemu-img aes-256-xts= -plain64-ripemd160 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Create image qemu-img create -f luks --object secret,id=3Dsec0,data=3DMTIzNDU2,format= =3Dbase64 -o key-secret=3Dsec0,iter-time=3D10,cipher-alg=3Daes-256,cipher-m= ode=3Dxts,ivgen-alg=3Dplain64,hash-alg=3Dripemd160 TEST_DIR/luks-aes-256-xt= s-plain64-ripemd160.img 4194304M - # Open dev sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-ripemd160= .img qiotest-145-aes-256-xts-plain64-ripemd160 # Write test pattern 0xa7 @@ -2281,7 +2263,6 @@ unlink TEST_DIR/luks-aes-256-xts-plain-sha1-pwallslot= s.img # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D qemu-img aes-256-xts= -plain-sha1-pwallslots =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Create image qemu-img create -f luks --object secret,id=3Dsec0,data=3Dc2xvdDE=3D,format= =3Dbase64 -o key-secret=3Dsec0,iter-time=3D10,cipher-alg=3Daes-256,cipher-m= ode=3Dxts,ivgen-alg=3Dplain,hash-alg=3Dsha1 TEST_DIR/luks-aes-256-xts-plain= -sha1-pwallslots.img 4194304M - # Open dev sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain-sha1-pwalls= lots.img qiotest-145-aes-256-xts-plain-sha1-pwallslots # Write test pattern 0xa7 @@ -2400,7 +2381,6 @@ unlink TEST_DIR/luks-aes-256-cbc-essiv-auto-sha1.img # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D qemu-img aes-256-cbc= -essiv-auto-sha1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Create image qemu-img create -f luks --object secret,id=3Dsec0,data=3DMTIzNDU2,format= =3Dbase64 -o key-secret=3Dsec0,iter-time=3D10,cipher-alg=3Daes-256,cipher-m= ode=3Dcbc,ivgen-alg=3Dessiv,hash-alg=3Dsha1 TEST_DIR/luks-aes-256-cbc-essiv= -auto-sha1.img 4194304M - # Open dev sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-essiv-auto-sha1.i= mg qiotest-145-aes-256-cbc-essiv-auto-sha1 # Write test pattern 0xa7 @@ -2519,7 +2499,6 @@ unlink TEST_DIR/luks-aes-256-cbc-plain64-sha256-sha1.= img # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D qemu-img aes-256-cbc= -plain64-sha256-sha1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Create image qemu-img create -f luks --object secret,id=3Dsec0,data=3DMTIzNDU2,format= =3Dbase64 -o key-secret=3Dsec0,iter-time=3D10,cipher-alg=3Daes-256,cipher-m= ode=3Dcbc,ivgen-alg=3Dplain64,hash-alg=3Dsha1,ivgen-hash-alg=3Dsha256 TEST_= DIR/luks-aes-256-cbc-plain64-sha256-sha1.img 4194304M - # Open dev sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-plain64-sha256-sh= a1.img qiotest-145-aes-256-cbc-plain64-sha256-sha1 # Write test pattern 0xa7 --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647951130703996.0616194531309; Tue, 22 Mar 2022 05:12:10 -0700 (PDT) Received: from localhost ([::1]:42322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWdMu-0004NT-EO for importer@patchew.org; Tue, 22 Mar 2022 08:12:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8h-0003IC-L7 for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36805) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8f-0006VF-EZ for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:27 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-652-U372qTB1Oh2d5blYSWo89w-1; Tue, 22 Mar 2022 07:57:21 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7BDAF803B22; Tue, 22 Mar 2022 11:57:21 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 370E040CFD01; Tue, 22 Mar 2022 11:57:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950244; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i3FiW9dyi/ToJO1Zs0c5Tcxq+BKcXbz++TOqGeQszl8=; b=Jk4eK5MHjkKjwgUgGr7PnGRmNnqnpyoh9y+ub65WF1nZ7DVVwFi2na6whk9GFvws++4ba4 UjkUPfrYgVR0PWle9JhC6ObKPK9AlQwAIRWv/KGnm2MIt91ZmrcEgV39fDKwJ/5njkG5IX w/CyFYOyA+I29oUl4FhZM9Zg3zERBew= X-MC-Unique: U372qTB1Oh2d5blYSWo89w-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 19/25] iotests: remove remaining calls to qemu_img_pipe() Date: Tue, 22 Mar 2022 12:56:41 +0100 Message-Id: <20220322115647.726044-20-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647951132129100001 Content-Type: text/plain; charset="utf-8" From: John Snow As part of moving all python iotest invocations of qemu-img onto a single qemu_img() implementation, remove a few lingering uses of qemu_img_pipe() from outside of iotests.py itself. Several cases here rely on the knowledge that qemu_img_pipe() suppresses *all* output on a successful case when the command being issued is 'create'. 065: This call's output is inspected, but it appears as if it's expected to succeed. Replace this call with the checked qemu_img() variant instead to get better diagnostics if/when qemu-img itself fails. 237: "create" call output isn't actually logged. Use qemu_img_create() instead, which checks the return code. Remove the empty lines from the test output. 296: Two calls; -create: Expected to succeed. Like other create calls, the output isn't actually logged. Switch to a checked variant (qemu_img_create) instead. The output for this test is a mixture of both test styles, so actually replace the blank line for readability. -amend: This is expected to fail. Log the output. After this patch, the only uses of qemu_img_pipe are internal to iotests.py and will be removed in subsequent patches. Signed-off-by: John Snow Reviewed-by: Hanna Reitz Message-Id: <20220321201618.903471-15-jsnow@redhat.com> Signed-off-by: Hanna Reitz --- tests/qemu-iotests/065 | 4 ++-- tests/qemu-iotests/237 | 3 +-- tests/qemu-iotests/237.out | 3 --- tests/qemu-iotests/296 | 12 ++++++------ 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/tests/qemu-iotests/065 b/tests/qemu-iotests/065 index 9466ce7df4..ba94e19349 100755 --- a/tests/qemu-iotests/065 +++ b/tests/qemu-iotests/065 @@ -24,7 +24,7 @@ import os import re import json import iotests -from iotests import qemu_img, qemu_img_info, qemu_img_pipe +from iotests import qemu_img, qemu_img_info import unittest =20 test_img =3D os.path.join(iotests.test_dir, 'test.img') @@ -54,7 +54,7 @@ class TestQemuImgInfo(TestImageInfoSpecific): self.assertEqual(data['data'], self.json_compare) =20 def test_human(self): - data =3D qemu_img_pipe('info', '--output=3Dhuman', test_img).split= ('\n') + data =3D qemu_img('info', '--output=3Dhuman', test_img).stdout.spl= it('\n') data =3D data[(data.index('Format specific information:') + 1) :data.index('')] for field in data: diff --git a/tests/qemu-iotests/237 b/tests/qemu-iotests/237 index 43dfd3bd40..5ea13eb01f 100755 --- a/tests/qemu-iotests/237 +++ b/tests/qemu-iotests/237 @@ -165,8 +165,7 @@ with iotests.FilePath('t.vmdk') as disk_path, \ iotests.log("") =20 for path in [ extent1_path, extent2_path, extent3_path ]: - msg =3D iotests.qemu_img_pipe('create', '-f', imgfmt, path, '0') - iotests.log(msg, [iotests.filter_testfiles]) + iotests.qemu_img_create('-f', imgfmt, path, '0') =20 vm.add_blockdev('driver=3Dfile,filename=3D%s,node-name=3Dext1' % (exte= nt1_path)) vm.add_blockdev('driver=3Dfile,filename=3D%s,node-name=3Dext2' % (exte= nt2_path)) diff --git a/tests/qemu-iotests/237.out b/tests/qemu-iotests/237.out index aeb9724492..62b8865677 100644 --- a/tests/qemu-iotests/237.out +++ b/tests/qemu-iotests/237.out @@ -129,9 +129,6 @@ Job failed: Cannot find device=3D'this doesn't exist' n= or node-name=3D'this doesn't =20 =3D=3D=3D Other subformats =3D=3D=3D =20 - - - =3D=3D Missing extent =3D=3D =20 {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "vmdk", "file": "node0", "size": 33554432, "subformat": "monolit= hicFlat"}}} diff --git a/tests/qemu-iotests/296 b/tests/qemu-iotests/296 index f80ef3434a..0d21b740a7 100755 --- a/tests/qemu-iotests/296 +++ b/tests/qemu-iotests/296 @@ -76,7 +76,7 @@ class EncryptionSetupTestCase(iotests.QMPTestCase): # create the encrypted block device using qemu-img def createImg(self, file, secret): =20 - output =3D iotests.qemu_img_pipe( + iotests.qemu_img( 'create', '--object', *secret.to_cmdline_object(), '-f', iotests.imgfmt, @@ -84,8 +84,7 @@ class EncryptionSetupTestCase(iotests.QMPTestCase): '-o', 'iter-time=3D10', file, '1M') - - iotests.log(output, filters=3D[iotests.filter_test_dir]) + iotests.log('') =20 # attempts to add a key using qemu-img def addKey(self, file, secret, new_secret): @@ -99,7 +98,7 @@ class EncryptionSetupTestCase(iotests.QMPTestCase): } } =20 - output =3D iotests.qemu_img_pipe( + output =3D iotests.qemu_img( 'amend', '--object', *secret.to_cmdline_object(), '--object', *new_secret.to_cmdline_object(), @@ -108,8 +107,9 @@ class EncryptionSetupTestCase(iotests.QMPTestCase): '-o', 'new-secret=3D' + new_secret.id(), '-o', 'iter-time=3D10', =20 - "json:" + json.dumps(image_options) - ) + "json:" + json.dumps(image_options), + check=3DFalse # Expected to fail. Log output. + ).stdout =20 iotests.log(output, filters=3D[iotests.filter_test_dir]) =20 --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647951025227143.1180435861378; Tue, 22 Mar 2022 05:10:25 -0700 (PDT) Received: from localhost ([::1]:37666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWdLF-00018A-Nn for importer@patchew.org; Tue, 22 Mar 2022 08:10:25 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59588) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8g-0003GB-V9 for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29394) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8f-0006VB-5Q for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:26 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-173-Sxz9VhdoMWia8mOxquzf-w-1; Tue, 22 Mar 2022 07:57:23 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 14FBD85A5BC; Tue, 22 Mar 2022 11:57:23 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C5F84778B; Tue, 22 Mar 2022 11:57:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950244; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/z84npdETHiGGDFh2NME+P3IwgPAl3Hi7h0aFNjt9gE=; b=CtsOZB/0gARZTudotsjqHruR6QMMAcxWjRaC9/f1IGzOU2M0gRmZBnTSwajkiQloQCRQsz +nPdhSPQoRoZHRTEeZxYy/N+8k/hU0gMz7xbm9IkQJyBjmGfi4A4eMeNZb7mVgyjBFyKcI HOHFCSaYqqEMtvpOr7rSBSY58KZ4UbQ= X-MC-Unique: Sxz9VhdoMWia8mOxquzf-w-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 20/25] iotests: use qemu_img() in has_working_luks() Date: Tue, 22 Mar 2022 12:56:42 +0100 Message-Id: <20220322115647.726044-21-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647951043797100001 Content-Type: text/plain; charset="utf-8" From: John Snow Admittedly a mostly lateral move, but qemu_img() is essentially the replacement for qemu_img_pipe_and_status(). It will give slightly better diagnostics on crash. Signed-off-by: John Snow Reviewed-by: Hanna Reitz Message-Id: <20220321201618.903471-16-jsnow@redhat.com> Signed-off-by: Hanna Reitz --- tests/qemu-iotests/iotests.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index aaf4da8be4..d006f56127 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -1445,20 +1445,20 @@ def has_working_luks() -> Tuple[bool, str]: """ =20 img_file =3D f'{test_dir}/luks-test.luks' - (output, status) =3D \ - qemu_img_pipe_and_status('create', '-f', 'luks', - '--object', luks_default_secret_object, - '-o', luks_default_key_secret_opt, - '-o', 'iter-time=3D10', - img_file, '1G') + res =3D qemu_img('create', '-f', 'luks', + '--object', luks_default_secret_object, + '-o', luks_default_key_secret_opt, + '-o', 'iter-time=3D10', + img_file, '1G', + check=3DFalse) try: os.remove(img_file) except OSError: pass =20 - if status !=3D 0: - reason =3D output - for line in output.splitlines(): + if res.returncode: + reason =3D res.stdout + for line in res.stdout.splitlines(): if img_file + ':' in line: reason =3D line.split(img_file + ':', 1)[1].strip() break --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647951604076723.5347873436838; Tue, 22 Mar 2022 05:20:04 -0700 (PDT) Received: from localhost ([::1]:53350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWdUZ-0003rI-0p for importer@patchew.org; Tue, 22 Mar 2022 08:20:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8l-0003Qk-2r for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:35705) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8i-0006XB-LW for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:30 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-403-Y9lrb4Z6P2WyjgBN3Ep2_w-1; Tue, 22 Mar 2022 07:57:25 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B89121C04B5F; Tue, 22 Mar 2022 11:57:24 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 545EE400E54A; Tue, 22 Mar 2022 11:57:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950248; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iS3BtLoCzcRjS57tPU0kBHul11WGdwxkp7b3ZNP7CdI=; b=SNRJ5cEOFGsmZr/szMw7+fbA5EllyF8QQIVCtXsUb0j7jD/p2rkOOjTJe7Rjpx0L5LwpYr WfaU3mlITItd9ssC0sZ2PsF/PVhg3IYSl+D7MHAaOS1yOlIi8Yx9QtKQlzLOHMmLc5BM8x 0gt0c6pD7iWtQu7MQxYRvuRHShJp0Wo= X-MC-Unique: Y9lrb4Z6P2WyjgBN3Ep2_w-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 21/25] iotests: replace qemu_img_log('create', ...) calls Date: Tue, 22 Mar 2022 12:56:43 +0100 Message-Id: <20220322115647.726044-22-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647951604672100001 Content-Type: text/plain; charset="utf-8" From: John Snow qemu_img_log() calls into qemu_img_pipe(), which always removes output for 'create' commands on success anyway. Replace all of these calls to the simpler qemu_img_create(...) which doesn't log, but raises a detailed exception object on failure instead. Blank lines are removed from output files where appropriate. Signed-off-by: John Snow Reviewed-by: Hanna Reitz Message-Id: <20220321201618.903471-17-jsnow@redhat.com> Signed-off-by: Hanna Reitz --- tests/qemu-iotests/255 | 8 ++++---- tests/qemu-iotests/255.out | 4 ---- tests/qemu-iotests/274 | 17 ++++++++--------- tests/qemu-iotests/274.out | 29 ----------------------------- tests/qemu-iotests/280 | 2 +- tests/qemu-iotests/280.out | 1 - 6 files changed, 13 insertions(+), 48 deletions(-) diff --git a/tests/qemu-iotests/255 b/tests/qemu-iotests/255 index 3d6d0e80cb..f86fa851b6 100755 --- a/tests/qemu-iotests/255 +++ b/tests/qemu-iotests/255 @@ -42,8 +42,8 @@ with iotests.FilePath('t.qcow2') as disk_path, \ size_str =3D str(size) =20 iotests.create_image(base_path, size) - iotests.qemu_img_log('create', '-f', iotests.imgfmt, mid_path, size_st= r) - iotests.qemu_img_log('create', '-f', iotests.imgfmt, disk_path, size_s= tr) + iotests.qemu_img_create('-f', iotests.imgfmt, mid_path, size_str) + iotests.qemu_img_create('-f', iotests.imgfmt, disk_path, size_str) =20 # Create a backing chain like this: # base <- [throttled: bps-read=3D4096] <- mid <- overlay @@ -92,8 +92,8 @@ with iotests.FilePath('src.qcow2') as src_path, \ size =3D 128 * 1024 * 1024 size_str =3D str(size) =20 - iotests.qemu_img_log('create', '-f', iotests.imgfmt, src_path, size_st= r) - iotests.qemu_img_log('create', '-f', iotests.imgfmt, dst_path, size_st= r) + iotests.qemu_img_create('-f', iotests.imgfmt, src_path, size_str) + iotests.qemu_img_create('-f', iotests.imgfmt, dst_path, size_str) =20 iotests.log(iotests.qemu_io('-f', iotests.imgfmt, '-c', 'write 0 1M', src_path), diff --git a/tests/qemu-iotests/255.out b/tests/qemu-iotests/255.out index 11a05a5213..2e837cbb5f 100644 --- a/tests/qemu-iotests/255.out +++ b/tests/qemu-iotests/255.out @@ -3,8 +3,6 @@ Finishing a commit job with background reads =20 =3D=3D=3D Create backing chain and start VM =3D=3D=3D =20 - - =3D=3D=3D Start background read requests =3D=3D=3D =20 =3D=3D=3D Run a commit job =3D=3D=3D @@ -21,8 +19,6 @@ Closing the VM while a job is being cancelled =20 =3D=3D=3D Create images and start VM =3D=3D=3D =20 - - wrote 1048576/1048576 bytes at offset 0 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 diff --git a/tests/qemu-iotests/274 b/tests/qemu-iotests/274 index 080a90f10f..2495e051a2 100755 --- a/tests/qemu-iotests/274 +++ b/tests/qemu-iotests/274 @@ -31,12 +31,11 @@ size_long =3D 2 * 1024 * 1024 size_diff =3D size_long - size_short =20 def create_chain() -> None: - iotests.qemu_img_log('create', '-f', iotests.imgfmt, base, - str(size_long)) - iotests.qemu_img_log('create', '-f', iotests.imgfmt, '-b', base, - '-F', iotests.imgfmt, mid, str(size_short)) - iotests.qemu_img_log('create', '-f', iotests.imgfmt, '-b', mid, - '-F', iotests.imgfmt, top, str(size_long)) + iotests.qemu_img_create('-f', iotests.imgfmt, base, str(size_long)) + iotests.qemu_img_create('-f', iotests.imgfmt, '-b', base, + '-F', iotests.imgfmt, mid, str(size_short)) + iotests.qemu_img_create('-f', iotests.imgfmt, '-b', mid, + '-F', iotests.imgfmt, top, str(size_long)) =20 iotests.qemu_io_log('-c', 'write -P 1 0 %d' % size_long, base) =20 @@ -160,9 +159,9 @@ with iotests.FilePath('base') as base, \ ('off', '512k', '256k', '500k', '436k')]: =20 iotests.log('=3D=3D=3D preallocation=3D%s =3D=3D=3D' % prealloc) - iotests.qemu_img_log('create', '-f', iotests.imgfmt, base, base_si= ze) - iotests.qemu_img_log('create', '-f', iotests.imgfmt, '-b', base, - '-F', iotests.imgfmt, top, top_size_old) + iotests.qemu_img_create('-f', iotests.imgfmt, base, base_size) + iotests.qemu_img_create('-f', iotests.imgfmt, '-b', base, + '-F', iotests.imgfmt, top, top_size_old) iotests.qemu_io_log('-c', 'write -P 1 %s 64k' % off, base) =20 # After this, top_size_old to base_size should be allocated/zeroed. diff --git a/tests/qemu-iotests/274.out b/tests/qemu-iotests/274.out index 1ce40d839a..acd8b166a6 100644 --- a/tests/qemu-iotests/274.out +++ b/tests/qemu-iotests/274.out @@ -1,7 +1,4 @@ =3D=3D Commit tests =3D=3D - - - wrote 2097152/2097152 bytes at offset 0 2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 @@ -63,9 +60,6 @@ read 1048576/1048576 bytes at offset 1048576 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 =3D=3D=3D Testing HMP commit (top -> mid) =3D=3D=3D - - - wrote 2097152/2097152 bytes at offset 0 2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 @@ -92,9 +86,6 @@ read 1048576/1048576 bytes at offset 1048576 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 =3D=3D=3D Testing QMP active commit (top -> mid) =3D=3D=3D - - - wrote 2097152/2097152 bytes at offset 0 2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 @@ -127,9 +118,6 @@ read 1048576/1048576 bytes at offset 1048576 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 =3D=3D=3D Testing qemu-img commit (top -> base) =3D=3D=3D - - - wrote 2097152/2097152 bytes at offset 0 2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 @@ -154,9 +142,6 @@ read 1048576/1048576 bytes at offset 1048576 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 =3D=3D=3D Testing QMP active commit (top -> base) =3D=3D=3D - - - wrote 2097152/2097152 bytes at offset 0 2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 @@ -190,8 +175,6 @@ read 1048576/1048576 bytes at offset 1048576 =20 =3D=3D Resize tests =3D=3D =3D=3D=3D preallocation=3Doff =3D=3D=3D - - wrote 65536/65536 bytes at offset 5368709120 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 @@ -207,8 +190,6 @@ read 65536/65536 bytes at offset 5368709120 { "start": 1073741824, "length": 7516192768, "depth": 0, "present": true, = "zero": true, "data": false}] =20 =3D=3D=3D preallocation=3Dmetadata =3D=3D=3D - - wrote 65536/65536 bytes at offset 33285996544 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 @@ -229,8 +210,6 @@ read 65536/65536 bytes at offset 33285996544 { "start": 34896609280, "length": 536870912, "depth": 0, "present": true, = "zero": true, "data": false, "offset": 2685075456}] =20 =3D=3D=3D preallocation=3Dfalloc =3D=3D=3D - - wrote 65536/65536 bytes at offset 9437184 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 @@ -246,8 +225,6 @@ read 65536/65536 bytes at offset 9437184 { "start": 5242880, "length": 10485760, "depth": 0, "present": true, "zero= ": false, "data": true, "offset": 327680}] =20 =3D=3D=3D preallocation=3Dfull =3D=3D=3D - - wrote 65536/65536 bytes at offset 11534336 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 @@ -263,8 +240,6 @@ read 65536/65536 bytes at offset 11534336 { "start": 8388608, "length": 4194304, "depth": 0, "present": true, "zero"= : false, "data": true, "offset": 327680}] =20 =3D=3D=3D preallocation=3Doff =3D=3D=3D - - wrote 65536/65536 bytes at offset 259072 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 @@ -281,8 +256,6 @@ read 65536/65536 bytes at offset 259072 { "start": 262144, "length": 262144, "depth": 0, "present": true, "zero": = true, "data": false}] =20 =3D=3D=3D preallocation=3Doff =3D=3D=3D - - wrote 65536/65536 bytes at offset 344064 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 @@ -298,8 +271,6 @@ read 65536/65536 bytes at offset 344064 { "start": 262144, "length": 262144, "depth": 0, "present": true, "zero": = true, "data": false}] =20 =3D=3D=3D preallocation=3Doff =3D=3D=3D - - wrote 65536/65536 bytes at offset 446464 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 diff --git a/tests/qemu-iotests/280 b/tests/qemu-iotests/280 index 628f3c33ca..5f50500fdb 100755 --- a/tests/qemu-iotests/280 +++ b/tests/qemu-iotests/280 @@ -33,7 +33,7 @@ with iotests.FilePath('base') as base_path , \ iotests.FilePath('top') as top_path, \ iotests.VM() as vm: =20 - iotests.qemu_img_log('create', '-f', iotests.imgfmt, base_path, '64M') + iotests.qemu_img_create('-f', iotests.imgfmt, base_path, '64M') =20 iotests.log('=3D=3D=3D Launch VM =3D=3D=3D') vm.add_object('iothread,id=3Diothread0') diff --git a/tests/qemu-iotests/280.out b/tests/qemu-iotests/280.out index e39164c579..c75f437c00 100644 --- a/tests/qemu-iotests/280.out +++ b/tests/qemu-iotests/280.out @@ -1,4 +1,3 @@ - =3D=3D=3D Launch VM =3D=3D=3D Enabling migration QMP events on VM... {"return": {}} --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16479511858171023.4074345627938; Tue, 22 Mar 2022 05:13:05 -0700 (PDT) Received: from localhost ([::1]:44060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWdNo-0005ZF-Bc for importer@patchew.org; Tue, 22 Mar 2022 08:13:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8k-0003Pk-2c for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:43418) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8i-0006X5-87 for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:29 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-253-tGbnybd6O0GY689aOvku7w-1; Tue, 22 Mar 2022 07:57:26 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4CA973801EC4; Tue, 22 Mar 2022 11:57:26 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 068B61121314; Tue, 22 Mar 2022 11:57:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950247; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Hxa0Atc6mxnf9pqzb/UvncJLg3k9vxIvOUSksLw490c=; b=D5WfNAquNZfQ5qu2ZTGxiAuSpRItq3nZuWNqe6ZFap0JDVIxamMIh8vvwZqVAYzjFG1lVk qu517iEaONqQ/SAM/QaDIPY/5nwHJt/rB7L0XIIPINWivOoU7LsCENchiz8voVoalYZJt/ gLqdz4gtqSdU5V+hIkfKuQnuE8iFmMA= X-MC-Unique: tGbnybd6O0GY689aOvku7w-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 22/25] iotests: remove qemu_img_pipe_and_status() Date: Tue, 22 Mar 2022 12:56:44 +0100 Message-Id: <20220322115647.726044-23-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647951186506100001 Content-Type: text/plain; charset="utf-8" From: John Snow With the exceptional 'create' calls removed in the prior commit, change qemu_img_log() and img_info_log() to call qemu_img() directly instead. For now, allow these calls to qemu-img to return non-zero on the basis that any unusual output will be logged anyway. The very next commit begins to enforce a successful exit code by default even for the logged functions. Signed-off-by: John Snow Message-Id: <20220321201618.903471-18-jsnow@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Hanna Reitz --- tests/qemu-iotests/iotests.py | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index d006f56127..1771d01977 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -207,15 +207,6 @@ def qemu_img_create_prepare_args(args: List[str]) -> L= ist[str]: =20 return result =20 -def qemu_img_pipe_and_status(*args: str) -> Tuple[str, int]: - """ - Run qemu-img and return both its output and its exit code - """ - is_create =3D bool(args and args[0] =3D=3D 'create') - full_args =3D qemu_img_args + qemu_img_create_prepare_args(list(args)) - return qemu_tool_pipe_and_status('qemu-img', full_args, - drop_successful_output=3Dis_create) - def qemu_img(*args: str, check: bool =3D True, combine_stdio: bool =3D True ) -> 'subprocess.CompletedProcess[str]': """ @@ -321,17 +312,14 @@ def qemu_img_info(*args: str) -> Any: def qemu_img_map(*args: str) -> Any: return qemu_img_json('map', "--output", "json", *args) =20 -def qemu_img_pipe(*args: str) -> str: - '''Run qemu-img and return its output''' - return qemu_img_pipe_and_status(*args)[0] - -def qemu_img_log(*args): - result =3D qemu_img_pipe(*args) - log(result, filters=3D[filter_testfiles]) +def qemu_img_log(*args: str) -> 'subprocess.CompletedProcess[str]': + result =3D qemu_img(*args, check=3DFalse) + log(result.stdout, filters=3D[filter_testfiles]) return result =20 -def img_info_log(filename, filter_path=3DNone, use_image_opts=3DFalse, - extra_args=3D()): +def img_info_log(filename: str, filter_path: Optional[str] =3D None, + use_image_opts: bool =3D False, extra_args: Sequence[str]= =3D (), + ) -> None: args =3D ['info'] if use_image_opts: args.append('--image-opts') @@ -340,7 +328,7 @@ def img_info_log(filename, filter_path=3DNone, use_imag= e_opts=3DFalse, args +=3D extra_args args.append(filename) =20 - output =3D qemu_img_pipe(*args) + output =3D qemu_img(*args, check=3DFalse).stdout if not filter_path: filter_path =3D filename log(filter_img_info(output, filter_path)) --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647951496972121.25967676485641; Tue, 22 Mar 2022 05:18:16 -0700 (PDT) Received: from localhost ([::1]:50922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWdSr-0001xc-HS for importer@patchew.org; Tue, 22 Mar 2022 08:18:17 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59704) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8l-0003R8-Ny for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22915) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8k-0006XY-4j for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:31 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-374-8Aaz8NerM7GX01CEIJ7Hsg-1; Tue, 22 Mar 2022 07:57:28 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F1FAE185A794; Tue, 22 Mar 2022 11:57:27 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AFE702166B2D; Tue, 22 Mar 2022 11:57:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950249; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LxdXr/VkIT+V2Iz0sh7H2LmlzExFpzY7QPZdcuLJk8Y=; b=NK1M9N+3tBuQdT0txt0loknGNHDwgFrr6J5CoRcnRT5mbEa6gHJ5wAkPtQjap4j7FUmL6W 1Vp2zxXy3wlUSCicM/2wLLpr5INEOBIAL3I+9Mso0+GP4dmTDFxBlWSlipF989v16ciHLv 3Nb9vj2KrRaGexAGsEutL8ZTfz18dOc= X-MC-Unique: 8Aaz8NerM7GX01CEIJ7Hsg-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 23/25] iotests: make qemu_img_log and img_info_log raise on error Date: Tue, 22 Mar 2022 12:56:45 +0100 Message-Id: <20220322115647.726044-24-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647951525956100003 Content-Type: text/plain; charset="utf-8" From: John Snow Add a `check: bool =3D True` parameter to both functions and make their qemu_img() invocations raise on error by default. users of img_info_log: 206, 207, 210, 211, 212, 213, 237, 242, 266, 274, 302 users of qemu_img_log: 044, 209, 274, 302, 304 iotests 242 and 266 need to use check=3DFalse for their negative tests. iotests 206, 210, 211, 212, 213, 237, 274 and 302 continue working normally. As of this commit, all calls to QEMU_IMG made from iotests enforce a return code of zero by default unless explicitly disabled or suppressed by passing check=3DFalse or with an exception handler. Signed-off-by: John Snow Message-Id: <20220321201618.903471-19-jsnow@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Hanna Reitz --- tests/qemu-iotests/242 | 2 +- tests/qemu-iotests/266 | 2 +- tests/qemu-iotests/iotests.py | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/qemu-iotests/242 b/tests/qemu-iotests/242 index 547bf382e3..b3afd36d72 100755 --- a/tests/qemu-iotests/242 +++ b/tests/qemu-iotests/242 @@ -100,7 +100,7 @@ add_bitmap(1, True, False) log('Write an unknown bitmap flag \'{}\' into a new QCOW2 image at offset = {}' .format(hex(bitmap_flag_unknown), flag_offset)) toggle_flag(flag_offset) -img_info_log(disk) +img_info_log(disk, check=3DFalse) toggle_flag(flag_offset) log('Unset the unknown bitmap flag \'{}\' in the bitmap directory entry:\n' .format(hex(bitmap_flag_unknown))) diff --git a/tests/qemu-iotests/266 b/tests/qemu-iotests/266 index 71ce81d0df..8fc3807ac5 100755 --- a/tests/qemu-iotests/266 +++ b/tests/qemu-iotests/266 @@ -137,7 +137,7 @@ def main(): iotests.log('') =20 vm.shutdown() - iotests.img_info_log(file_path) + iotests.img_info_log(file_path, check=3DFalse) =20 =20 iotests.script_main(main, diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 1771d01977..4b788c7491 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -312,13 +312,15 @@ def qemu_img_info(*args: str) -> Any: def qemu_img_map(*args: str) -> Any: return qemu_img_json('map', "--output", "json", *args) =20 -def qemu_img_log(*args: str) -> 'subprocess.CompletedProcess[str]': - result =3D qemu_img(*args, check=3DFalse) +def qemu_img_log(*args: str, check: bool =3D True + ) -> 'subprocess.CompletedProcess[str]': + result =3D qemu_img(*args, check=3Dcheck) log(result.stdout, filters=3D[filter_testfiles]) return result =20 def img_info_log(filename: str, filter_path: Optional[str] =3D None, use_image_opts: bool =3D False, extra_args: Sequence[str]= =3D (), + check: bool =3D True, ) -> None: args =3D ['info'] if use_image_opts: @@ -328,7 +330,7 @@ def img_info_log(filename: str, filter_path: Optional[s= tr] =3D None, args +=3D extra_args args.append(filename) =20 - output =3D qemu_img(*args, check=3DFalse).stdout + output =3D qemu_img(*args, check=3Dcheck).stdout if not filter_path: filter_path =3D filename log(filter_img_info(output, filter_path)) --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164795131737632.50343301279986; Tue, 22 Mar 2022 05:15:17 -0700 (PDT) Received: from localhost ([::1]:47686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWdPx-00083A-Rp for importer@patchew.org; Tue, 22 Mar 2022 08:15:18 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59740) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8n-0003RA-Aj for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33732) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8l-0006Xu-Kb for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:33 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-134--mShUXKBMh2TqzL-jXhWnw-1; Tue, 22 Mar 2022 07:57:29 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 870691C04B60; Tue, 22 Mar 2022 11:57:29 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 439624010A1C; Tue, 22 Mar 2022 11:57:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950251; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x/nWOWZ4rJg8/bzrORM6fWx6B4c3zOa/QO5cgrz63tE=; b=MHNfGEF+j53B/eVBUqVUDzo4wqtTk6RNihV1IMZsF2W0D5Ed+8c9GQKyBVAYBsvnguMfRN JWEUQud/Z5O+biX+/VOSi0ROIbVWQSTioU5NkYeAZjfk7+LvBZSL8amKrAsWO+/h0VFLe4 2PsfibvPS+H5Y+4lhp3zdIJtb/nicWI= X-MC-Unique: -mShUXKBMh2TqzL-jXhWnw-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 24/25] iotests.py: Filters for VM.run_job() Date: Tue, 22 Mar 2022 12:56:46 +0100 Message-Id: <20220322115647.726044-25-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647951345417100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Allow filters for VM.run_job(), and pass the filters given to VM.blockdev_create() to it. (Use this opportunity to annotate VM.run_job()'s parameter types; unfortunately, for the filter, I could not come up with anything better than Callable[[Any], Any] that would pass mypy's scrutiny.) At one point, a plain string is logged, so the filters passed to it must work fine with plain strings. The only filters passed to it at this point are the ones from VM.blockdev_create(), which are filter_qmp_test_files() (by default) and 207's filter_hash(). Both cannot handle plain strings yet, but we can make them by amending filter_qmp() to treat them as plain values with a None key. Signed-off-by: Hanna Reitz Message-Id: <20220318125304.66131-2-hreitz@redhat.com> Reviewed-by: John Snow --- tests/qemu-iotests/iotests.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 4b788c7491..fcec3e51e5 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -607,8 +607,10 @@ def filter_qmp(qmsg, filter_fn): # Iterate through either lists or dicts; if isinstance(qmsg, list): items =3D enumerate(qmsg) - else: + elif isinstance(qmsg, dict): items =3D qmsg.items() + else: + return filter_fn(None, qmsg) =20 for k, v in items: if isinstance(v, (dict, list)): @@ -944,8 +946,12 @@ def qmp_log(self, cmd, filters=3D(), indent=3DNone, **= kwargs): return result =20 # Returns None on success, and an error string on failure - def run_job(self, job, auto_finalize=3DTrue, auto_dismiss=3DFalse, - pre_finalize=3DNone, cancel=3DFalse, wait=3D60.0): + def run_job(self, job: str, auto_finalize: bool =3D True, + auto_dismiss: bool =3D False, + pre_finalize: Optional[Callable[[], None]] =3D None, + cancel: bool =3D False, wait: float =3D 60.0, + filters: Iterable[Callable[[Any], Any]] =3D (), + ) -> Optional[str]: """ run_job moves a job from creation through to dismissal. =20 @@ -975,7 +981,7 @@ def run_job(self, job, auto_finalize=3DTrue, auto_dismi= ss=3DFalse, while True: ev =3D filter_qmp_event(self.events_wait(events, timeout=3Dwai= t)) if ev['event'] !=3D 'JOB_STATUS_CHANGE': - log(ev) + log(ev, filters=3Dfilters) continue status =3D ev['data']['status'] if status =3D=3D 'aborting': @@ -983,18 +989,18 @@ def run_job(self, job, auto_finalize=3DTrue, auto_dis= miss=3DFalse, for j in result['return']: if j['id'] =3D=3D job: error =3D j['error'] - log('Job failed: %s' % (j['error'])) + log('Job failed: %s' % (j['error']), filters=3Dfil= ters) elif status =3D=3D 'ready': - self.qmp_log('job-complete', id=3Djob) + self.qmp_log('job-complete', id=3Djob, filters=3Dfilters) elif status =3D=3D 'pending' and not auto_finalize: if pre_finalize: pre_finalize() if cancel: - self.qmp_log('job-cancel', id=3Djob) + self.qmp_log('job-cancel', id=3Djob, filters=3Dfilters) else: - self.qmp_log('job-finalize', id=3Djob) + self.qmp_log('job-finalize', id=3Djob, filters=3Dfilte= rs) elif status =3D=3D 'concluded' and not auto_dismiss: - self.qmp_log('job-dismiss', id=3Djob) + self.qmp_log('job-dismiss', id=3Djob, filters=3Dfilters) elif status =3D=3D 'null': return error =20 @@ -1007,7 +1013,7 @@ def blockdev_create(self, options, job_id=3D'job0', f= ilters=3DNone): =20 if 'return' in result: assert result['return'] =3D=3D {} - job_result =3D self.run_job(job_id) + job_result =3D self.run_job(job_id, filters=3Dfilters) else: job_result =3D result['error'] =20 --=20 2.35.1 From nobody Sat Sep 21 00:47:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647951898538119.98036746494927; Tue, 22 Mar 2022 05:24:58 -0700 (PDT) Received: from localhost ([::1]:33546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWdZJ-0001He-Hb for importer@patchew.org; Tue, 22 Mar 2022 08:24:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59800) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8p-0003SM-5v for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:26303) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWd8n-0006YS-9c for qemu-devel@nongnu.org; Tue, 22 Mar 2022 07:57:34 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-102-OFAjd-g_PYiDltcYibeIrA-1; Tue, 22 Mar 2022 07:57:31 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 19FE13C16196; Tue, 22 Mar 2022 11:57:31 +0000 (UTC) Received: from localhost (unknown [10.39.194.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C6412403D1A3; Tue, 22 Mar 2022 11:57:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647950252; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i91O8dWwUcv78cm11nfWjgAvjx3LbmIrrCZ8Ackajak=; b=KHu2/bX2GmQJ8zhc7GfKxY+4sLVt1PHt8Oicl9F2chKfzg76INTKd2K5njLcEkw/w6Mx7c ETVZc2aXjT+k3amOoy1gu1SeTE0nJIyh8oIgFx40qWYpFLDWp0zlcR7p1KAGPbjlWWH2xJ 9/ykodEYtG5G5yNUelhaT4OaLxOklDY= X-MC-Unique: OFAjd-g_PYiDltcYibeIrA-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 25/25] iotests/207: Filter host fingerprint Date: Tue, 22 Mar 2022 12:56:47 +0100 Message-Id: <20220322115647.726044-26-hreitz@redhat.com> In-Reply-To: <20220322115647.726044-1-hreitz@redhat.com> References: <20220322115647.726044-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647951900289100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Commit e3296cc796aeaf319f3ed4e064ec309baf5e4da4 made the ssh block driver's error message for fingerprint mismatches more verbose, so it now prints the actual host key fingerprint and the key type. iotest 207 tests such errors, but was not amended to filter that fingerprint (which is host-specific), so do it now. Filter the key type, too, because I guess this too can differ depending on the host configuration. Fixes: e3296cc796aeaf319f3ed4e064ec309baf5e4da4 ("block: print the server key type and fingerprint on failure") Reported-by: John Snow Signed-off-by: Hanna Reitz Message-Id: <20220318125304.66131-3-hreitz@redhat.com> Reviewed-by: John Snow --- tests/qemu-iotests/207 | 7 ++++++- tests/qemu-iotests/207.out | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/qemu-iotests/207 b/tests/qemu-iotests/207 index 0f5c4bc8a0..41dcf3ff55 100755 --- a/tests/qemu-iotests/207 +++ b/tests/qemu-iotests/207 @@ -35,7 +35,12 @@ def filter_hash(qmsg): if key =3D=3D 'hash' and re.match('[0-9a-f]+', value): return 'HASH' return value - return iotests.filter_qmp(qmsg, _filter) + if isinstance(qmsg, str): + # Strip key type and fingerprint + p =3D r"\S+ (key fingerprint) '(md5|sha1|sha256):[0-9a-f]+'" + return re.sub(p, r"\1 '\2:HASH'", qmsg) + else: + return iotests.filter_qmp(qmsg, _filter) =20 def blockdev_create(vm, options): vm.blockdev_create(options, filters=3D[iotests.filter_qmp_testfiles, f= ilter_hash]) diff --git a/tests/qemu-iotests/207.out b/tests/qemu-iotests/207.out index aeb8569d77..05cf753283 100644 --- a/tests/qemu-iotests/207.out +++ b/tests/qemu-iotests/207.out @@ -42,7 +42,7 @@ virtual size: 4 MiB (4194304 bytes) =20 {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "ssh", "location": {"host-key-check": {"hash": "wrong", "mode": = "hash", "type": "md5"}, "path": "TEST_DIR/PID-t.img", "server": {"host": "1= 27.0.0.1", "port": "22"}}, "size": 2097152}}} {"return": {}} -Job failed: remote host key does not match host_key_check 'wrong' +Job failed: remote host key fingerprint 'md5:HASH' does not match host_key= _check 'md5:wrong' {"execute": "job-dismiss", "arguments": {"id": "job0"}} {"return": {}} =20 @@ -59,7 +59,7 @@ virtual size: 8 MiB (8388608 bytes) =20 {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "ssh", "location": {"host-key-check": {"hash": "wrong", "mode": = "hash", "type": "sha1"}, "path": "TEST_DIR/PID-t.img", "server": {"host": "= 127.0.0.1", "port": "22"}}, "size": 2097152}}} {"return": {}} -Job failed: remote host key does not match host_key_check 'wrong' +Job failed: remote host key fingerprint 'sha1:HASH' does not match host_ke= y_check 'sha1:wrong' {"execute": "job-dismiss", "arguments": {"id": "job0"}} {"return": {}} =20 @@ -76,7 +76,7 @@ virtual size: 4 MiB (4194304 bytes) =20 {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "ssh", "location": {"host-key-check": {"hash": "wrong", "mode": = "hash", "type": "sha256"}, "path": "TEST_DIR/PID-t.img", "server": {"host":= "127.0.0.1", "port": "22"}}, "size": 2097152}}} {"return": {}} -Job failed: remote host key does not match host_key_check 'wrong' +Job failed: remote host key fingerprint 'sha256:HASH' does not match host_= key_check 'sha256:wrong' {"execute": "job-dismiss", "arguments": {"id": "job0"}} {"return": {}} =20 --=20 2.35.1