From nobody Fri Nov 7 02:19:11 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545534307878449.41637757283627; Sat, 22 Dec 2018 19:05:07 -0800 (PST) Received: from localhost ([::1]:57574 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gau4g-0007GG-N6 for importer@patchew.org; Sat, 22 Dec 2018 22:05:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44355) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gau0x-00050Z-I5 for qemu-devel@nongnu.org; Sat, 22 Dec 2018 22:01:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gau0w-0005kp-KW for qemu-devel@nongnu.org; Sat, 22 Dec 2018 22:01:15 -0500 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:38859) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gau0u-0005bu-Lg; Sat, 22 Dec 2018 22:01:14 -0500 Received: by mail-pl1-x641.google.com with SMTP id e5so4253973plb.5; Sat, 22 Dec 2018 19:01:05 -0800 (PST) Received: from localhost.localdomain (114-136-27-106.emome-ip.hinet.net. [114.136.27.106]) by smtp.gmail.com with ESMTPSA id g190sm32610180pgc.28.2018.12.22.19.01.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Dec 2018 19:01:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=L1FR6ELX1uVFNnHrkM+ggycxAznG+B07guu3n9P38XE=; b=OBzb2wHtSmLwZqqJ73PAIwnx13iGUz+hARr+pLgYBnGVpCvEb15wtmlr9jbNNTQXGw 6eF1Y2b8cOJAAq6TaolvnbsBQORCZkGVVGvKOO533mhZ8D72oLlmQIzZTsdZXnlq+9GY CnudNg4BdcEcx4nVkmCD2KnR8cZao1zFeqmSXpUgV/WcO5CL080OZgxrBxyb+sXIGrMV Op5gi/WWyDuwY/owa6m+8ZHRchADrTPizKFF2K/rJG5upsKLdapMII97q6Q3UfN0z1pk RhmXZ8QiTkPPxvBxodXlW3QiDk22JzeG6WoVFZCvb7+Frz4Kx4F7PmqxWJzR5Hg95XFN Gqcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=L1FR6ELX1uVFNnHrkM+ggycxAznG+B07guu3n9P38XE=; b=KoJIfSXULa+aGQVuVwMj2u5RcoaTbVmtMmSmufWoS0QpVNcYV+7BLY93U2bNJ6eC9f T72WTXDhKVLMWCgMhbge/4yk9I5xDfzfJHRsUWlrnFnL8zaTDGzqJRyX5+Ml3LjPPhcB PB3gCHhXCZjZXsgTw70pulGLJf4gbDDXsq2Etj9GBhpG7DvDHBeVMN6VOcNA03KWAjkb V9bNsATLaZ6FDUkZxVt0arscNhKKOpSLkyBnBIUskuD7IkqmwQptuK+i1E0E1ruP5cZQ zaiTdT9opy12V7lIsmgAuMCmAgxdGHdkZG8xZoHLT7rGrTTYIrJJM6GN9jEdJDfHObqK ASOQ== X-Gm-Message-State: AJcUukdehvOHHxmcNuxzkgNW1PsVwoWyB/wGku8bh6U4mgsKsvoJUosM Kjocc6SFgvyLpmrvYgAq1CogHSiLvys= X-Google-Smtp-Source: ALg8bN795x5809+s0w6bazF4CbwGeNcQjKWYk+qbJIJJBJagTlRJGSJzhimBpgRDzWalnO7UyTh/2A== X-Received: by 2002:a17:902:2868:: with SMTP id e95mr8454480plb.317.1545534063892; Sat, 22 Dec 2018 19:01:03 -0800 (PST) From: yuchenlin To: qemu-devel@nongnu.org Date: Sun, 23 Dec 2018 10:59:37 +0800 Message-Id: <20181223025939.15775-2-npes87184@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181223025939.15775-1-npes87184@gmail.com> References: <20181223025939.15775-1-npes87184@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH v2 1/3] dmg: fix binary search X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yuchenlin , qemu-block@nongnu.org, stefanha@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" There is a possible hang in original binary search implementation. That is if chunk1 =3D 4, chunk2 =3D 5, chunk3 =3D 4, and we go else case. The chunk1 will be still 4, and so on. Signed-off-by: yuchenlin Reviewed-by: Julio Faracco --- block/dmg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/dmg.c b/block/dmg.c index 50e91aef6d..0e05702f5d 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -572,14 +572,14 @@ static inline uint32_t search_chunk(BDRVDMGState *s, = uint64_t sector_num) { /* binary search */ uint32_t chunk1 =3D 0, chunk2 =3D s->n_chunks, chunk3; - while (chunk1 !=3D chunk2) { + while (chunk1 <=3D chunk2) { chunk3 =3D (chunk1 + chunk2) / 2; if (s->sectors[chunk3] > sector_num) { - chunk2 =3D chunk3; + chunk2 =3D chunk3 - 1; } else if (s->sectors[chunk3] + s->sectorcounts[chunk3] > sector_n= um) { return chunk3; } else { - chunk1 =3D chunk3; + chunk1 =3D chunk3 + 1; } } return s->n_chunks; /* error */ --=20 2.17.1 From nobody Fri Nov 7 02:19:11 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545534209071501.5833383801647; Sat, 22 Dec 2018 19:03:29 -0800 (PST) Received: from localhost ([::1]:55552 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gau35-0005vD-O9 for importer@patchew.org; Sat, 22 Dec 2018 22:03:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44324) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gau0w-0004zb-Jb for qemu-devel@nongnu.org; Sat, 22 Dec 2018 22:01:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gau0u-0005ij-Jv for qemu-devel@nongnu.org; Sat, 22 Dec 2018 22:01:14 -0500 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:44727) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gau0u-0005eb-9W; Sat, 22 Dec 2018 22:01:12 -0500 Received: by mail-pl1-x641.google.com with SMTP id e11so4239356plt.11; Sat, 22 Dec 2018 19:01:08 -0800 (PST) Received: from localhost.localdomain (114-136-27-106.emome-ip.hinet.net. [114.136.27.106]) by smtp.gmail.com with ESMTPSA id g190sm32610180pgc.28.2018.12.22.19.01.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Dec 2018 19:01:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tCQ7M75vIzt+9JWvC8gbxrEs7r7SdiaDpSBrZK87RdM=; b=YK8olPpHpKtJ4z0hR1V1O7Xr+n6Ek9rn0qXPfv6iNR/kQhzuRmhG1g337OVcPRlA0H DU8i5ismbAmskzJXNUd3Oy3Adhcev8jrlCu2yw8+qVdkzx0Rrz00cQ81uHwv3oyfsDNL KmhjvVB3y8TwhTk/cpwQb0TEAxyIzTvjmOMO6uBOySXGBC58OZRm/PgTu3b/zdMKeHsx F8PS+bvBkNPgCPSIfV46M9jAP9BVIX9ABMSPORHuDyKdv90mTDpN4pNP+crkYEraOZJp 6x7e9jAHkbrlbXpIEpF0ZU9ctQFqyeQXok4FMw3+RhytOtu6iXFCnYGfexLNWXTM+Ztr 7A2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tCQ7M75vIzt+9JWvC8gbxrEs7r7SdiaDpSBrZK87RdM=; b=Nv/XQp7fbjE6Qx+BWdc3N1G6OYYG5+u6MqHX4nuy922VbYz8ZD6yU+OKpwKuFp1E4+ SoP72SmsoLGoD5MplZABfOPedzp1Hbc6ChZ8DZ6RBHObY0j3+Kh+B22KmOgOiMli5YMa 56SxNgFVgYsWFC7SH4Stda0YquORHJZbvzo4W6seq8jrxlHQjGf66hx5jHWMClQ6sOti +eycCIGm1gfLmRftXCXndTztZnPxCO5/UEqmnks2PMm+WFSeyIh5G4/Xg6awbNN2BRSj 5wwNPKabaxOZEy+YBPc+INcHH+jMH/CD7aAgyE2nQjhZi7OYftW50wL9aVXiUEwdOFEz Q/HQ== X-Gm-Message-State: AJcUukfDb0uL6mA0XaXTgUJ3Fevmd0RRj81sBYd3TTdxVcdupTcW6j/a t44ZI2V4hYWpjmN2/veGrAE3G8C0iu4= X-Google-Smtp-Source: ALg8bN75Fy4hqWj+8xlaAxD9brzL3+7Juk5gg8Q69B8sGSqZ1FSQvjHp/Bxp2MShbpqnN7L2+ITZNA== X-Received: by 2002:a17:902:4225:: with SMTP id g34mr8637921pld.152.1545534067145; Sat, 22 Dec 2018 19:01:07 -0800 (PST) From: yuchenlin To: qemu-devel@nongnu.org Date: Sun, 23 Dec 2018 10:59:38 +0800 Message-Id: <20181223025939.15775-3-npes87184@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181223025939.15775-1-npes87184@gmail.com> References: <20181223025939.15775-1-npes87184@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH v2 2/3] dmg: use enumeration type instead of hard coding number X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yuchenlin , qemu-block@nongnu.org, stefanha@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: yuchenlin Reviewed-by: Julio Faracco Reviewed-by: Stefan Hajnoczi --- block/dmg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/dmg.c b/block/dmg.c index 0e05702f5d..6b0a057bf8 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -267,7 +267,7 @@ static int dmg_read_mish_block(BDRVDMGState *s, DmgHead= erState *ds, =20 /* all-zeroes sector (type 2) does not need to be "uncompressed" a= nd can * therefore be unbounded. */ - if (s->types[i] !=3D 2 && s->sectorcounts[i] > DMG_SECTORCOUNTS_MA= X) { + if (s->types[i] !=3D UDIG && s->sectorcounts[i] > DMG_SECTORCOUNTS= _MAX) { error_report("sector count %" PRIu64 " for chunk %" PRIu32 " is larger than max (%u)", s->sectorcounts[i], i, DMG_SECTORCOUNTS_MAX); @@ -706,7 +706,7 @@ dmg_co_preadv(BlockDriverState *bs, uint64_t offset, ui= nt64_t bytes, /* Special case: current chunk is all zeroes. Do not perform a mem= cpy as * s->uncompressed_chunk may be too small to cover the large all-z= eroes * section. dmg_read_chunk is called to find s->current_chunk */ - if (s->types[s->current_chunk] =3D=3D 2) { /* all zeroes block ent= ry */ + if (s->types[s->current_chunk] =3D=3D UDIG) { /* all zeroes block = entry */ qemu_iovec_memset(qiov, i * 512, 0, 512); continue; } --=20 2.17.1 From nobody Fri Nov 7 02:19:11 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545534210047383.4180147590222; Sat, 22 Dec 2018 19:03:30 -0800 (PST) Received: from localhost ([::1]:55585 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gau36-0005wH-Kz for importer@patchew.org; Sat, 22 Dec 2018 22:03:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44359) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gau0x-00050g-MV for qemu-devel@nongnu.org; Sat, 22 Dec 2018 22:01:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gau0w-0005kj-Km for qemu-devel@nongnu.org; Sat, 22 Dec 2018 22:01:15 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:46261) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gau0u-0005gU-K6; Sat, 22 Dec 2018 22:01:14 -0500 Received: by mail-pl1-x644.google.com with SMTP id t13so4235295ply.13; Sat, 22 Dec 2018 19:01:10 -0800 (PST) Received: from localhost.localdomain (114-136-27-106.emome-ip.hinet.net. [114.136.27.106]) by smtp.gmail.com with ESMTPSA id g190sm32610180pgc.28.2018.12.22.19.01.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Dec 2018 19:01:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MShGp47QRiQwWuK+yf1CJXsrfpB6HDhws8Iyenae/sE=; b=XPYYsGkqDyOj6a/onq5TSGLpYMDOOa9oVXI29V1d2e8ADZkLY/NFae2DNXikIR/fSc oTn33PfG7wOPaOfHKB8MaKVXiQxxRBVWIpxbL7Ehc3Q8amkZHIMZUljLAVKurWiSO9IB KvR8MMO/zwl4IefQ6dGZ/oOMoislqsEXuiBZjneGnAEap5+kFSJJgUShDxP4Mx1Z+g0T IAQkPSBDbC/t69pohNhGIbTbyNJ7yN2NKjXX8pnV5CBV2e/pO29xdul+jo4PgyrgmPXZ UzXM+4k6YZl99/RJKSeqENYlHT/h7BibpLCIwXUoqhfIOO8DZH4kn1/UTdgrW3Q7r9HP cWiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MShGp47QRiQwWuK+yf1CJXsrfpB6HDhws8Iyenae/sE=; b=IVmNrSauNaaZbCnMQxtwgiA9BYJu5AzoCprLBYns0yfJv+Wi4PQAQe1kpGqUJ76bRe WeJqh1R5dYlgkQ+QXhypJm/GHL8J4KiTRPHo/YyJ90+drRI90PleTh/d3/B+6BcEBX6U 0SbAYBvGy1i7chfBEu7zYkQgT+FdlCYWlxCXN3ZOyuZ6E+nnRQUExeOuLddVO3BQXT0a b+lYT2opdXcOfO+fPO8tNpe33LYpbN4S2gJPWr+ZkRB+NqjLh4KCmEeJ/isHMO3Sb0Wp k4BPimtehGDtd4U984/CDxUqIOslVNE6l4Grcp9QHAdtmmD4mDl9jgXTkLVlPfdBZ8hi pE8g== X-Gm-Message-State: AJcUukfN7rtwEQgfemY4t3F9vhX+iRIazqIEL68lWMapnJxjwI/XYnCU 40BWrJQnTHHhbGofQZ1S7DF6E4zVm0E= X-Google-Smtp-Source: ALg8bN7sOCMr/rXvmIt061/HLRGgMnKD0ZqKW/GjPZTBCz3L3Zo7udXpU8s0MSb20iaWOH+wjH9jFg== X-Received: by 2002:a17:902:aa8c:: with SMTP id d12mr8587783plr.25.1545534069828; Sat, 22 Dec 2018 19:01:09 -0800 (PST) From: yuchenlin To: qemu-devel@nongnu.org Date: Sun, 23 Dec 2018 10:59:39 +0800 Message-Id: <20181223025939.15775-4-npes87184@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181223025939.15775-1-npes87184@gmail.com> References: <20181223025939.15775-1-npes87184@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 Subject: [Qemu-devel] [PATCH v2 3/3] dmg: don't skip zero chunk X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yuchenlin , qemu-block@nongnu.org, stefanha@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The dmg file has many tables which describe: "start from sector XXX to sector XXX, the compression method is XXX and where the compressed data resides on". Each sector in the expanded file should be covered by a table. The table will describe the offset of compressed data (or raw depends on the type) in the dmg. For example: [-----------The expanded file------------] [---bzip table ---]/* zeros */[---zlib---] ^ | if we want to read this sector. we will find bzip table which contains this sector, and get the compressed data offset, read it from dmg, uncompress it, finally write to expanded file. If we skip zero chunk (table), some sector cannot find the table which will cause search_chunk() return s->n_chunks, dmg_read_chunk() return -1 and finally causing dmg_co_preadv() return EIO. See: [-----------The expanded file------------] [---bzip table ---]/* zeros */[---zlib---] ^ | if we want to read this sector. Oops, we cannot find the table contains it... In the original implementation, we don't have zero table. When we try to read sector inside the zero chunk. We will get EIO, and skip reading. After this patch, we treat zero chunk the same as ignore chunk, it will directly write zero and avoid some sector may not find the table. After this patch: [-----------The expanded file------------] [---bzip table ---][--zeros--][---zlib---] Signed-off-by: yuchenlin Reviewed-by: Julio Faracco Reviewed-by: Stefan Hajnoczi --- block/dmg.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/block/dmg.c b/block/dmg.c index 6b0a057bf8..137fe9c1ff 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -130,7 +130,8 @@ static void update_max_chunk_size(BDRVDMGState *s, uint= 32_t chunk, case UDRW: /* copy */ uncompressed_sectors =3D DIV_ROUND_UP(s->lengths[chunk], 512); break; - case UDIG: /* zero */ + case UDZE: /* zero */ + case UDIG: /* ignore */ /* as the all-zeroes block may be large, it is treated specially: = the * sector is not copied from a large buffer, a simple memset is us= ed * instead. Therefore uncompressed_sectors does not need to be set= . */ @@ -199,8 +200,9 @@ typedef struct DmgHeaderState { static bool dmg_is_known_block_type(uint32_t entry_type) { switch (entry_type) { + case UDZE: /* zeros */ case UDRW: /* uncompressed */ - case UDIG: /* zeroes */ + case UDIG: /* ignore */ case UDZO: /* zlib */ return true; case UDBZ: /* bzip2 */ @@ -265,9 +267,10 @@ static int dmg_read_mish_block(BDRVDMGState *s, DmgHea= derState *ds, /* sector count */ s->sectorcounts[i] =3D buff_read_uint64(buffer, offset + 0x10); =20 - /* all-zeroes sector (type 2) does not need to be "uncompressed" a= nd can - * therefore be unbounded. */ - if (s->types[i] !=3D UDIG && s->sectorcounts[i] > DMG_SECTORCOUNTS= _MAX) { + /* all-zeroes sector (type UDZE and UDIG) does not need to be + * "uncompressed" and can therefore be unbounded. */ + if (s->types[i] !=3D UDZE && s->types[i] !=3D UDIG + && s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) { error_report("sector count %" PRIu64 " for chunk %" PRIu32 " is larger than max (%u)", s->sectorcounts[i], i, DMG_SECTORCOUNTS_MAX); @@ -671,7 +674,8 @@ static inline int dmg_read_chunk(BlockDriverState *bs, = uint64_t sector_num) return -1; } break; - case UDIG: /* zero */ + case UDZE: /* zeros */ + case UDIG: /* ignore */ /* see dmg_read, it is treated specially. No buffer needs to be * pre-filled, the zeroes can be set directly. */ break; @@ -706,7 +710,8 @@ dmg_co_preadv(BlockDriverState *bs, uint64_t offset, ui= nt64_t bytes, /* Special case: current chunk is all zeroes. Do not perform a mem= cpy as * s->uncompressed_chunk may be too small to cover the large all-z= eroes * section. dmg_read_chunk is called to find s->current_chunk */ - if (s->types[s->current_chunk] =3D=3D UDIG) { /* all zeroes block = entry */ + if (s->types[s->current_chunk] =3D=3D UDZE + || s->types[s->current_chunk] =3D=3D UDIG) { /* all zeroes blo= ck entry */ qemu_iovec_memset(qiov, i * 512, 0, 512); continue; } --=20 2.17.1