From nobody Sat May 18 10:30:07 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 ARC-Seal: i=1; a=rsa-sha256; t=1589406279; cv=none; d=zohomail.com; s=zohoarc; b=DWXjUE0/Rc3wuxPlU7dKoalb28bnUOBMiGDGfEz7Wqv+qdaLAbptWHd1fTcO2a1yktviw7f7O5GM1ht8Oo0YeFAxEQ0RNGENY0TatYp97/aENrLl+fmBREkQiXhAT+sxcJom4pbg0B2Fwqj13kJd6ShGT7a7VcsWU6i9zwyX8LU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589406279; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kXoCwbk+3HXyEFBiiOU0vwvD6R17WSdenHb1GicYPzY=; b=l5D79fm+nKpeeQG8gORCnBzN221g9g+2vArmsYc9sZoMm16kE3nxITsXqH8V2pxJq46PrHGSqvZ4GyUt+N69uNOIDZb0EbiRPY67Xobxknh/cQ3IOu8s3BzbUlyoGgZPOJ0oq9d3lKLVXjMxMp40res+4UAEBUNUD93e1u/t8MU= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589406279974274.95647700168536; Wed, 13 May 2020 14:44:39 -0700 (PDT) Received: from localhost ([::1]:48684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYzB8-0001Au-Hu for importer@patchew.org; Wed, 13 May 2020 17:44:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34056) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYz8F-0006re-Ip for qemu-devel@nongnu.org; Wed, 13 May 2020 17:41:39 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:34531 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jYz8E-0005a5-5w for qemu-devel@nongnu.org; Wed, 13 May 2020 17:41:38 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-470-fMQ1shCZOFaNvBsxlgv9Pw-1; Wed, 13 May 2020 17:41:33 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DD834801503; Wed, 13 May 2020 21:41:32 +0000 (UTC) Received: from probe.redhat.com (ovpn-113-80.rdu2.redhat.com [10.10.113.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BEB21C94D; Wed, 13 May 2020 21:41:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589406096; 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=kXoCwbk+3HXyEFBiiOU0vwvD6R17WSdenHb1GicYPzY=; b=dXGVCZM8SuMtSgKjgdZR1uhxlQugFnlfStQxsPiMET4xQiBsHR0CpmD9eJG/YyJL4KEWiJ QAGviX6LiokLaY+Tc2SQoPCT/moOXOYX6p3GG3yxrn2EoXeqZtCRo66+FsUorem/y6jMRf 1cbC4FMzapqqzZF12PP0/RzFcP6svvA= X-MC-Unique: fMQ1shCZOFaNvBsxlgv9Pw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH RFC WIP 1/6] iotests: type hint wip Date: Wed, 13 May 2020 17:41:25 -0400 Message-Id: <20200513214130.15375-2-jsnow@redhat.com> In-Reply-To: <20200513214130.15375-1-jsnow@redhat.com> References: <20200513214130.15375-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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=205.139.110.61; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/13 01:56:38 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, 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_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , ehabkost@redhat.com, qemu-block@nongnu.org, philmd@redhat.com, Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- tests/qemu-iotests/iotests.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 6c0e781af7..27c477c8a7 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -90,7 +90,7 @@ luks_default_key_secret_opt =3D 'key-secret=3Dkeysec0' =20 =20 -def qemu_img(*args): +def qemu_img(*args) -> int: '''Run qemu-img and return the exit code''' devnull =3D open('/dev/null', 'r+') exitcode =3D subprocess.call(qemu_img_args + list(args), @@ -113,24 +113,24 @@ def ordered_qmp(qmsg, conv_keys=3DTrue): return od return qmsg =20 -def qemu_img_create(*args): - args =3D list(args) +def qemu_img_create(*args: str) -> int: + qargs =3D list(args) =20 # default luks support - if '-f' in args and args[args.index('-f') + 1] =3D=3D 'luks': - if '-o' in args: - i =3D args.index('-o') - if 'key-secret' not in args[i + 1]: - args[i + 1].append(luks_default_key_secret_opt) - args.insert(i + 2, '--object') - args.insert(i + 3, luks_default_secret_object) + if '-f' in qargs and qargs[qargs.index('-f') + 1] =3D=3D 'luks': + if '-o' in qargs: + i =3D qargs.index('-o') + if 'key-secret' not in qargs[i + 1]: + qargs[i + 1].append(luks_default_key_secret_opt) + qargs.insert(i + 2, '--object') + qargs.insert(i + 3, luks_default_secret_object) else: - args =3D ['-o', luks_default_key_secret_opt, - '--object', luks_default_secret_object] + args + qargs =3D ['-o', luks_default_key_secret_opt, + '--object', luks_default_secret_object] + qargs =20 - args.insert(0, 'create') + qargs.insert(0, 'create') =20 - return qemu_img(*args) + return qemu_img(*qargs) =20 def qemu_img_verbose(*args): '''Run qemu-img without suppressing its output and return the exit cod= e''' --=20 2.21.1 From nobody Sat May 18 10:30:07 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 ARC-Seal: i=1; a=rsa-sha256; t=1589406163; cv=none; d=zohomail.com; s=zohoarc; b=Fy7e08vKVzendvYfL2WNL7lNjOTbjbNC1XyNFdNAs/mh7aRk9FKgqmVEAwSu3EsWyBEvaeeNsbKinY9AcrVJugoskX99bNNEshA3l0kmqSL+b0JjTNf6NAleLCbVKNS8jjz7u7WqWx7R+M5E3wT9tutx3TWWFnqW1tvEfAWGvHY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589406163; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0QffVv5xbmQImW4UmidPHrV3KfMFnmJXLW/0kpOw5Hc=; b=F/lAOrJPF+CzGjhFyrWXnr6mYOBJsSUIK9P4WL8Bv4zil3u0Knd7C+2XKU4rHMZSjWyLLWq1lLvA9jEKJ+dwV4cpq1yME34ELxc3GwFvCgkg0bedO4My7v4/QS2AqU1Aw1xXUS/MG/Ae3smsKHKtOJ/HRksEroV0lB1/0bLZNCw= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589406163262245.8171971603856; Wed, 13 May 2020 14:42:43 -0700 (PDT) Received: from localhost ([::1]:44456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYz9F-0007u8-5M for importer@patchew.org; Wed, 13 May 2020 17:42:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYz8F-0006rh-IO for qemu-devel@nongnu.org; Wed, 13 May 2020 17:41:39 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:21271 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jYz8E-0005ac-RL for qemu-devel@nongnu.org; Wed, 13 May 2020 17:41:39 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-172-UdF1q2RmN5qu5NPljf8WsA-1; Wed, 13 May 2020 17:41:34 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C8AE883DE6C; Wed, 13 May 2020 21:41:33 +0000 (UTC) Received: from probe.redhat.com (ovpn-113-80.rdu2.redhat.com [10.10.113.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0DE9A1C94D; Wed, 13 May 2020 21:41:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589406098; 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=0QffVv5xbmQImW4UmidPHrV3KfMFnmJXLW/0kpOw5Hc=; b=VhBY6n87g+8U+4nlIniW+JC6u1PDNgOJaKQAwF68tul5V+loDBjCEfOUVeSZ2oY9DVq+ck q4vnWYJ3zGi10k/DDk6TVyMnTy0r6l4oRmusBwaODWRJrPMGfMRJ2/lyjf7kJTJiLCK7XB dM50V8R8OM2kbLYll4AVKIaSnC8QWyQ= X-MC-Unique: UdF1q2RmN5qu5NPljf8WsA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH RFC WIP 2/6] Makefile: add delint WIP Date: Wed, 13 May 2020 17:41:26 -0400 Message-Id: <20200513214130.15375-3-jsnow@redhat.com> In-Reply-To: <20200513214130.15375-1-jsnow@redhat.com> References: <20200513214130.15375-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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=205.139.110.61; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/13 01:56:38 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, 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_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , ehabkost@redhat.com, qemu-block@nongnu.org, philmd@redhat.com, Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- tests/qemu-iotests/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/qemu-iotests/Makefile b/tests/qemu-iotests/Makefile index 27380e60c1..7dbb7f0fff 100644 --- a/tests/qemu-iotests/Makefile +++ b/tests/qemu-iotests/Makefile @@ -1,3 +1,6 @@ +PYMODULES =3D $(wildcard *.py) + +KNOWN_GOOD =3D iotests.py =20 CLEANFILES=3D *.out.bad *.notrun check.log check.time* =20 @@ -7,3 +10,6 @@ default: clean: rm -f $(CLEANFILES) =20 +delint: + pylint $(KNOWN_GOOD) + pylint --disable=3DR,C,W $(filter-out $(KNOWN_GOOD), $(PYMODULES)) --=20 2.21.1 From nobody Sat May 18 10:30:07 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 ARC-Seal: i=1; a=rsa-sha256; t=1589406165; cv=none; d=zohomail.com; s=zohoarc; b=MxjSQClFf9pXY4M2M4pSoLpIKbMyVFPJQHzvFnMJg7KH2MlEzxjGqsForuo/SnFRVgC7WmA+WBmlo+BDw0i6R68NutsGlXdoBR1y46ggsKgsD1jBskaj7SUjBHiNOJdfNMZmkrBsV0zSw3y+Vj795fcxoqNG+H4lbTVAsoqdRkg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589406165; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AQPoy5tHkY9or+yZngAsI3Otf/N2lSJ/rV5CdZXMGCw=; b=kA0oZyBxmG2dd2YzzzHxD/HolOU7ZjgZx+k7cF85cVqn4IM4XnISlj0cZ3mf65Zq+Sf1XtcSH80fE8rrFDPD7H60mKd2ma9CPdbzygVrkIjNeFRCZqlX6O7H+7eYP1SLMeovJq49l/g6xjcbpuClUljxVv/QmAVd1hf/SHMNa20= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589406165967460.84147191515115; Wed, 13 May 2020 14:42:45 -0700 (PDT) Received: from localhost ([::1]:44648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYz9I-0007yk-Pj for importer@patchew.org; Wed, 13 May 2020 17:42:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYz8J-0006uY-85 for qemu-devel@nongnu.org; Wed, 13 May 2020 17:41:43 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:38042 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jYz8I-0005bY-8n for qemu-devel@nongnu.org; Wed, 13 May 2020 17:41:42 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-52-QpuKz1NNMhWdpQqL5AO6mw-1; Wed, 13 May 2020 17:41:35 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AE4A5108BD09; Wed, 13 May 2020 21:41:34 +0000 (UTC) Received: from probe.redhat.com (ovpn-113-80.rdu2.redhat.com [10.10.113.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBB512E034; Wed, 13 May 2020 21:41:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589406101; 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=AQPoy5tHkY9or+yZngAsI3Otf/N2lSJ/rV5CdZXMGCw=; b=dEeNTr6dvKaHWg49m0ZvOTh/LAh+rWB3C5ojJrc8n3VJpztp87FkOIAHFgmRidKX8fnyNW h2TWBdPrAND/7Ghh0/hRD6BBb3kq263i7DzvIgWbshTdv1mGG4+WbMGQ5u589jTm8ftuN2 uE4skqS45X3CRc4tSdDK3pVXuj72g3s= X-MC-Unique: QpuKz1NNMhWdpQqL5AO6mw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH RFC WIP 3/6] nbd-fault-injector: delint Date: Wed, 13 May 2020 17:41:27 -0400 Message-Id: <20200513214130.15375-4-jsnow@redhat.com> In-Reply-To: <20200513214130.15375-1-jsnow@redhat.com> References: <20200513214130.15375-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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=205.139.110.120; envelope-from=jsnow@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/13 01:56:38 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, 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_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , ehabkost@redhat.com, qemu-block@nongnu.org, philmd@redhat.com, Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- tests/qemu-iotests/Makefile | 2 +- tests/qemu-iotests/nbd-fault-injector.py | 34 ++++++++++++++---------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/tests/qemu-iotests/Makefile b/tests/qemu-iotests/Makefile index 7dbb7f0fff..64db48342f 100644 --- a/tests/qemu-iotests/Makefile +++ b/tests/qemu-iotests/Makefile @@ -1,6 +1,6 @@ PYMODULES =3D $(wildcard *.py) =20 -KNOWN_GOOD =3D iotests.py +KNOWN_GOOD =3D iotests.py nbd-fault-injector.py =20 CLEANFILES=3D *.out.bad *.notrun check.log check.time* =20 diff --git a/tests/qemu-iotests/nbd-fault-injector.py b/tests/qemu-iotests/= nbd-fault-injector.py index 588d62aebf..0de6bc643e 100755 --- a/tests/qemu-iotests/nbd-fault-injector.py +++ b/tests/qemu-iotests/nbd-fault-injector.py @@ -47,10 +47,7 @@ import socket import struct import collections -if sys.version_info.major >=3D 3: - import configparser -else: - import ConfigParser as configparser +import configparser =20 FAKE_DISK_SIZE =3D 8 * 1024 * 1024 * 1024 # 8 GB =20 @@ -71,7 +68,9 @@ export_tuple =3D collections.namedtuple('Export', 'reserved magic opt len') export_struct =3D struct.Struct('>IQII') neg2_struct =3D struct.Struct('>QH124x') -request_tuple =3D collections.namedtuple('Request', 'magic type handle fro= m_ len') +request_tuple =3D collections.namedtuple( + 'Request', 'magic type handle from_ len' +) request_struct =3D struct.Struct('>IIQQI') reply_struct =3D struct.Struct('>IIQ') =20 @@ -84,13 +83,13 @@ def recvall(sock, bufsize): chunks =3D [] while received < bufsize: chunk =3D sock.recv(bufsize - received) - if len(chunk) =3D=3D 0: + if not chunk: raise Exception('unexpected disconnect') chunks.append(chunk) received +=3D len(chunk) return b''.join(chunks) =20 -class Rule(object): +class Rule: def __init__(self, name, event, io, when): self.name =3D name self.event =3D event @@ -104,7 +103,7 @@ def match(self, event, io): return False return True =20 -class FaultInjectionSocket(object): +class FaultInjectionSocket: def __init__(self, sock, rules): self.sock =3D sock self.rules =3D rules @@ -150,7 +149,7 @@ def negotiate_export(conn): export =3D export_tuple._make(export_struct.unpack(buf)) assert export.magic =3D=3D NBD_OPTS_MAGIC assert export.opt =3D=3D NBD_OPT_EXPORT_NAME - name =3D conn.recv(export.len, event=3D'export-name') + _name =3D conn.recv(export.len, event=3D'export-name') =20 # Send negotiation part 2 buf =3D neg2_struct.pack(FAKE_DISK_SIZE, 0) @@ -200,7 +199,8 @@ def parse_inject_error(name, options): if 'event' not in options: err('missing \"event\" option in %s' % name) event =3D options['event'] - if event not in ('neg-classic', 'neg1', 'export', 'neg2', 'request', '= reply', 'data'): + if event not in ('neg-classic', 'neg1', 'export', + 'neg2', 'request', 'reply', 'data'): err('invalid \"event\" option value \"%s\" in %s' % (event, name)) io =3D options.get('io', 'readwrite') if io not in ('read', 'write', 'readwrite'): @@ -229,8 +229,8 @@ def parse_config(config): =20 def load_rules(filename): config =3D configparser.RawConfigParser() - with open(filename, 'rt') as f: - config.readfp(f, filename) + with open(filename, 'rt') as infile: + config.read_file(infile) return parse_config(config) =20 def open_socket(path): @@ -252,8 +252,14 @@ def open_socket(path): return sock =20 def usage(args): - sys.stderr.write('usage: %s [--classic-negotiation] | \n' % args[0]) - sys.stderr.write('Run an fault injector NBD server with rules defined = in a config file.\n') + name =3D args[0] + sys.stderr.write( + f'usage: {name} [--classic-negotiation] ' + '| \n' + ) + sys.stderr.write( + 'Run a fault injector NBD server with ' + 'rules defined in a config file.\n') sys.exit(1) =20 def main(args): --=20 2.21.1 From nobody Sat May 18 10:30:07 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 ARC-Seal: i=1; a=rsa-sha256; t=1589406394; cv=none; d=zohomail.com; s=zohoarc; b=VS0ticL+bHNHKPah9WsQUXLJIdEQr16RWQzTojUreygCsBEtnFUJ5BPq5yMJBWde0+OW7TPlZuxIbYAf1GH0YvwGyRwrxE2rf7dtp5fDA5xj74aW8ekYL3E6Daulk1YHNs+xjBTOMaV9CXj5Jirx334h2CFxYD7LVuQy0iaA060= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589406394; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mADFPjG4NsDPQUvoHbp1gHPK/gjpmZfpYfEuvG6grrA=; b=Gex7tCF3IFVRhJq81bt+a9IW8vDaBPnzjzDcsxZkwTiRxmZKAs8ojOBQEULJ8onTb8ZuaxIdJWgnEkkN20KB+e0JhRi0L7D3k6jG34dVcf3OCpgJoHfwgCnaqsOKnzKiB1PTHj11sthv3WRZbd9aj4Lg2Fx+CTVzApzGI1E9nEM= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589406394452633.2682734483532; Wed, 13 May 2020 14:46:34 -0700 (PDT) Received: from localhost ([::1]:53328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYzCz-0003Ha-7r for importer@patchew.org; Wed, 13 May 2020 17:46:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYz8M-0006zz-9f for qemu-devel@nongnu.org; Wed, 13 May 2020 17:41:46 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:33414 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jYz8L-0005cS-9F for qemu-devel@nongnu.org; Wed, 13 May 2020 17:41:45 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-305-Dz6Hj7TWM3uAr18L59AzaA-1; Wed, 13 May 2020 17:41:36 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 954EC84638F; Wed, 13 May 2020 21:41:35 +0000 (UTC) Received: from probe.redhat.com (ovpn-113-80.rdu2.redhat.com [10.10.113.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id D312B1C94D; Wed, 13 May 2020 21:41:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589406104; 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=mADFPjG4NsDPQUvoHbp1gHPK/gjpmZfpYfEuvG6grrA=; b=jS+y/iFw0GVQnnhByxnHk2PI/NSTuu8z32l/Y4TpzBxgUfwS6oazJEbEgXMSe2WbGcQdTc codHxk59Rbc8l8UYr+FchmRVPpjR2aFNGRbNXnF2toSW33QA3rkYhmC1sn9PaQ1O+R/4Ky orCEg+LCHDexZ5H62ExnXPGr/yX2nRI= X-MC-Unique: Dz6Hj7TWM3uAr18L59AzaA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH RFC WIP 4/6] qed.py: delint Date: Wed, 13 May 2020 17:41:28 -0400 Message-Id: <20200513214130.15375-5-jsnow@redhat.com> In-Reply-To: <20200513214130.15375-1-jsnow@redhat.com> References: <20200513214130.15375-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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=207.211.31.81; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/13 04:17:42 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, 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_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , ehabkost@redhat.com, qemu-block@nongnu.org, philmd@redhat.com, Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- tests/qemu-iotests/Makefile | 2 +- tests/qemu-iotests/qed.py | 46 ++++++++++++++++++++++++------------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/tests/qemu-iotests/Makefile b/tests/qemu-iotests/Makefile index 64db48342f..5a3a1e8092 100644 --- a/tests/qemu-iotests/Makefile +++ b/tests/qemu-iotests/Makefile @@ -1,6 +1,6 @@ PYMODULES =3D $(wildcard *.py) =20 -KNOWN_GOOD =3D iotests.py nbd-fault-injector.py +KNOWN_GOOD =3D iotests.py nbd-fault-injector.py qed.py =20 CLEANFILES=3D *.out.bad *.notrun check.log check.time* =20 diff --git a/tests/qemu-iotests/qed.py b/tests/qemu-iotests/qed.py index d6bec96069..9e016cc2a2 100755 --- a/tests/qemu-iotests/qed.py +++ b/tests/qemu-iotests/qed.py @@ -13,7 +13,6 @@ import sys import struct import random -import optparse =20 # This can be used as a module __all__ =3D ['QED_F_NEED_CHECK', 'QED'] @@ -47,7 +46,7 @@ def unpack_table_elem(s): def pack_table_elem(elem): return struct.pack(table_elem_fmt, elem) =20 -class QED(object): +class QED: def __init__(self, f): self.f =3D f =20 @@ -74,19 +73,22 @@ def store_header(self): def read_table(self, offset): size =3D self.header['table_size'] * self.header['cluster_size'] s =3D self.raw_pread(offset, size) - table =3D [unpack_table_elem(s[i:i + table_elem_size]) for i in xr= ange(0, size, table_elem_size)] + table =3D [unpack_table_elem(s[i:i + table_elem_size]) + for i in range(0, size, table_elem_size)] return table =20 def load_l1_table(self): self.l1_table =3D self.read_table(self.header['l1_table_offset']) - self.table_nelems =3D self.header['table_size'] * self.header['clu= ster_size'] // table_elem_size + self.table_nelems =3D (self.header['table_size'] + * self.header['cluster_size'] // table_elem_s= ize) =20 def write_table(self, offset, table): s =3D ''.join(pack_table_elem(x) for x in table) self.raw_pwrite(offset, s) =20 def random_table_item(table): - vals =3D [(index, offset) for index, offset in enumerate(table) if off= set !=3D 0] + vals =3D [(index, offset) for index, offset + in enumerate(table) if offset !=3D 0] if not vals: err('cannot pick random item because table is empty') return random.choice(vals) @@ -103,7 +105,8 @@ def corrupt_table_duplicate(table): def corrupt_table_invalidate(qed, table): '''Corrupt a table by introducing an invalid offset''' index, _ =3D random_table_item(table) - table[index] =3D qed.filesize + random.randint(0, 100 * 1024 * 1024 * = 1024 * 1024) + table[index] =3D (qed.filesize + + random.randint(0, 100 * 1024 * 1024 * 1024 * 1024)) =20 def cmd_show(qed, *args): '''show [header|l1|l2 ]- Show header or l1/l2 tables''' @@ -144,7 +147,11 @@ def cmd_invalidate(qed, table_level): qed.write_table(offset, table) =20 def cmd_need_check(qed, *args): - '''need-check [on|off] - Test, set, or clear the QED_F_NEED_CHECK head= er bit''' + """ + need-check [on|off] + + Test, set, or clear the QED_F_NEED_CHECK header bit + """ if not args: print(bool(qed.header['features'] & QED_F_NEED_CHECK)) return @@ -165,7 +172,7 @@ def cmd_zero_cluster(qed, pos, *args): err('expected one argument') n =3D int(args[0]) =20 - for i in xrange(n): + for _ in range(n): l1_index =3D pos // qed.header['cluster_size'] // len(qed.l1_table) if qed.l1_table[l1_index] =3D=3D 0: err('no l2 table allocated') @@ -179,7 +186,11 @@ def cmd_zero_cluster(qed, pos, *args): pos +=3D qed.header['cluster_size'] =20 def cmd_copy_metadata(qed, outfile): - '''copy-metadata - Copy metadata only (for scrubbing corrupt= ed images)''' + """ + copy-metadata + + Copy metadata only (for scrubbing corrupted images) + """ out =3D open(outfile, 'wb') =20 # Match file size @@ -213,23 +224,26 @@ def usage(): print('Supported commands:') for cmd in sorted(x for x in globals() if x.startswith('cmd_')): print(globals()[cmd].__doc__) - sys.exit(1) + return 1 =20 def main(): if len(sys.argv) < 3: - usage() - filename, cmd =3D sys.argv[1:3] + return usage() + filename =3D sys.argv[1] + cmd =3D sys.argv[2] =20 cmd =3D 'cmd_' + cmd.replace('-', '_') if cmd not in globals(): - usage() + return usage() =20 qed =3D QED(open(filename, 'r+b')) try: globals()[cmd](qed, *sys.argv[3:]) - except TypeError as e: + except TypeError: sys.stderr.write(globals()[cmd].__doc__ + '\n') - sys.exit(1) + return 1 + + return 0 =20 if __name__ =3D=3D '__main__': - main() + sys.exit(main()) --=20 2.21.1 From nobody Sat May 18 10:30:07 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 ARC-Seal: i=1; a=rsa-sha256; t=1589406284; cv=none; d=zohomail.com; s=zohoarc; b=F5kgHt63r/OxhUGmoOnAS1HJJv8CsJqNGHxkzzZywyDq30jlkKmz6d7a0F1k0JKBjnHzvGwqVjxcaXck5snZbkgNfxLNXTb8unsIuN/CFR+DFjiri5kd/0Yno+eZijV3wAk9CFN0wWQ3RQJyEMIFtZmrZLRKHQWlKub+dMcOgs8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589406284; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=11EItyxhwah0ZNUqpJ6iomtdgWv2ScwwGFBOkvnqQcU=; b=avSFYz8beP1yFUWR2ESQOWOJBbe3B373UTZX0MUC8xZLi+ymmou1GyysY/K8ck2YwyfwFXfRD9EEHI5fAFwn8M2cZCcvPzyAIMeTq35p+evU/GBokHuEWC3KNUl4LfZJJlVQYMbKMcmT3yE2UIs7/uOCDzdDCGZkdliRfT2t8IU= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589406284967456.9644664701493; Wed, 13 May 2020 14:44:44 -0700 (PDT) Received: from localhost ([::1]:48956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYzBD-0001HV-Hx for importer@patchew.org; Wed, 13 May 2020 17:44:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34086) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYz8K-0006vV-0e for qemu-devel@nongnu.org; Wed, 13 May 2020 17:41:44 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:38340 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jYz8I-0005bg-GE for qemu-devel@nongnu.org; Wed, 13 May 2020 17:41:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-312-5l-ljKviPSWO6g3F3fTmvA-1; Wed, 13 May 2020 17:41:38 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8058F100CCCC; Wed, 13 May 2020 21:41:37 +0000 (UTC) Received: from probe.redhat.com (ovpn-113-80.rdu2.redhat.com [10.10.113.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7D4C2E055; Wed, 13 May 2020 21:41:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589406101; 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=11EItyxhwah0ZNUqpJ6iomtdgWv2ScwwGFBOkvnqQcU=; b=Ha2NWr6VvJFv32ee5/0Q0VrQMh3/nOFSTakMkWQfclq/YZbiy+6RZMI3HFvpjXauBdeE6s DmVE0HlxQ/Nu9kwXS21s3rldO/1R2K74Px4y5KiM1sXShqR9nnGD9qA2WDUOkDI3CpstWk VJNdyf3zVI6m7gp7t3OmRqzrL/C1mjM= X-MC-Unique: 5l-ljKviPSWO6g3F3fTmvA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH RFC WIP 5/6] qcow2.py: delint Date: Wed, 13 May 2020 17:41:29 -0400 Message-Id: <20200513214130.15375-6-jsnow@redhat.com> In-Reply-To: <20200513214130.15375-1-jsnow@redhat.com> References: <20200513214130.15375-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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=205.139.110.120; envelope-from=jsnow@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/13 01:56:38 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, 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_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , ehabkost@redhat.com, qemu-block@nongnu.org, philmd@redhat.com, Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- tests/qemu-iotests/Makefile | 5 +- tests/qemu-iotests/pylintrc | 1 + tests/qemu-iotests/qcow2.py | 156 +++++++++++++++++++++++------------- 3 files changed, 104 insertions(+), 58 deletions(-) diff --git a/tests/qemu-iotests/Makefile b/tests/qemu-iotests/Makefile index 5a3a1e8092..77da9fd96d 100644 --- a/tests/qemu-iotests/Makefile +++ b/tests/qemu-iotests/Makefile @@ -1,7 +1,5 @@ PYMODULES =3D $(wildcard *.py) =20 -KNOWN_GOOD =3D iotests.py nbd-fault-injector.py qed.py - CLEANFILES=3D *.out.bad *.notrun check.log check.time* =20 # no default target @@ -11,5 +9,4 @@ clean: rm -f $(CLEANFILES) =20 delint: - pylint $(KNOWN_GOOD) - pylint --disable=3DR,C,W $(filter-out $(KNOWN_GOOD), $(PYMODULES)) + pylint $(PYMODULES) diff --git a/tests/qemu-iotests/pylintrc b/tests/qemu-iotests/pylintrc index 5481afe528..a334e242b6 100644 --- a/tests/qemu-iotests/pylintrc +++ b/tests/qemu-iotests/pylintrc @@ -17,6 +17,7 @@ disable=3Dinvalid-name, too-many-lines, too-many-locals, too-many-public-methods, + too-many-instance-attributes, # These are temporary, and should be removed: missing-docstring, =20 diff --git a/tests/qemu-iotests/qcow2.py b/tests/qemu-iotests/qcow2.py index 94a07b2f6f..2840f4b661 100755 --- a/tests/qemu-iotests/qcow2.py +++ b/tests/qemu-iotests/qcow2.py @@ -11,14 +11,15 @@ def __init__(self, magic, length, data): padding =3D 8 - (length % 8) data +=3D b"\0" * padding =20 - self.magic =3D magic + self.magic =3D magic self.length =3D length - self.data =3D data + self.data =3D data =20 @classmethod def create(cls, magic, data): return QcowHeaderExtension(magic, len(data), data) =20 + class QcowHeader: =20 uint32_t =3D 'I' @@ -26,30 +27,41 @@ class QcowHeader: =20 fields =3D [ # Version 2 header fields - [ uint32_t, '%#x', 'magic' ], - [ uint32_t, '%d', 'version' ], - [ uint64_t, '%#x', 'backing_file_offset' ], - [ uint32_t, '%#x', 'backing_file_size' ], - [ uint32_t, '%d', 'cluster_bits' ], - [ uint64_t, '%d', 'size' ], - [ uint32_t, '%d', 'crypt_method' ], - [ uint32_t, '%d', 'l1_size' ], - [ uint64_t, '%#x', 'l1_table_offset' ], - [ uint64_t, '%#x', 'refcount_table_offset' ], - [ uint32_t, '%d', 'refcount_table_clusters' ], - [ uint32_t, '%d', 'nb_snapshots' ], - [ uint64_t, '%#x', 'snapshot_offset' ], + # pylint: disable=3Dbad-whitespace + [uint32_t, '%#x', 'magic'], + [uint32_t, '%d', 'version'], + [uint64_t, '%#x', 'backing_file_offset'], + [uint32_t, '%#x', 'backing_file_size'], + [uint32_t, '%d', 'cluster_bits'], + [uint64_t, '%d', 'size'], + [uint32_t, '%d', 'crypt_method'], + [uint32_t, '%d', 'l1_size'], + [uint64_t, '%#x', 'l1_table_offset'], + [uint64_t, '%#x', 'refcount_table_offset'], + [uint32_t, '%d', 'refcount_table_clusters'], + [uint32_t, '%d', 'nb_snapshots'], + [uint64_t, '%#x', 'snapshot_offset'], =20 # Version 3 header fields - [ uint64_t, 'mask', 'incompatible_features' ], - [ uint64_t, 'mask', 'compatible_features' ], - [ uint64_t, 'mask', 'autoclear_features' ], - [ uint32_t, '%d', 'refcount_order' ], - [ uint32_t, '%d', 'header_length' ], - ]; + [uint64_t, 'mask', 'incompatible_features'], + [uint64_t, 'mask', 'compatible_features'], + [uint64_t, 'mask', 'autoclear_features'], + [uint32_t, '%d', 'refcount_order'], + [uint32_t, '%d', 'header_length'], + ] =20 fmt =3D '>' + ''.join(field[0] for field in fields) =20 + @property + def backing_file_offset(self): + # Pylint struggles to verify dynamic properties. + # Dataclasses in 3.7 would make this easy. + return self.__dict__['backing_file_offset'] + + @backing_file_offset.setter + def backing_file_offset(self, val): + self.__dict__['backing_file_offset'] =3D val + def __init__(self, fd): =20 buf_size =3D struct.calcsize(QcowHeader.fmt) @@ -59,22 +71,22 @@ def __init__(self, fd): =20 header =3D struct.unpack(QcowHeader.fmt, buf) self.__dict__ =3D dict((field[2], header[i]) - for i, field in enumerate(QcowHeader.fields)) + for i, field in enumerate(QcowHeader.fields)) =20 self.set_defaults() - self.cluster_size =3D 1 << self.cluster_bits + self.cluster_size =3D 1 << self.__dict__['cluster_bits'] =20 fd.seek(self.header_length) self.load_extensions(fd) =20 if self.backing_file_offset: fd.seek(self.backing_file_offset) - self.backing_file =3D fd.read(self.backing_file_size) + self.backing_file =3D fd.read(self.__dict__['backing_file_size= ']) else: self.backing_file =3D None =20 def set_defaults(self): - if self.version =3D=3D 2: + if self.__dict__['version'] =3D=3D 2: self.incompatible_features =3D 0 self.compatible_features =3D 0 self.autoclear_features =3D 0 @@ -93,10 +105,10 @@ def load_extensions(self, fd): (magic, length) =3D struct.unpack('>II', fd.read(8)) if magic =3D=3D 0: break - else: - padded =3D (length + 7) & ~7 - data =3D fd.read(padded) - self.extensions.append(QcowHeaderExtension(magic, length, = data)) + padded =3D (length + 7) & ~7 + data =3D fd.read(padded) + extension =3D QcowHeaderExtension(magic, length, data) + self.extensions.append(extension) =20 def update_extensions(self, fd): =20 @@ -108,7 +120,7 @@ def update_extensions(self, fd): fd.write(buf) fd.write(ex.data) =20 - if self.backing_file !=3D None: + if self.backing_file is None: self.backing_file_offset =3D fd.tell() fd.write(self.backing_file) =20 @@ -170,13 +182,13 @@ def cmd_dump_header_exts(fd): def cmd_set_header(fd, name, value): try: value =3D int(value, 0) - except: - print("'%s' is not a valid number" % value) + except ValueError: + print(f"'{value}' is not a valid number") sys.exit(1) =20 fields =3D (field[2] for field in QcowHeader.fields) if not name in fields: - print("'%s' is not a known header field" % name) + print("'{name}' is not a known header field") sys.exit(1) =20 h =3D QcowHeader(fd) @@ -186,12 +198,13 @@ def cmd_set_header(fd, name, value): def cmd_add_header_ext(fd, magic, data): try: magic =3D int(magic, 0) - except: - print("'%s' is not a valid magic number" % magic) + except ValueError: + print(f"'{magic}' is not a valid magic number") sys.exit(1) =20 h =3D QcowHeader(fd) - h.extensions.append(QcowHeaderExtension.create(magic, data.encode('asc= ii'))) + ext =3D QcowHeaderExtension.create(magic, data.encode('ascii')) + h.extensions.append(ext) h.update(fd) =20 def cmd_add_header_ext_stdio(fd, magic): @@ -201,8 +214,8 @@ def cmd_add_header_ext_stdio(fd, magic): def cmd_del_header_ext(fd, magic): try: magic =3D int(magic, 0) - except: - print("'%s' is not a valid magic number" % magic) + except ValueError: + print(f"'{magic}' is not a valid magic number") sys.exit(1) =20 h =3D QcowHeader(fd) @@ -224,8 +237,8 @@ def cmd_set_feature_bit(fd, group, bit): bit =3D int(bit, 0) if bit < 0 or bit >=3D 64: raise ValueError - except: - print("'%s' is not a valid bit number in range [0, 64)" % bit) + except ValueError: + print(f"'{bit}' is not a valid bit number in range [0, 64)") sys.exit(1) =20 h =3D QcowHeader(fd) @@ -236,33 +249,68 @@ def cmd_set_feature_bit(fd, group, bit): elif group =3D=3D 'autoclear': h.autoclear_features |=3D 1 << bit else: - print("'%s' is not a valid group, try 'incompatible', 'compatible'= , or 'autoclear'" % group) + print(f"'{group}' is not a valid group, " + "try 'incompatible', 'compatible', or 'autoclear'") sys.exit(1) =20 h.update(fd) =20 cmds =3D [ - [ 'dump-header', cmd_dump_header, 0, 'Dump image hea= der and header extensions' ], - [ 'dump-header-exts', cmd_dump_header_exts, 0, 'Dump image hea= der extensions' ], - [ 'set-header', cmd_set_header, 2, 'Set a field in= the header'], - [ 'add-header-ext', cmd_add_header_ext, 2, 'Add a header e= xtension' ], - [ 'add-header-ext-stdio', cmd_add_header_ext_stdio, 1, 'Add a header e= xtension, data from stdin' ], - [ 'del-header-ext', cmd_del_header_ext, 1, 'Delete a heade= r extension' ], - [ 'set-feature-bit', cmd_set_feature_bit, 2, 'Set a feature = bit'], + [ + 'dump-header', + cmd_dump_header, + 0, + 'Dump image header and header extensions' + ], + [ + 'dump-header-exts', + cmd_dump_header_exts, + 0, + 'Dump image header extensions' + ], + [ + 'set-header', + cmd_set_header, + 2, + 'Set a field in the header' + ], + [ + 'add-header-ext', + cmd_add_header_ext, + 2, + 'Add a header extension' + ], + [ + 'add-header-ext-stdio', + cmd_add_header_ext_stdio, + 1, + 'Add a header extension, data from stdin' + ], + [ + 'del-header-ext', + cmd_del_header_ext, + 1, + 'Delete a header extension' + ], + [ + 'set-feature-bit', + cmd_set_feature_bit, + 2, + 'Set a feature bit' + ], ] =20 def main(filename, cmd, args): fd =3D open(filename, "r+b") try: - for name, handler, num_args, desc in cmds: + for name, handler, num_args, _desc in cmds: if name !=3D cmd: continue - elif len(args) !=3D num_args: + if len(args) !=3D num_args: usage() return - else: - handler(fd, *args) - return + handler(fd, *args) + return print("Unknown command '%s'" % cmd) finally: fd.close() @@ -271,7 +319,7 @@ def usage(): print("Usage: %s [, ...]" % sys.argv[0]) print("") print("Supported commands:") - for name, handler, num_args, desc in cmds: + for name, _handler, _num_args, desc in cmds: print(" %-20s - %s" % (name, desc)) =20 if __name__ =3D=3D '__main__': --=20 2.21.1 From nobody Sat May 18 10:30:07 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 ARC-Seal: i=1; a=rsa-sha256; t=1589406409; cv=none; d=zohomail.com; s=zohoarc; b=YxpDSndq/rwQbgza6Bxh1FMr5RbwC8kTuX4LtGyRC0k8cUEJPGDF247m84Qo09XW5zbLa1ElqsZGY53lXDd+udw73WMUMUHIp7W2UjHsl8v9zyByHmjMMPaslu2XJqgCI3pb170KP4LnvfmeCxdpe3J5Y6eTnf+iWzw2k6S/dr0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589406409; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iyNNnc9x0rXIx3Mu60FEI9ELoLsFtzBiUEfAXdfLcn4=; b=HA1eEq7gVUrj9DugQZITvkecL/ZVk3bqaDhCGA4mFsUZ7mU9sbklmX/n4Oyq3L7/6GSNPOqakWwg5ZHTtti81il8N1XltLXJFAkuxoq7tcSrsMK4AF/m1qbhF/Kzv4CLQR66JAlR36szG02BGM2JyfwRmJjR/etGXMUpR5HXnlI= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589406409852771.8129328363573; Wed, 13 May 2020 14:46:49 -0700 (PDT) Received: from localhost ([::1]:53696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYzDE-0003WX-Lh for importer@patchew.org; Wed, 13 May 2020 17:46:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34104) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYz8M-00070X-IQ for qemu-devel@nongnu.org; Wed, 13 May 2020 17:41:46 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:22680 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jYz8K-0005c9-Eu for qemu-devel@nongnu.org; Wed, 13 May 2020 17:41:46 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-263-XM0gRJVDNV6C_KSAdPeGuA-1; Wed, 13 May 2020 17:41:38 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 654AA18C35B7; Wed, 13 May 2020 21:41:37 +0000 (UTC) Received: from probe.redhat.com (ovpn-113-80.rdu2.redhat.com [10.10.113.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id A328B1C94D; Wed, 13 May 2020 21:41:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589406103; 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=iyNNnc9x0rXIx3Mu60FEI9ELoLsFtzBiUEfAXdfLcn4=; b=QX8QAPcinYVuHtmIB81iqqoKZmteFRQ5L08YxZZ3weQvMnL+Hnu7szBVio29mYaOj0HLPY o+hiCN7d/MLtOJQoTPji3ZfIX9d92H87IDep3pIXqfq9ZYwb1yj6Y3fVhK4JySAGsTo3iQ /LuyC4t02bGilHfW1x06Hge05wkR/Xw= X-MC-Unique: XM0gRJVDNV6C_KSAdPeGuA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH RFC WIP 6/6] WIP: delint test files Date: Wed, 13 May 2020 17:41:30 -0400 Message-Id: <20200513214130.15375-7-jsnow@redhat.com> In-Reply-To: <20200513214130.15375-1-jsnow@redhat.com> References: <20200513214130.15375-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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=207.211.31.81; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/13 04:17:42 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, 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_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , ehabkost@redhat.com, qemu-block@nongnu.org, philmd@redhat.com, Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- tests/qemu-iotests/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/qemu-iotests/Makefile b/tests/qemu-iotests/Makefile index 77da9fd96d..fd85eb5bae 100644 --- a/tests/qemu-iotests/Makefile +++ b/tests/qemu-iotests/Makefile @@ -1,4 +1,6 @@ PYMODULES =3D $(wildcard *.py) +PYTESTS :=3D $(shell grep -rl '^\#!/usr/bin/env python3' *) +PYTESTS :=3D $(filter-out $(PYMODULES), $(PYTESTS)) =20 CLEANFILES=3D *.out.bad *.notrun check.log check.time* =20 @@ -10,3 +12,4 @@ clean: =20 delint: pylint $(PYMODULES) + pylint --disable=3DR,C,W $(PYTESTS) --=20 2.21.1