From nobody Mon Feb 9 22:18:59 2026 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=1598019240; cv=none; d=zohomail.com; s=zohoarc; b=cBXYgHrkPZ9CbySbmP1KeDi8S7sQNd4NFjC7vtKRXMFQ2siQgsay0zZP9Qwi7usHHf627+C5OpBfSwGer0M4J+A5zpODVgLncF3VIK26pq3pXHRPnRtynIko6/HcbbbqsWJ0za1SwzWzzwvzP0Tn3I56vUf/wznbTrphpIsKDno= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598019240; 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=XOclbXnZE4kY6hOS/0TCAiAkVWRtcrn3Emkrekd17sQ=; b=CS1c1oDnuvUCwSKMZQql+C9VAEkWm50P6k0cbWRi3jDa6JPRWsJhN4I2a1rBEkjlLNXpqX5sTKfPhBP+HS5dcibBAxtenSmaSbWdXvq55Uq//NGph+AFXFlmXVaeMqOBOrV8LkbzCrMvs0SIggkiz/QG+nA0qTLtdlAl+BGGfps= 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 1598019240096773.4252608046804; Fri, 21 Aug 2020 07:14:00 -0700 (PDT) Received: from localhost ([::1]:57166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k97np-0000HG-Qk for importer@patchew.org; Fri, 21 Aug 2020 10:13:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k97iv-00079z-Pk for qemu-devel@nongnu.org; Fri, 21 Aug 2020 10:08:53 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:55937 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 1k97it-0004WG-To for qemu-devel@nongnu.org; Fri, 21 Aug 2020 10:08:53 -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-398-1pq0FeeePj2s11Vrpbwwpg-1; Fri, 21 Aug 2020 10:08:32 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0984A18A2245; Fri, 21 Aug 2020 14:08:31 +0000 (UTC) Received: from blue.redhat.com (ovpn-113-220.phx2.redhat.com [10.3.113.220]) by smtp.corp.redhat.com (Postfix) with ESMTP id 930A67A40B; Fri, 21 Aug 2020 14:08:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598018930; 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=XOclbXnZE4kY6hOS/0TCAiAkVWRtcrn3Emkrekd17sQ=; b=A6lJs0ojhyPQG0XpaxJ9tml4K5+NFSVdsCeNbwP8y99n1lbvo316esKNBwCPFXPaDrsXSi TATB9bRXGhB/UEMihslvvfgkXUvC+RxbZ1K47Kv7OXsjbXpygenJGkdRzD/wIDLvR87T6Y ycSg39AAHajEwGpHPPhj9ZjckEtm9+A= X-MC-Unique: 1pq0FeeePj2s11Vrpbwwpg-1 From: Eric Blake To: qemu-devel@nongnu.org Subject: [PULL 03/14] qcow2_format.py: change Qcow2BitmapExt initialization method Date: Fri, 21 Aug 2020 09:08:15 -0500 Message-Id: <20200821140826.194322-4-eblake@redhat.com> In-Reply-To: <20200821140826.194322-1-eblake@redhat.com> References: <20200821140826.194322-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eblake@redhat.com X-Mimecast-Spam-Score: 0.001 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=eblake@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/21 01:00:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=unavailable autolearn_force=no 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 , Andrey Shinkevich , Vladimir Sementsov-Ogievskiy , "open list:Block layer core" , Max Reitz 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" From: Andrey Shinkevich There are two ways to initialize a class derived from Qcow2Struct: 1. Pass a block of binary data to the constructor. 2. Pass the file descriptor to allow reading the file from constructor. Let's change the Qcow2BitmapExt initialization method from 1 to 2 to support a scattered reading in the initialization chain. The implementation comes with the patch that follows. Suggested-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Andrey Shinkevich Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <1596742557-320265-4-git-send-email-andrey.shinkevich@virtuozzo= .com> Signed-off-by: Eric Blake --- tests/qemu-iotests/qcow2_format.py | 34 ++++++++++++++++++------------ 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/tests/qemu-iotests/qcow2_format.py b/tests/qemu-iotests/qcow2_= format.py index 2f3681bb5f7c..d4a997453758 100644 --- a/tests/qemu-iotests/qcow2_format.py +++ b/tests/qemu-iotests/qcow2_format.py @@ -113,6 +113,11 @@ class Qcow2BitmapExt(Qcow2Struct): ('u64', '{:#x}', 'bitmap_directory_offset') ) + def __init__(self, fd): + super().__init__(fd=3Dfd) + tail =3D struct.calcsize(self.fmt) % 8 + if tail: + fd.seek(8 - tail, 1) QCOW2_EXT_MAGIC_BITMAPS =3D 0x23852875 @@ -161,21 +166,24 @@ class QcowHeaderExtension(Qcow2Struct): else: assert all(v is None for v in (magic, length, data)) super().__init__(fd=3Dfd) - padded =3D (self.length + 7) & ~7 - self.data =3D fd.read(padded) - assert self.data is not None + if self.magic =3D=3D QCOW2_EXT_MAGIC_BITMAPS: + self.obj =3D Qcow2BitmapExt(fd=3Dfd) + self.data =3D None + else: + padded =3D (self.length + 7) & ~7 + self.data =3D fd.read(padded) + assert self.data is not None + self.obj =3D None - data_str =3D self.data[:self.length] - if all(c in string.printable.encode('ascii') for c in data_str): - data_str =3D f"'{ data_str.decode('ascii') }'" - else: - data_str =3D '' - self.data_str =3D data_str + if self.data is not None: + data_str =3D self.data[:self.length] + if all(c in string.printable.encode( + 'ascii') for c in data_str): + data_str =3D f"'{ data_str.decode('ascii') }'" + else: + data_str =3D '' + self.data_str =3D data_str - if self.magic =3D=3D QCOW2_EXT_MAGIC_BITMAPS: - self.obj =3D Qcow2BitmapExt(data=3Dself.data) - else: - self.obj =3D None def dump(self): super().dump() --=20 2.28.0