From nobody Mon Feb 9 18:18:49 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=1598019052; cv=none; d=zohomail.com; s=zohoarc; b=CpQ03vXXxIB+APLAfMVwvFIl4z6loxoHIGDKXki38hx/o8z2C9+FwlPneMMmrRej+UAC1KWAvV/MpywSPfiZpzZcrq+GUA3uKO3k0Vsjz7cBSlIXLRBdAtyQ3xWpLzFWrHkSZoEtGLM3HBoetSgIgU9bnXQQJlIeKdDUpuT9IPk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598019052; 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=dFTJI66gXbHFJpiFeUt37MLvYmD4RYoxQkVSz55LzJM=; b=Tt3Se8WQWSgqIkAllwSZn76cW1TiVovXEXyyKesySPIgZ10izQxH/HQsJlzByqGkgNDtobcAF+wVCtjsZcQTI5BVnszEWgQ9Q3hOpsLFWkBCrDYCKug5hkmFjGJpDfjw75a2+W9kAHqUnrnDDGbQgzv1NS4Q/gU/eWM08Zf5/IA= 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 1598019052592531.043160957153; Fri, 21 Aug 2020 07:10:52 -0700 (PDT) Received: from localhost ([::1]:41878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k97kp-0002Oh-Aq for importer@patchew.org; Fri, 21 Aug 2020 10:10:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k97j0-0007Md-42 for qemu-devel@nongnu.org; Fri, 21 Aug 2020 10:08:58 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:21958 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 1k97ix-0004Xd-5j for qemu-devel@nongnu.org; Fri, 21 Aug 2020 10:08:57 -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-467-co64W7f9MSOUk9jMUFP85Q-1; Fri, 21 Aug 2020 10:08:37 -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 65B1B101962B; Fri, 21 Aug 2020 14:08:36 +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 ED4D07AEC9; Fri, 21 Aug 2020 14:08:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598018934; 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=dFTJI66gXbHFJpiFeUt37MLvYmD4RYoxQkVSz55LzJM=; b=CQJ2hNUcIdQ79whHcWqgGE46c5FfKLQ23u9LgJ1LKumdPqKvRzkvoqJClDRZV34uAPYpaA PQYO6I6anwl++yclR3lqWgGXFWfuWA6jmvtJX7WuPkDBokHKfK16sClFadLj6RW0ry69DB 75kZoP12wayCvvPUKdu6cO8ixHdM3yQ= X-MC-Unique: co64W7f9MSOUk9jMUFP85Q-1 From: Eric Blake To: qemu-devel@nongnu.org Subject: [PULL 07/14] qcow2_format.py: Dump bitmap table serialized entries Date: Fri, 21 Aug 2020 09:08:19 -0500 Message-Id: <20200821140826.194322-8-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=207.211.31.81; 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 05:15:56 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 Add bitmap table information to the QCOW2 metadata dump. Bitmap name bitmap-1 ... Bitmap table type size offset 0 serialized 65536 10092544 1 all-zeroes 0 0 2 all-zeroes 0 0 Signed-off-by: Andrey Shinkevich Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <1596742557-320265-8-git-send-email-andrey.shinkevich@virtuozzo= .com> Signed-off-by: Eric Blake --- tests/qemu-iotests/303.out | 4 +++ tests/qemu-iotests/qcow2_format.py | 50 ++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/tests/qemu-iotests/303.out b/tests/qemu-iotests/303.out index 038ba93a87d7..70828e05f11f 100644 --- a/tests/qemu-iotests/303.out +++ b/tests/qemu-iotests/303.out @@ -66,6 +66,8 @@ type 1 granularity_bits 15 name_size 8 extra_data_size 0 +Bitmap table type size offset +0 serialized 65536 10092544 Bitmap name bitmap-2 bitmap_table_offset 0x9c0000 @@ -75,4 +77,6 @@ type 1 granularity_bits 16 name_size 8 extra_data_size 0 +Bitmap table type size offset +0 all-zeroes 0 0 diff --git a/tests/qemu-iotests/qcow2_format.py b/tests/qemu-iotests/qcow2_= format.py index ca0d3501e0a2..574249bc463c 100644 --- a/tests/qemu-iotests/qcow2_format.py +++ b/tests/qemu-iotests/qcow2_format.py @@ -175,6 +175,10 @@ class Qcow2BitmapDirEntry(Qcow2Struct): entry_raw_size =3D self.bitmap_dir_entry_raw_size() padding =3D ((entry_raw_size + 7) & ~7) - entry_raw_size fd.seek(padding, 1) + self.bitmap_table =3D Qcow2BitmapTable(fd=3Dfd, + offset=3Dself.bitmap_table_of= fset, + nb_entries=3Dself.bitmap_tabl= e_size, + cluster_size=3Dself.cluster_s= ize) def bitmap_dir_entry_raw_size(self): return struct.calcsize(self.fmt) + self.name_size + \ @@ -183,6 +187,52 @@ class Qcow2BitmapDirEntry(Qcow2Struct): def dump(self): print(f'{"Bitmap name":<25} {self.name}') super(Qcow2BitmapDirEntry, self).dump() + self.bitmap_table.dump() + + +class Qcow2BitmapTableEntry(Qcow2Struct): + + fields =3D ( + ('u64', '{}', 'entry'), + ) + + BME_TABLE_ENTRY_RESERVED_MASK =3D 0xff000000000001fe + BME_TABLE_ENTRY_OFFSET_MASK =3D 0x00fffffffffffe00 + BME_TABLE_ENTRY_FLAG_ALL_ONES =3D 1 + + def __init__(self, fd): + super().__init__(fd=3Dfd) + self.reserved =3D self.entry & self.BME_TABLE_ENTRY_RESERVED_MASK + self.offset =3D self.entry & self.BME_TABLE_ENTRY_OFFSET_MASK + if self.offset: + if self.entry & self.BME_TABLE_ENTRY_FLAG_ALL_ONES: + self.type =3D 'invalid' + else: + self.type =3D 'serialized' + elif self.entry & self.BME_TABLE_ENTRY_FLAG_ALL_ONES: + self.type =3D 'all-ones' + else: + self.type =3D 'all-zeroes' + + +class Qcow2BitmapTable: + + def __init__(self, fd, offset, nb_entries, cluster_size): + self.cluster_size =3D cluster_size + position =3D fd.tell() + fd.seek(offset) + self.entries =3D [Qcow2BitmapTableEntry(fd) for _ in range(nb_entr= ies)] + fd.seek(position) + + def dump(self): + bitmap_table =3D enumerate(self.entries) + print(f'{"Bitmap table":<14} {"type":<15} {"size":<12} {"offset"}') + for i, entry in bitmap_table: + if entry.type =3D=3D 'serialized': + size =3D self.cluster_size + else: + size =3D 0 + print(f'{i:<14} {entry.type:<15} {size:<12} {entry.offset}') QCOW2_EXT_MAGIC_BITMAPS =3D 0x23852875 --=20 2.28.0