From nobody Fri Nov 7 02:09:58 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1546516175456987.6015201336523; Thu, 3 Jan 2019 03:49:35 -0800 (PST) Received: from localhost ([127.0.0.1]:52792 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gf1V7-0001n1-8x for importer@patchew.org; Thu, 03 Jan 2019 06:49:25 -0500 Received: from eggs.gnu.org ([208.118.235.92]:53055) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gf1TK-0000Um-Ux for qemu-devel@nongnu.org; Thu, 03 Jan 2019 06:47:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gf1TK-0003SN-CS for qemu-devel@nongnu.org; Thu, 03 Jan 2019 06:47:34 -0500 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:37391) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gf1TK-0003S1-71; Thu, 03 Jan 2019 06:47:34 -0500 Received: by mail-pf1-x442.google.com with SMTP id y126so16600854pfb.4; Thu, 03 Jan 2019 03:47:34 -0800 (PST) Received: from localhost.localdomain (223-137-100-47.emome-ip.hinet.net. [223.137.100.47]) by smtp.gmail.com with ESMTPSA id t67sm103011808pfd.90.2019.01.03.03.47.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Jan 2019 03:47:32 -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=JrqOcFUpKvSl7P5WLgjrOg0Yk69+g6Qle5b6/IqyXG4=; b=sd2SF7vkDgy+5YCdwyVCKiFc3N8lhOLkTCEBUoDMr4SEtnmn2QX+Ift/OC71o0IToa 6b5TIIhD+Msib5KT0kc6lrqujeEh++RzK04krrswZxKH/nLMDZKx+/iiDEaSZVExPIdd Cv/lJLanU2cVMgn27YG2by7xOftRUeRTo/cxnWDENuvYIoh6E9ixYdUzvjwooHCn8s3C uERA0Iumy+gzX0D+rEsF/dEqDQLSsmNGUXTvqzcByFntuOAcrzf2irdJDwUXmmyDlUMR XM3xTw54suEJtCV9RA1JGnJ1iDbv956xTkVPo928yxQ5qUDeG187MNYoweciLwyY9lPG A5Ug== 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=JrqOcFUpKvSl7P5WLgjrOg0Yk69+g6Qle5b6/IqyXG4=; b=cDFvDBekv5YqEUASZZzomuPNAOm/mbJMoaRM0tCwhnXyJ8mJwU9LqWTeudUrvNe6Lr x/WjTwGddIBU0jM83cr2AxlIAvIUqE69WSa+sZAASWr6GwlxUheVO2EnJFyMlcxUIg4/ 7oIT3sd/3UxC/jCVzPYtVds61qpnz9KeijtnCE/tjH2st/DTGQtahh1p2dT0iTrYMDa7 9geg6ulWHc4wUwqEqT+ZkYhAEH0muO0gQl9ZManbpsbA9rsjMljfpQAFtXeHG2vCIcJ6 U6DMn4Y2YtYANUvIv2+IiOyOgU97FGRBBTOGs2Bbx5FsG5WKsQa68gS1n7xjnmjVoV39 Sw3g== X-Gm-Message-State: AA+aEWbTazTrAIG8/I2Wl4mDuLFPcB+akyOYkQ1f4n3OiLdmLr7yr6Lc KuuNjmtZqCOEZKgPY8Uwa2B7kOy4MEc= X-Google-Smtp-Source: AFSGD/UMi80B1ArgmlfmajygcavPVnLUtIXwIq7L4c1O5wOPShraQE1j1mPYhqf2Rzmwm83wt1tIFQ== X-Received: by 2002:a62:5dd1:: with SMTP id n78mr47287101pfj.58.1546516052968; Thu, 03 Jan 2019 03:47:32 -0800 (PST) From: yuchenlin To: qemu-devel@nongnu.org Date: Thu, 3 Jan 2019 19:46:58 +0800 Message-Id: <20190103114700.9686-2-npes87184@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190103114700.9686-1-npes87184@gmail.com> References: <20190103114700.9686-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::442 Subject: [Qemu-devel] [PATCH v3 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 --- block/dmg.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/block/dmg.c b/block/dmg.c index 50e91aef6d..65a0140487 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -572,16 +572,20 @@ 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; + if (chunk3 =3D=3D 0) { + goto err; + } + 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; } } +err: return s->n_chunks; /* error */ } =20 --=20 2.17.1 From nobody Fri Nov 7 02:09:58 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 154651617575327.20603731984727; Thu, 3 Jan 2019 03:49:35 -0800 (PST) Received: from localhost ([127.0.0.1]:52794 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gf1VG-000204-IO for importer@patchew.org; Thu, 03 Jan 2019 06:49:34 -0500 Received: from eggs.gnu.org ([208.118.235.92]:53102) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gf1TT-0000e1-EM for qemu-devel@nongnu.org; Thu, 03 Jan 2019 06:47:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gf1TQ-0003VO-Aj for qemu-devel@nongnu.org; Thu, 03 Jan 2019 06:47:43 -0500 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:38834) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gf1TQ-0003VC-5C; Thu, 03 Jan 2019 06:47:40 -0500 Received: by mail-pf1-x444.google.com with SMTP id q1so16588328pfi.5; Thu, 03 Jan 2019 03:47:40 -0800 (PST) Received: from localhost.localdomain (223-137-100-47.emome-ip.hinet.net. [223.137.100.47]) by smtp.gmail.com with ESMTPSA id t67sm103011808pfd.90.2019.01.03.03.47.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Jan 2019 03:47:38 -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=gWVFu9fUEmfepDQxhrrY+x7XCltFAktAN40YlpHKl3Y=; b=StOirCH1YcQrz6HCBiwknoIPFieNnxszAybcCj0Dtul2jOGtUbBdGa4OtVGRVRVjcg WbOMkXzTlAooszGsH2tcEqdgaEdONzsTkJBuxvB2/vGrTa8/ypgKV+kJdDF0mOTj22yK SEyyK0InvaQuwRJNfinCTKl9xFJ5kyGzRJoNbZ2mtFU85SpftXs7JIopFc8aq+/+FUE7 kgaxTU4XDu4eivQlb77qwZuOYp9iOz4/k1ntbC8ik0ekg+2MufkK8EpuMRqrsDNLLFIL C7k2TEBhIEvolpFvtKHtSGPabjs7LDQmrv3s9e4q7ZciCIQNrqyFXOlJXPt3DCI1GtJR azDA== 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=gWVFu9fUEmfepDQxhrrY+x7XCltFAktAN40YlpHKl3Y=; b=r3vT2mtBt4nZ5YxH8GnOvOGFBRIGavSPisabh6BPtQplWelHeBbwaK5559eiclC/i8 8HqeFPmGFH9HPbV2SFyEV8EjZm8NclagcDROCG7c+Rvdrui0kEndDtaqCp0PKE65leH9 UBmC25LcEiM7Sdh/tuxgDJ9Axe5U1BLFD4RcKi6WhBMkbD91iWfD+kINaawJjZkvwahE bnxMY45T1Myyv9TFzYwLA+PZAiYmIJBO7yscwF32MC69SfRYwQl9IGbdrg+bqoGOULKr qP3KxdbtQhOQasNOCKceeqG0jBsSH7vGjSu1yhG7PSaUzD8BdHmFBg7EBSOBN5b0tIVc 5XzQ== X-Gm-Message-State: AJcUukfKNCCYEg2Z3hqWHy0y2qmnx4NfNb+V+j2QpsTn8c5CHlsg5Q9k QvpuBsR3+N1RaEsROl8E61O3Qpzmtqw= X-Google-Smtp-Source: ALg8bN4d+ko5YK6UZVg2cMrwmuedbW7z4DZLyHruJcTwPTlI02hp5YiL7uvv54cgRn7JBJo+jgJjDw== X-Received: by 2002:a63:f844:: with SMTP id v4mr16603431pgj.82.1546516058877; Thu, 03 Jan 2019 03:47:38 -0800 (PST) From: yuchenlin To: qemu-devel@nongnu.org Date: Thu, 3 Jan 2019 19:46:59 +0800 Message-Id: <20190103114700.9686-3-npes87184@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190103114700.9686-1-npes87184@gmail.com> References: <20190103114700.9686-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::444 Subject: [Qemu-devel] [PATCH v3 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 65a0140487..9758482131 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); @@ -710,7 +710,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:09:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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=listsout.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.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=gmail.com Return-Path: Received: from listsout.gnu.org (listsout.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 154651627706954.75090057003024; Thu, 3 Jan 2019 03:51:17 -0800 (PST) Received: from localhost ([127.0.0.1]:52817 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gf1Wt-0003s6-Ua for importer@patchew.org; Thu, 03 Jan 2019 06:51:15 -0500 Received: from eggs.gnu.org ([208.118.235.92]:53130) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gf1TW-0000i2-A9 for qemu-devel@nongnu.org; Thu, 03 Jan 2019 06:47:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gf1TU-0003XS-Rj for qemu-devel@nongnu.org; Thu, 03 Jan 2019 06:47:46 -0500 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:41212) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gf1TU-0003X2-MB; Thu, 03 Jan 2019 06:47:44 -0500 Received: by mail-pg1-x542.google.com with SMTP id m1so15924711pgq.8; Thu, 03 Jan 2019 03:47:44 -0800 (PST) Received: from localhost.localdomain (223-137-100-47.emome-ip.hinet.net. [223.137.100.47]) by smtp.gmail.com with ESMTPSA id t67sm103011808pfd.90.2019.01.03.03.47.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Jan 2019 03:47:43 -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=ECjJODVG7RHE2yh+0zGzQM26frs1LXFHcmZRJ3Nk260=; b=H5gM42NSnSJKbyVY9W9No+/jgS3KFaMKr2/I3IYkiTjpYBhR+fmh6S2as2v5m1ttjZ 4OIX1xGuqHaat4VNOrb20yp3JUzpT8ZnttYCKZqo1gtSeUSEkR37t4To9mZ9M0e7blzp 8+p4QyeodwMN7S16/w1q6rSqrlDqQoYLjjrXdqnfliWjl5eCk+cnELXOwbCW8ypAvx2b 016L0I3lPJPcLRz07WUaZ6T4ZysLPBLyz7ZctvjtwwDN8HSoKmQBZiJS5ogYg4AG6BxW utMSA/95NC8QplULUR0iHBiJK9wpsc2B3WiQF8VWmlUgKlNju/AtY8uyAkKj2oFA3hM7 3auw== 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=ECjJODVG7RHE2yh+0zGzQM26frs1LXFHcmZRJ3Nk260=; b=dkbU9EXqIey6MtP1ryS40xI+YzaoYlP8Uko3ZmofhUHPSZvjhn4oPr3u5NccFTsHsa IbEfcnt9yW63LzoqZ8xKUPu19nUo5MWaN7VXmQN2m3K7+uZWqUG3fgAFC9igzwb7mwUk jNU8xnMJ+ecS4gKClwnDHqtIbdy8/vVoV8cWIsyJ21Pixf268entyMDFjXAcp6/81+4x fXcPg5dw9Vqav6iT0zMvg2fi/bTnn8k8/gLCaSV3XA9Rs1w8yCs+wxZLmIybSfqXbI04 a8mfvbyWIstavxbS3+90H9YJba0k2M4AUOpmtVdW5Xk5mR5BiKCk7T0C5mv0Gxqqo+Om 9z3w== X-Gm-Message-State: AJcUukcO9nb3hmHwzolZmbY4iz6FS/lkGrgdu69sRw1tXFPV6XWKAEyF 23VcsNPgMHAU1TG2QdprYzx4uqkWxHc= X-Google-Smtp-Source: ALg8bN4fL+1NIjkvappk5z+Sj4Ir2n6s7/1+c6dVQc++GjHoKCficcF1zaq2PdZMUwkiu7qRz9+mAg== X-Received: by 2002:a63:3602:: with SMTP id d2mr16453433pga.404.1546516063421; Thu, 03 Jan 2019 03:47:43 -0800 (PST) From: yuchenlin To: qemu-devel@nongnu.org Date: Thu, 3 Jan 2019 19:47:00 +0800 Message-Id: <20190103114700.9686-4-npes87184@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190103114700.9686-1-npes87184@gmail.com> References: <20190103114700.9686-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::542 Subject: [Qemu-devel] [PATCH v3 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 9758482131..351f2991a7 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); @@ -675,7 +678,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; @@ -710,7 +714,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