From nobody Fri May 3 07:33:10 2024 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493150445876588.8554881454245; Tue, 25 Apr 2017 13:00:45 -0700 (PDT) Received: from localhost ([::1]:51183 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d36dg-0007xQ-KG for importer@patchew.org; Tue, 25 Apr 2017 16:00:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d36bu-0006ja-1x for qemu-devel@nongnu.org; Tue, 25 Apr 2017 15:58:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d36bt-0003uo-D3 for qemu-devel@nongnu.org; Tue, 25 Apr 2017 15:58:54 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:35690) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d36bt-0003uT-7G; Tue, 25 Apr 2017 15:58:53 -0400 Received: by mail-pf0-x241.google.com with SMTP id a188so12347592pfa.2; Tue, 25 Apr 2017 12:58:53 -0700 (PDT) Received: from linux.local ([157.51.23.94]) by smtp.gmail.com with ESMTPSA id y187sm37931530pfy.67.2017.04.25.12.58.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Apr 2017 12:58:51 -0700 (PDT) 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=IlnxF6kfjqlPCG3CQGlgRbUb7F2oQkuehDnoRyUmjOE=; b=AirGPs4iJ33o7v9+STaDnU+TYPur5AIcXMVYQjcm4yWCnD/MIsaAXKqIJgqRbiBBVj CCWxIgdEpI8K5K0HTIdOnwMvMmw28BpTgYaIo8DKP4MzAolDDCTOJyQMyLmwoPjcrkmg JtlUlCSHD/kX2ojCmZwSW4poJ2t1d8KqFEvFCJipN3X90d0peOUfSr3WOskeT/lpQ6k5 JwWbQKN3rRD5yTQvwRg6QxsL795Uy7BBADiugM7zz8GOorrkfdxR8mTU3nSUFQhN3gSN E7HpAuYjX868MUqa8oUn19X565IwkuhUE8W8Fov6B0cOJxZI/CVFWzBkRA9ptTLJBJns tOrQ== 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=IlnxF6kfjqlPCG3CQGlgRbUb7F2oQkuehDnoRyUmjOE=; b=SH/czzvYCPu4p+fKsOlKEcj3p6NnGaUlDqPHfMAk5D6czVx+4Ht84L77E4AFUk2YXk BNl1P/cKlc9g07uqbRmKDazGTLIw83piolkTVNAlpa5qiHR59S3qYyyArHnTMdufWPUj PRvT6ShmGD7fbPbV/mcstEGLbNXg4BhWpnv0Ff8whs4dVHqa/upQNHmfISWxDQ49fJ8p gzOl3v2+T4uQPenz3GW15v6fThW5Vc6AyGCDZ26/l5dROhm5Njbex42rJGiat3uY+4L4 6cAAZrxNIiMvtmYrV3gSoCSbw8dkx3YgW/Sr99O3jPPhpnehsrhME/EE645K+NbdYsCJ 5l3Q== X-Gm-Message-State: AN3rC/4ZnRuHZ/GuxykIboSUgLJn5OFqdD0HngRI/JFNTuNaaPESNKZI H3FKnfDrXp+xcw== X-Received: by 10.84.176.100 with SMTP id u91mr39255274plb.39.1493150332167; Tue, 25 Apr 2017 12:58:52 -0700 (PDT) From: Ashijeet Acharya To: stefanha@gmail.com Date: Wed, 26 Apr 2017 01:29:04 +0530 Message-Id: <1493150351-28918-2-git-send-email-ashijeetacharya@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1493150351-28918-1-git-send-email-ashijeetacharya@gmail.com> References: <1493150351-28918-1-git-send-email-ashijeetacharya@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH v1 1/8] dmg: Introduce a new struct to cache random access points 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: kwolf@redhat.com, famz@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, mreitz@redhat.com, peter@lekensteyn.nl, Ashijeet Acharya , jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We need to cache the random access point while performing partial decompression so that we can resume decompression from that point onwards in our next sequential read request. Introduce a new struct DMGReadState which will help us do this. Signed-off-by: Ashijeet Acharya --- block/dmg.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/block/dmg.h b/block/dmg.h index b592d6f..ee67ae1 100644 --- a/block/dmg.h +++ b/block/dmg.h @@ -31,6 +31,15 @@ #include "block/block_int.h" #include =20 +/* used to cache current position in compressed input stream */ +typedef struct DMGReadState { + uint8_t *saved_next_in; + int64_t saved_avail_in; + int32_t saved_chunk_type; + int64_t sectors_read; /* possible sectors read in each cycle */ + int32_t sector_offset_in_chunk; +} DMGReadState; + typedef struct BDRVDMGState { CoMutex lock; /* each chunk contains a certain number of sectors, @@ -51,6 +60,7 @@ typedef struct BDRVDMGState { uint8_t *compressed_chunk; uint8_t *uncompressed_chunk; z_stream zstream; + DMGReadState *drs; } BDRVDMGState; =20 extern int (*dmg_uncompress_bz2)(char *next_in, unsigned int avail_in, --=20 2.6.2 From nobody Fri May 3 07:33:10 2024 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493150504860611.4253658139501; Tue, 25 Apr 2017 13:01:44 -0700 (PDT) Received: from localhost ([::1]:51189 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d36ed-0000IN-GF for importer@patchew.org; Tue, 25 Apr 2017 16:01:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52525) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d36c2-0006re-Rl for qemu-devel@nongnu.org; Tue, 25 Apr 2017 15:59:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d36bz-0003x9-Nt for qemu-devel@nongnu.org; Tue, 25 Apr 2017 15:59:02 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:34375) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d36bz-0003x5-IX; Tue, 25 Apr 2017 15:58:59 -0400 Received: by mail-pg0-x243.google.com with SMTP id t7so9745156pgt.1; Tue, 25 Apr 2017 12:58:59 -0700 (PDT) Received: from linux.local ([157.51.23.94]) by smtp.gmail.com with ESMTPSA id y187sm37931530pfy.67.2017.04.25.12.58.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Apr 2017 12:58:58 -0700 (PDT) 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=vKRWlpiWK/pGAzUMPnNXBO77u7wg9oKIRckfGdnlhB4=; b=Jw2OL/rYJTcCNEOV8CnxmIeECTs5yGEQamrvjP47fnGC8ie3Ma5wd5Mg9CX5FVoYTx 8O/E/9czXDQYq+EGK4qClSDrFQezLJqIyCMKCSpnowzmiYuhgYU49syNBmjsAqziETGI PvgHLCPkCY1HWBQN8y4DxO/7rzq+se10+sQXY8F0BSY8AbYOIjSLT82IwBOBtUb9YWGC i6vwUglgGSoRwEkBd3TDCWjta7kKeiEyK4UZffFWlZeh1b20j1M9HDQ+D0UUQGI1mS1X eYMlfahgmshGbbInBcUOcDQzMdeiVU8IoFsffYmDZITGuvdqYkoBKYm4OJ95hs2nLQaB 39XQ== 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=vKRWlpiWK/pGAzUMPnNXBO77u7wg9oKIRckfGdnlhB4=; b=oSBnOFXtb1XIkS0iYtnmKEP9qObybQycxYJmLy2C7gO/yyMIy395+jpYN9fcQ+Lvmg ZVr9JJCPltcbfXDyz+AckkVXZQRzaBpKbDTzO7IPWx4AhSZMmrymyKQPMTEpIwLQF6+f WT0XBaaTzpQ/tp51KHciYzx7i/O/R3CeemwTEhIFAwLX/JPVsQTNmksxGkHR+/8IcPIl 3kfsiuQNt/jGhsJ1FY84wp57NpTVekMjaxlTTRQjyFRRY7MaU3MW5kfayzJgXSQUXQ2y 8CKsJrSkRqUY1xBINaqCqVY65Qs8eq7pyGfBQkKhDCmTUCD8heKdjj94wMDRhtF5tntV OJbA== X-Gm-Message-State: AN3rC/7DvIf4yRKktjvi2Jd4hV9JHMXvFdev+OoKBdrrKEvcySg70gzV ByYpGDttWrboIw== X-Received: by 10.98.35.10 with SMTP id j10mr29917781pfj.23.1493150338582; Tue, 25 Apr 2017 12:58:58 -0700 (PDT) From: Ashijeet Acharya To: stefanha@gmail.com Date: Wed, 26 Apr 2017 01:29:05 +0530 Message-Id: <1493150351-28918-3-git-send-email-ashijeetacharya@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1493150351-28918-1-git-send-email-ashijeetacharya@gmail.com> References: <1493150351-28918-1-git-send-email-ashijeetacharya@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH v1 2/8] dmg: New function to help us cache random access point 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: kwolf@redhat.com, famz@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, mreitz@redhat.com, peter@lekensteyn.nl, Ashijeet Acharya , jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Introduce a new cache_access_point() function which will help us first cache a random access point inside a compressed stream and then keep updating it according to our requirement at appropriate times. Signed-off-by: Ashijeet Acharya --- block/dmg.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/block/dmg.c b/block/dmg.c index a7d25fc..c6fe8b0 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -128,6 +128,18 @@ static void update_max_chunk_size(BDRVDMGState *s, uin= t32_t chunk, } } =20 +static void cache_access_point(DMGReadState *drs, uint8_t *next_in, + int64_t avail_in, int32_t chunk, + int64_t sectors_read, int32_t sector_offse= t) +{ + drs->saved_next_in =3D next_in; + drs->saved_avail_in =3D avail_in; + drs->saved_chunk_type =3D chunk; + drs->sectors_read =3D sectors_read; + drs->sector_offset_in_chunk =3D sector_offset; + return; +} + static int64_t dmg_find_koly_offset(BdrvChild *file, Error **errp) { BlockDriverState *file_bs =3D file->bs; @@ -507,6 +519,10 @@ static int dmg_open(BlockDriverState *bs, QDict *optio= ns, int flags, goto fail; } =20 + s->drs =3D g_malloc(sizeof(DMGReadState)); + /* initialise our access point cache */ + cache_access_point(s->drs, NULL, -1, -1, -1, -1); + if (inflateInit(&s->zstream) !=3D Z_OK) { ret =3D -EINVAL; goto fail; @@ -523,6 +539,7 @@ fail: g_free(s->lengths); g_free(s->sectors); g_free(s->sectorcounts); + g_free(s->drs); qemu_vfree(s->compressed_chunk); qemu_vfree(s->uncompressed_chunk); return ret; @@ -685,6 +702,7 @@ static void dmg_close(BlockDriverState *bs) g_free(s->lengths); g_free(s->sectors); g_free(s->sectorcounts); + g_free(s->drs); qemu_vfree(s->compressed_chunk); qemu_vfree(s->uncompressed_chunk); =20 --=20 2.6.2 From nobody Fri May 3 07:33:10 2024 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14931506040341000.6791992718435; Tue, 25 Apr 2017 13:03:24 -0700 (PDT) Received: from localhost ([::1]:51201 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d36gE-0001fi-Pr for importer@patchew.org; Tue, 25 Apr 2017 16:03:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52555) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d36c7-0006v6-Dh for qemu-devel@nongnu.org; Tue, 25 Apr 2017 15:59:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d36c6-0003yH-Kv for qemu-devel@nongnu.org; Tue, 25 Apr 2017 15:59:07 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:36790) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d36c6-0003xr-FS; Tue, 25 Apr 2017 15:59:06 -0400 Received: by mail-pg0-x243.google.com with SMTP id v1so6107190pgv.3; Tue, 25 Apr 2017 12:59:06 -0700 (PDT) Received: from linux.local ([157.51.23.94]) by smtp.gmail.com with ESMTPSA id y187sm37931530pfy.67.2017.04.25.12.59.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Apr 2017 12:59:04 -0700 (PDT) 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=0dwAeaTrL8M+Wcw/JFOoAfyC6juX1ymrfEPG4bVor1w=; b=MElVVsw/YuMiBIgtQBPpuxvke25JqjD5xbcnyam2EY66DuYctazcpTdoOFXAGR0e0z 2MdWLJcehRFrahkZkEBCn/BVQMZUbnIMutzW6xLj1OTj+1KYTuZdvjwWq7k721PmwEdA OJVEm89C5me2bvjSKsLwLB6I9J4VvFvTC4a4eDea/U5Wg+Z9/1yzIKH8X7SWsY95G1ok 8WvzsJPX0Nyjjdggy7jCRYe7PqhPMlp3iGUxzMcKwceebynBC+vukjyKHBHdjVB8zEqv IINXdfhyetAaQoRrJA00nPQpmqR7Fmn2cGrT4bwVoPQWdKvTmIvL8MgYtWKo7k7lJwdJ Ablw== 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=0dwAeaTrL8M+Wcw/JFOoAfyC6juX1ymrfEPG4bVor1w=; b=B59nybYRZ8cA0UK/OxAmdLNrhmxb0rFfGEdA7rbpyrNj7A0oNHujQulS0XBtm0uixw Kmey9p4d7cXZFtuIv0tvAv02k258rR/7xRA8ZRNPtzs47v4HSaq6msb+ShJnwoEAqW/F A70hRV5SwC7oXl69Skj22IrAKXqW9kY+mqrJnZeDGW1C4mULqXBS4bZrCXh76N4jdOVt SSyHgPAENDaEi6Vcd1wUt99dUHfJU9SPtIuN6y0rsCTt8FTChR2tDcDMJOjUF9w+wvhk jchKYMkclrL86D/S5voWs0ktp7zIF97Zi+x9tD9aBZ1LGULUQnPxj8gNZSc8vPiV5hpf euHw== X-Gm-Message-State: AN3rC/7tleBkjA/aA8BaOUn+pS9nS649k6oW95n56D6UrQhwLfhnfl70 RuiE1rrKBVKNFw== X-Received: by 10.98.32.211 with SMTP id m80mr29724729pfj.153.1493150345538; Tue, 25 Apr 2017 12:59:05 -0700 (PDT) From: Ashijeet Acharya To: stefanha@gmail.com Date: Wed, 26 Apr 2017 01:29:06 +0530 Message-Id: <1493150351-28918-4-git-send-email-ashijeetacharya@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1493150351-28918-1-git-send-email-ashijeetacharya@gmail.com> References: <1493150351-28918-1-git-send-email-ashijeetacharya@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH v1 3/8] dmg: Limit the output buffer size to a max of 2MB 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: kwolf@redhat.com, famz@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, mreitz@redhat.com, peter@lekensteyn.nl, Ashijeet Acharya , jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The size of the output buffer is limited to a maximum of 2MB so that QEMU doesn't end up allocating huge amounts of memory while decompressing compressed input streams. 2MB is an appropriate size because "qemu-img convert" has the same I/O buffer size and the most important use case for DMG files is to be compatible with qemu-img convert. Signed-off-by: Ashijeet Acharya --- block/dmg.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/block/dmg.c b/block/dmg.c index c6fe8b0..7ae30e3 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -37,8 +37,8 @@ enum { /* Limit chunk sizes to prevent unreasonable amounts of memory being u= sed * or truncating when converting to 32-bit types */ - DMG_LENGTHS_MAX =3D 64 * 1024 * 1024, /* 64 MB */ - DMG_SECTORCOUNTS_MAX =3D DMG_LENGTHS_MAX / 512, + DMG_MAX_OUTPUT =3D 2 * 1024 * 1024, /* 2 MB */ + DMG_SECTOR_MAX =3D DMG_MAX_OUTPUT / 512, }; =20 static int dmg_probe(const uint8_t *buf, int buf_size, const char *filenam= e) @@ -260,10 +260,10 @@ static int dmg_read_mish_block(BDRVDMGState *s, DmgHe= aderState *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 2 && s->sectorcounts[i] > DMG_SECTOR_MAX) { error_report("sector count %" PRIu64 " for chunk %" PRIu32 " is larger than max (%u)", - s->sectorcounts[i], i, DMG_SECTORCOUNTS_MAX); + s->sectorcounts[i], i, DMG_SECTOR_MAX); ret =3D -EINVAL; goto fail; } @@ -275,10 +275,10 @@ static int dmg_read_mish_block(BDRVDMGState *s, DmgHe= aderState *ds, /* length in (compressed) data fork */ s->lengths[i] =3D buff_read_uint64(buffer, offset + 0x20); =20 - if (s->lengths[i] > DMG_LENGTHS_MAX) { + if (s->lengths[i] > DMG_MAX_OUTPUT) { error_report("length %" PRIu64 " for chunk %" PRIu32 " is larger than max (%u)", - s->lengths[i], i, DMG_LENGTHS_MAX); + s->lengths[i], i, DMG_MAX_OUTPUT); ret =3D -EINVAL; goto fail; } --=20 2.6.2 From nobody Fri May 3 07:33:10 2024 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493150471500932.0871025697257; Tue, 25 Apr 2017 13:01:11 -0700 (PDT) Received: from localhost ([::1]:51185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d36e4-0008Gc-Um for importer@patchew.org; Tue, 25 Apr 2017 16:01:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d36cE-00071u-S8 for qemu-devel@nongnu.org; Tue, 25 Apr 2017 15:59:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d36cD-00041l-R8 for qemu-devel@nongnu.org; Tue, 25 Apr 2017 15:59:14 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:35942) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d36cD-00041f-JC; Tue, 25 Apr 2017 15:59:13 -0400 Received: by mail-pf0-x241.google.com with SMTP id v14so11217518pfd.3; Tue, 25 Apr 2017 12:59:13 -0700 (PDT) Received: from linux.local ([157.51.23.94]) by smtp.gmail.com with ESMTPSA id y187sm37931530pfy.67.2017.04.25.12.59.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Apr 2017 12:59:12 -0700 (PDT) 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=2n/DnCZ8ehdmy5uxUKPHvSyeXAoL+Ns9QpAIX6kKEKk=; b=EEt6toWVKucMDgCkII/zCiApF+0j4CO1gDh6D/mESBkdfbuht62w82zoePokxqOnfl xCvkqJ3+oFZ3DeULRPToVOb36Oz/D+6P3EXMKY/EzA+k+uBOlxOnuU8k/P24/aKsFGL1 iEcMpCDaTcmaiqBTGfLLe0m4B/Wwij8gRIig04QUIywaMl5f58FH77xUJ3NgCahQtbQd FUBsIQ1a4ffOutSSs3AKNcVmB0B18PS4lU8GUx7zA8gDH+iC/R+NB0vNa3nFtM/ek/1y RGCsiLMLfRyxD492PtH8GrKtjf4ohRAMToSqxrMncXHFEL6DJbc5xjiZCrCbnbLT6HAd YXxA== 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=2n/DnCZ8ehdmy5uxUKPHvSyeXAoL+Ns9QpAIX6kKEKk=; b=ITq3LAHvbgZi9hp/qMAVCVfId/CykEZk4utGUAprm79D84FkR8KfiSsi4oTtzdWweZ zkRqscYfQDoqExgL6WLcNbuHIhVYvDEeTP8ny8QxguewzVjtnYW9du/YAcZRyUvEa7jO LmMpSU6KbWIyNPV0FwebJuWkezTvlOdv4DN0Rf+AJ8X0Qydu7GNDEKfINfXF70EGsY9J TsGgBJnLqGpcDWyQFdVYzSX5BAeS/f8PJ67R0U+UTG/nH5NMrRDDo+sYM9Ew1UsNWsff I4mk7bVg9jW5sZ5+qrv2bfMGiS5hjgQgsdP9JaelTtPtSrEIEXEXuFc2VCATajFgwKvp RjBw== X-Gm-Message-State: AN3rC/7+UlOeRdYApszsr6ekFhD3a1bs3ky+yjS/6TvMr5GmK7mlkbS7 Tu4TeayYEQvp3A== X-Received: by 10.99.129.194 with SMTP id t185mr29390175pgd.57.1493150352591; Tue, 25 Apr 2017 12:59:12 -0700 (PDT) From: Ashijeet Acharya To: stefanha@gmail.com Date: Wed, 26 Apr 2017 01:29:07 +0530 Message-Id: <1493150351-28918-5-git-send-email-ashijeetacharya@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1493150351-28918-1-git-send-email-ashijeetacharya@gmail.com> References: <1493150351-28918-1-git-send-email-ashijeetacharya@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH v1 4/8] dmg: Refactor and prepare dmg_read_chunk() to cache random access points 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: kwolf@redhat.com, famz@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, mreitz@redhat.com, peter@lekensteyn.nl, Ashijeet Acharya , jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Refactor dmg_read_chunk() to start making use of the new DMGReadState structure and do chunk and sector related calculations based on it. Add a new argument "DMGReadState *drs" to it. Signed-off-by: Ashijeet Acharya --- block/dmg.c | 153 ++++++++++++++++++++++++++++++++++++--------------------= ---- 1 file changed, 91 insertions(+), 62 deletions(-) diff --git a/block/dmg.c b/block/dmg.c index 7ae30e3..dc356b0 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -578,78 +578,106 @@ static inline uint32_t search_chunk(BDRVDMGState *s,= uint64_t sector_num) return s->n_chunks; /* error */ } =20 -static inline int dmg_read_chunk(BlockDriverState *bs, uint64_t sector_num) +static inline int dmg_read_chunk(BlockDriverState *bs, uint64_t sector_num, + DMGReadState *drs) { BDRVDMGState *s =3D bs->opaque; =20 + int ret; + uint32_t sector_offset; + uint64_t sectors_read; + uint32_t chunk; + if (!is_sector_in_chunk(s, s->current_chunk, sector_num)) { - int ret; - uint32_t chunk =3D search_chunk(s, sector_num); + chunk =3D search_chunk(s, sector_num); + } else { + chunk =3D drs->saved_chunk_type; + } =20 - if (chunk >=3D s->n_chunks) { + if (chunk >=3D s->n_chunks) { + return -1; + } + + /* reset our access point cache if we had a change in current chunk */ + if (chunk !=3D drs->saved_chunk_type) { + cache_access_point(drs, NULL, -1, -1, -1, -1); + } + + sector_offset =3D sector_num - s->sectors[chunk]; + + if ((s->sectorcounts[chunk] - sector_offset) > DMG_SECTOR_MAX) { + sectors_read =3D DMG_SECTOR_MAX; + } else { + sectors_read =3D s->sectorcounts[chunk] - sector_offset; + } + + /* truncate sectors read if it exceeds the 2MB buffer of qemu-img + * convert */ + if ((sector_num % DMG_SECTOR_MAX) + sectors_read > DMG_SECTOR_MAX) { + sectors_read =3D DMG_SECTOR_MAX - (sector_num % DMG_SECTOR_MAX); + } + + s->current_chunk =3D s->n_chunks; + + switch (s->types[chunk]) { /* block entry type */ + case 0x80000005: { /* zlib compressed */ + /* we need to buffer, because only the chunk as whole can be + * inflated. */ + ret =3D bdrv_pread(bs->file, s->offsets[chunk], + s->compressed_chunk, s->lengths[chunk]); + if (ret !=3D s->lengths[chunk]) { return -1; } =20 - s->current_chunk =3D s->n_chunks; - switch (s->types[chunk]) { /* block entry type */ - case 0x80000005: { /* zlib compressed */ - /* we need to buffer, because only the chunk as whole can be - * inflated. */ - ret =3D bdrv_pread(bs->file, s->offsets[chunk], - s->compressed_chunk, s->lengths[chunk]); - if (ret !=3D s->lengths[chunk]) { - return -1; - } - - s->zstream.next_in =3D s->compressed_chunk; - s->zstream.avail_in =3D s->lengths[chunk]; - s->zstream.next_out =3D s->uncompressed_chunk; - s->zstream.avail_out =3D 512 * s->sectorcounts[chunk]; - ret =3D inflateReset(&s->zstream); - if (ret !=3D Z_OK) { - return -1; - } - ret =3D inflate(&s->zstream, Z_FINISH); - if (ret !=3D Z_STREAM_END || - s->zstream.total_out !=3D 512 * s->sectorcounts[chunk]) { - return -1; - } - break; } - case 0x80000006: /* bzip2 compressed */ - if (!dmg_uncompress_bz2) { - break; - } - /* we need to buffer, because only the chunk as whole can be - * inflated. */ - ret =3D bdrv_pread(bs->file, s->offsets[chunk], - s->compressed_chunk, s->lengths[chunk]); - if (ret !=3D s->lengths[chunk]) { - return -1; - } - - ret =3D dmg_uncompress_bz2((char *)s->compressed_chunk, - (unsigned int) s->lengths[chunk], - (char *)s->uncompressed_chunk, - (unsigned int) - (512 * s->sectorcounts[chunk])); - if (ret < 0) { - return ret; - } - break; - case 1: /* copy */ - ret =3D bdrv_pread(bs->file, s->offsets[chunk], - s->uncompressed_chunk, s->lengths[chunk]); - if (ret !=3D s->lengths[chunk]) { - return -1; - } - break; - case 2: /* zero */ - /* see dmg_read, it is treated specially. No buffer needs to be - * pre-filled, the zeroes can be set directly. */ + s->zstream.next_in =3D s->compressed_chunk; + s->zstream.avail_in =3D s->lengths[chunk]; + s->zstream.next_out =3D s->uncompressed_chunk; + s->zstream.avail_out =3D 512 * s->sectorcounts[chunk]; + ret =3D inflateReset(&s->zstream); + if (ret !=3D Z_OK) { + return -1; + } + ret =3D inflate(&s->zstream, Z_FINISH); + if (ret !=3D Z_STREAM_END || + s->zstream.total_out !=3D 512 * s->sectorcounts[chunk]) { + return -1; + } + break; } + case 0x80000006: /* bzip2 compressed */ + if (!dmg_uncompress_bz2) { break; } - s->current_chunk =3D chunk; + /* we need to buffer, because only the chunk as whole can be + * inflated. */ + ret =3D bdrv_pread(bs->file, s->offsets[chunk], + s->compressed_chunk, s->lengths[chunk]); + if (ret !=3D s->lengths[chunk]) { + return -1; + } + + ret =3D dmg_uncompress_bz2((char *)s->compressed_chunk, + (unsigned int) s->lengths[chunk], + (char *)s->uncompressed_chunk, + (unsigned int) + (512 * s->sectorcounts[chunk])); + if (ret < 0) { + return ret; + } + break; + case 1: /* copy */ + ret =3D bdrv_pread(bs->file, s->offsets[chunk], + s->uncompressed_chunk, s->lengths[chunk]); + if (ret !=3D s->lengths[chunk]) { + return -1; + } + break; + case 2: /* zero */ + /* see dmg_read, it is treated specially. No buffer needs to be + * pre-filled, the zeroes can be set directly. */ + break; } + s->current_chunk =3D chunk; + return 0; } =20 @@ -661,6 +689,7 @@ dmg_co_preadv(BlockDriverState *bs, uint64_t offset, ui= nt64_t bytes, uint64_t sector_num =3D offset >> BDRV_SECTOR_BITS; int nb_sectors =3D bytes >> BDRV_SECTOR_BITS; int ret, i; + DMGReadState *drs =3D s->drs; =20 assert((offset & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); assert((bytes & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); @@ -671,7 +700,7 @@ dmg_co_preadv(BlockDriverState *bs, uint64_t offset, ui= nt64_t bytes, uint32_t sector_offset_in_chunk; void *data; =20 - if (dmg_read_chunk(bs, sector_num + i) !=3D 0) { + if (dmg_read_chunk(bs, sector_num + i, drs) !=3D 0) { ret =3D -EIO; goto fail; } --=20 2.6.2 From nobody Fri May 3 07:33:10 2024 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493150620073449.20887086626067; Tue, 25 Apr 2017 13:03:40 -0700 (PDT) Received: from localhost ([::1]:51202 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d36gU-0001ri-PA for importer@patchew.org; Tue, 25 Apr 2017 16:03:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52617) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d36cM-000760-4Y for qemu-devel@nongnu.org; Tue, 25 Apr 2017 15:59:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d36cK-00042Y-5C for qemu-devel@nongnu.org; Tue, 25 Apr 2017 15:59:22 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:33564) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d36cJ-00042Q-Vf; Tue, 25 Apr 2017 15:59:20 -0400 Received: by mail-pg0-x242.google.com with SMTP id 63so13417586pgh.0; Tue, 25 Apr 2017 12:59:19 -0700 (PDT) Received: from linux.local ([157.51.23.94]) by smtp.gmail.com with ESMTPSA id y187sm37931530pfy.67.2017.04.25.12.59.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Apr 2017 12:59:18 -0700 (PDT) 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=bqGQX1E5k8JUNKPIqlPZOjNOiilxec2eu4nbVmEO90U=; b=MBcgwWCDylCk6/tUTVaOq4RSW9qd+X/Avm0d+VL8fmEIev25Oi2vsJO54AKXcTKoII mHLjc2phzNGNodUZeHZQoAGobDLoEYIteoUc0aITTvQ4YBtlskmu89aeez32Cr2WPogb iD5grQa5iytoYSJQuF+eyG4PTrwjbtHPQMsigiNkN0opJslQVrAliuJdwEh45DsfEzO8 oOb3i0Hr4n3hC5K67R3UyoAokW57W56Y097rVGp3GjZf6Pczprdr8Kg8u71I8dIghlNB R9keTpuCCyTK0LwjP7pY7gjsD1er0a2oaYgMYJ9hsvtn4qdragfks0aKqXG3fhiv7Iu7 4bzw== 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=bqGQX1E5k8JUNKPIqlPZOjNOiilxec2eu4nbVmEO90U=; b=lb62NuMbpm7FdmbPM/e63MwZdwrvsSZ0AXw9GTX0stAk0CZlIdJS1DZQ4GH1PL2FO/ AdL0AoRXNQxtBDnJu7uUKkfemMJylaV755LHudr4wYl+A3/KhGpwkcohYCd6oYzQF4f3 M4K1kyd06bEhNOU8n/CZuAObgE+IN/kGLL0+Nhj4hGg9oBMzxmEQO7T9mBwJyAQXClK/ jrpIkI47BIb/GL85A5BLaXvZdIqxOhs4RutHWQdM0Mn7wW5W2vvttwe4yiei1uG25O51 TXVYFfgbCVUPiD4AEMknruKI4Cofhf+rI7wPzR7npfztzQV7AvztpcfW8S67/OP7oyn6 nQiw== X-Gm-Message-State: AN3rC/4QaZ/DdaMNWnepktN7BoehyrdhrteLLWB1M8W9YekLevyMyyfQ 9kd4eKhh0a2gwQ== X-Received: by 10.98.150.78 with SMTP id c75mr27991240pfe.206.1493150358954; Tue, 25 Apr 2017 12:59:18 -0700 (PDT) From: Ashijeet Acharya To: stefanha@gmail.com Date: Wed, 26 Apr 2017 01:29:08 +0530 Message-Id: <1493150351-28918-6-git-send-email-ashijeetacharya@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1493150351-28918-1-git-send-email-ashijeetacharya@gmail.com> References: <1493150351-28918-1-git-send-email-ashijeetacharya@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PATCH v1 5/8] dmg: Handle zlib compressed chunks 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: kwolf@redhat.com, famz@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, mreitz@redhat.com, peter@lekensteyn.nl, Ashijeet Acharya , jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Set the output buffer size to be equal to the size of number of sectors stored in @sectors_read. Start inflating to a max output buffer size of 2MB and cache our access point to aid random access later if required. Signed-off-by: Ashijeet Acharya --- block/dmg.c | 48 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/block/dmg.c b/block/dmg.c index dc356b0..749c151 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -621,27 +621,47 @@ static inline int dmg_read_chunk(BlockDriverState *bs= , uint64_t sector_num, =20 switch (s->types[chunk]) { /* block entry type */ case 0x80000005: { /* zlib compressed */ - /* we need to buffer, because only the chunk as whole can be - * inflated. */ - ret =3D bdrv_pread(bs->file, s->offsets[chunk], - s->compressed_chunk, s->lengths[chunk]); - if (ret !=3D s->lengths[chunk]) { - return -1; + /* check for cached random access point */ + if (drs->saved_next_in =3D=3D NULL) { + /* we need to buffer, because only the chunk as whole can be + * inflated. */ + ret =3D bdrv_pread(bs->file, s->offsets[chunk], + s->compressed_chunk, s->lengths[chunk]); + if (ret !=3D s->lengths[chunk]) { + return -1; + } + + s->zstream.next_in =3D s->compressed_chunk; + s->zstream.avail_in =3D s->lengths[chunk]; + } else { + s->zstream.next_in =3D drs->saved_next_in; + s->zstream.avail_in =3D drs->saved_avail_in; } =20 - s->zstream.next_in =3D s->compressed_chunk; - s->zstream.avail_in =3D s->lengths[chunk]; s->zstream.next_out =3D s->uncompressed_chunk; - s->zstream.avail_out =3D 512 * s->sectorcounts[chunk]; - ret =3D inflateReset(&s->zstream); - if (ret !=3D Z_OK) { - return -1; + + s->zstream.avail_out =3D sectors_read * BDRV_SECTOR_SIZE; + + if (drs->saved_next_in =3D=3D NULL) { + ret =3D inflateReset(&s->zstream); + if (ret !=3D Z_OK) { + return -1; + } + } + /* reset total_out for each successive call */ + s->zstream.total_out =3D 0; + ret =3D inflate(&s->zstream, Z_SYNC_FLUSH); + if (ret =3D=3D Z_OK && + s->zstream.total_out =3D=3D 512 * sectors_read) { + goto update; } - ret =3D inflate(&s->zstream, Z_FINISH); if (ret !=3D Z_STREAM_END || - s->zstream.total_out !=3D 512 * s->sectorcounts[chunk]) { + s->zstream.total_out !=3D 512 * sectors_read) { return -1; } +update: + cache_access_point(drs, s->zstream.next_in, s->zstream.avail_in, + chunk, sectors_read, sector_offset); break; } case 0x80000006: /* bzip2 compressed */ if (!dmg_uncompress_bz2) { --=20 2.6.2 From nobody Fri May 3 07:33:10 2024 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493150725186745.8750717417299; Tue, 25 Apr 2017 13:05:25 -0700 (PDT) Received: from localhost ([::1]:51214 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d36iB-0003Jk-V6 for importer@patchew.org; Tue, 25 Apr 2017 16:05:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52669) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d36cP-00079h-TP for qemu-devel@nongnu.org; Tue, 25 Apr 2017 15:59:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d36cP-00043z-5K for qemu-devel@nongnu.org; Tue, 25 Apr 2017 15:59:25 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:34413) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d36cO-00043a-VZ; Tue, 25 Apr 2017 15:59:25 -0400 Received: by mail-pg0-x243.google.com with SMTP id t7so9747186pgt.1; Tue, 25 Apr 2017 12:59:24 -0700 (PDT) Received: from linux.local ([157.51.23.94]) by smtp.gmail.com with ESMTPSA id y187sm37931530pfy.67.2017.04.25.12.59.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Apr 2017 12:59:23 -0700 (PDT) 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=XWpjEBu8sMbn6ZIAbzJPE1ZnhTWfURZjL92A+nLwqEg=; b=Faug/Wv4FyTw48CfPH/jbq9lcjbyDFMyBRWCQCAY0MX6atdZa7Ea+fgs3Jy2OzvqyP 0LOJQO4ymj4C0pOOwmpGfyJQurJVJI+u77bvmwTVyexH4RHNXxlfqTQVlh3LuFkhDsAr 3WCkG3dtVdr0XJ8c0lbkTwicF/Ryu8SpR43rbuuEr3cBijnfhCLeP7dkdjerx6TRsUBK zUa5W96xi/UT2sKzkWtXZdsyvINRVe+wCOQemWyfsaYMFQ25OqT6yG+OkZ8Y01HQjJZb WoxfgjTy11ckHXjyrOsAB4o/f6yltZk3azZiZxudPEn2P2HNwMNS65BpC0Yw9ZiqPiGe mqeA== 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=XWpjEBu8sMbn6ZIAbzJPE1ZnhTWfURZjL92A+nLwqEg=; b=rfs4b6JKVEdZ2/eqJm98+9wGEMzhAo7wx6uS4BfleJzv4ej84cpHE37pke6IssXAtm eYE52XcHab5doA+25k24vZHFOotV1KAdCF1JnyibG94qa1eIPM3cYS23txHlpeF9QMyC 4MPXLfnkAoSGEObeDum1C9HU2zFc4YyVJQA6zcTo4QMJ3X751UoiNOvKKALZ3o28sSeS OFW6pdwSLDMOWfGpEPzVivA45lRMOrbOZwAx7M17UN1ABSKtzb28VAGdhNw9+deLgYCP HtM6MJkrEAheJmbu5fTmKE42slnrhQGuxIlrnhcppW3DmCMNWcoEoCV8sfU9qY8FNqOJ QGLw== X-Gm-Message-State: AN3rC/6qbCl7nkOu4Icq+LnYYoGJqDa2Ae3Ek6j4C1eRWTEHo8aS/YaJ CSIAD/GDWmBdxA== X-Received: by 10.84.241.65 with SMTP id u1mr39222303plm.28.1493150364080; Tue, 25 Apr 2017 12:59:24 -0700 (PDT) From: Ashijeet Acharya To: stefanha@gmail.com Date: Wed, 26 Apr 2017 01:29:09 +0530 Message-Id: <1493150351-28918-7-git-send-email-ashijeetacharya@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1493150351-28918-1-git-send-email-ashijeetacharya@gmail.com> References: <1493150351-28918-1-git-send-email-ashijeetacharya@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH v1 6/8] dmg: Handle bz2 compressed/raw/zeroed chunks 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: kwolf@redhat.com, famz@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, mreitz@redhat.com, peter@lekensteyn.nl, Ashijeet Acharya , jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We do not need to cache the access point for these chunks but need to update our various supporting variables like chunk, sectors_read etc. to keep maintaining our code structure. Call cache_access_point() after reading chunks of these types. Signed-off-by: Ashijeet Acharya --- block/dmg.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/block/dmg.c b/block/dmg.c index 749c151..f643e41 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -680,20 +680,30 @@ update: (char *)s->uncompressed_chunk, (unsigned int) (512 * s->sectorcounts[chunk])); + if (ret < 0) { return ret; } + cache_access_point(drs, NULL, -1, chunk, sectors_read, + sector_offset); break; case 1: /* copy */ - ret =3D bdrv_pread(bs->file, s->offsets[chunk], - s->uncompressed_chunk, s->lengths[chunk]); - if (ret !=3D s->lengths[chunk]) { - return -1; + if (drs->sectors_read =3D=3D -1) { + ret =3D bdrv_pread(bs->file, s->offsets[chunk], + s->uncompressed_chunk, s->lengths[chunk]); + if (ret !=3D s->lengths[chunk]) { + return -1; + } } + cache_access_point(drs, NULL, -1, chunk, sectors_read, + sector_offset); break; case 2: /* zero */ /* see dmg_read, it is treated specially. No buffer needs to be * pre-filled, the zeroes can be set directly. */ + cache_access_point(drs, NULL, -1, chunk, sectors_read, + sector_offset); + break; } s->current_chunk =3D chunk; --=20 2.6.2 From nobody Fri May 3 07:33:10 2024 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149315082854483.72859995070212; Tue, 25 Apr 2017 13:07:08 -0700 (PDT) Received: from localhost ([::1]:51221 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d36jq-0004OU-Lb for importer@patchew.org; Tue, 25 Apr 2017 16:07:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d36cV-0007Em-9x for qemu-devel@nongnu.org; Tue, 25 Apr 2017 15:59:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d36cU-00045W-DL for qemu-devel@nongnu.org; Tue, 25 Apr 2017 15:59:31 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:33578) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d36cU-000459-7E; Tue, 25 Apr 2017 15:59:30 -0400 Received: by mail-pg0-x243.google.com with SMTP id 63so13418410pgh.0; Tue, 25 Apr 2017 12:59:30 -0700 (PDT) Received: from linux.local ([157.51.23.94]) by smtp.gmail.com with ESMTPSA id y187sm37931530pfy.67.2017.04.25.12.59.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Apr 2017 12:59:28 -0700 (PDT) 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=lff7WGyzQ58LVkveJGMjRFsgZQpZnAiyqM4mf2m6OKk=; b=HKzSZSMW17+bNDoqc6ZXvDFEQkBPgZeQD5Q4uDV6vn5O7DEGdbSPTzt559if2rZuQK FkL1RKSKGBbb1z6amqZX+Yg5HPJseiqjxl+gwGV/UK8x21istMdLAxrJgoXCjxf9l9TT jb1f6uU/3X6d+V6V3/80mhFKoWVide3lwS1p8KxkpmyY0yidpqt1k3a3wBW9Dh5dy9ty /CuKjhGx2qlMTdgvrHEvw8Dq+URSoUOQjfbkWqSbjYBfWY7bYE+WX8cQX50p4NGtQZwg qbV8Y6DsSDfttjTLnoQ/i7t9TWVSW/5JO/r7l2YF7CzEfp88YgTXuSK3d9qcT2eCthWd DOAw== 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=lff7WGyzQ58LVkveJGMjRFsgZQpZnAiyqM4mf2m6OKk=; b=kF0GZu8lhKL+Z6y1rTA61lkYtr6A4e2AqaPt2s884ZWvI0mT7eeoWAuh6lCNSJ8J0c ZkCcOLBaIgOssUye/o5R7OQx8hw8I5/pEiERe/XNow2OQYcpSkfTDSNTT9bj0xH7rM4I +vnCplIYoABAJUME+WJm+iGWMBA5joATzmexk6XwiomToHsJTo8O7FN+p85lZfS999Rw NP5I62peawHxvx/HgtaCaPHK242zbLWitp+D8stCgp68FxWorqE43/ufn5EvE7r4MLlc /FvFCMpMTey8yUSiiIe7m/VAIn6HBvPBvXKeAs28RFc4DAslwXA5pCIPoxh9xW9bA+Oa ZXAw== X-Gm-Message-State: AN3rC/4tCTpOsVMl95Fa3/1cjSmbz0NGIU6do+RihczOtp29a2pGG45v vS5gWRrIjU56aA== X-Received: by 10.99.121.67 with SMTP id u64mr15696310pgc.230.1493150369294; Tue, 25 Apr 2017 12:59:29 -0700 (PDT) From: Ashijeet Acharya To: stefanha@gmail.com Date: Wed, 26 Apr 2017 01:29:10 +0530 Message-Id: <1493150351-28918-8-git-send-email-ashijeetacharya@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1493150351-28918-1-git-send-email-ashijeetacharya@gmail.com> References: <1493150351-28918-1-git-send-email-ashijeetacharya@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH v1 7/8] dmg: Refactor dmg_co_preadv() to start reading multiple sectors 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: kwolf@redhat.com, famz@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, mreitz@redhat.com, peter@lekensteyn.nl, Ashijeet Acharya , jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" At the moment, dmg_co_preadv() reads one sector at a time. Make it read multiple sectors at a time depending on the number of sectors stored in "drs->sectors_read". This does not provide any significant optimization in the I/O process of DMG but is still a nicer way. Adjust the 'data' variable depending on our cached access point situation to align our read requests appropriately. Signed-off-by: Ashijeet Acharya --- block/dmg.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/block/dmg.c b/block/dmg.c index f643e41..b0f3c84 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -718,7 +718,7 @@ dmg_co_preadv(BlockDriverState *bs, uint64_t offset, ui= nt64_t bytes, BDRVDMGState *s =3D bs->opaque; uint64_t sector_num =3D offset >> BDRV_SECTOR_BITS; int nb_sectors =3D bytes >> BDRV_SECTOR_BITS; - int ret, i; + int ret, i =3D 0; DMGReadState *drs =3D s->drs; =20 assert((offset & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); @@ -726,8 +726,7 @@ dmg_co_preadv(BlockDriverState *bs, uint64_t offset, ui= nt64_t bytes, =20 qemu_co_mutex_lock(&s->lock); =20 - for (i =3D 0; i < nb_sectors; i++) { - uint32_t sector_offset_in_chunk; + while (i < nb_sectors) { void *data; =20 if (dmg_read_chunk(bs, sector_num + i, drs) !=3D 0) { @@ -738,12 +737,20 @@ dmg_co_preadv(BlockDriverState *bs, uint64_t offset, = uint64_t bytes, * 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 */ - qemu_iovec_memset(qiov, i * 512, 0, 512); - continue; + qemu_iovec_memset(qiov, i * 512, 0, + 512 * drs->sectors_read); + goto increment; + } + + if (drs->saved_next_in =3D=3D NULL) { + data =3D s->uncompressed_chunk + drs->sector_offset_in_chunk *= 512; + } else { + data =3D s->uncompressed_chunk; } - sector_offset_in_chunk =3D sector_num + i - s->sectors[s->current_= chunk]; - data =3D s->uncompressed_chunk + sector_offset_in_chunk * 512; - qemu_iovec_from_buf(qiov, i * 512, data, 512); + qemu_iovec_from_buf(qiov, i * 512, data, drs->sectors_read * 512); + +increment: + i +=3D drs->sectors_read; } =20 ret =3D 0; --=20 2.6.2 From nobody Fri May 3 07:33:10 2024 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493150634769289.1310247200445; Tue, 25 Apr 2017 13:03:54 -0700 (PDT) Received: from localhost ([::1]:51203 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d36gj-00021P-Gl for importer@patchew.org; Tue, 25 Apr 2017 16:03:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52800) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d36cb-0007JN-23 for qemu-devel@nongnu.org; Tue, 25 Apr 2017 15:59:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d36ca-00046n-65 for qemu-devel@nongnu.org; Tue, 25 Apr 2017 15:59:37 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:34425) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d36ca-00046f-0Q; Tue, 25 Apr 2017 15:59:36 -0400 Received: by mail-pg0-x244.google.com with SMTP id t7so9747948pgt.1; Tue, 25 Apr 2017 12:59:35 -0700 (PDT) Received: from linux.local ([157.51.23.94]) by smtp.gmail.com with ESMTPSA id y187sm37931530pfy.67.2017.04.25.12.59.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Apr 2017 12:59:33 -0700 (PDT) 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=eVgFgudWZiUcTSg67LBP7OzFCoGYeVEq3a391wRLk0M=; b=Sp/N4m6tQdT+/TyxdWb7cp2ZLSKrAD8te7H9ucxTC7bcNMLgkSchj0esg8CyaRkYGJ qF7yRpn58AWIQ6mOPyjeTbsegJw7ceseSkIEHe7HnS1sG4q2YTFD9vhWSYTHlEJsOAIq jNYZCYlAufQEmUishvsCu1dMLi5Lolqcxw+yKPN4zLR4zOIwlCz/YEtBY6qeFAQhxAuw O7Bhm4AVGSvxO66KIF0QEE10G0btXKSmGe3Gnz6oRxbqbJFAGD7h1EEFqDT7S5A2mkB3 UZLnZjWFyc5HJa0BkHy77nWnfrnUc5rPPeLPxuiw7z/JtI7Blspt5nsc+Vi1TuZd+S8Z rOJQ== 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=eVgFgudWZiUcTSg67LBP7OzFCoGYeVEq3a391wRLk0M=; b=PCJ60Ra4cmbVwpgNzfCdobxeiI4BrkTcRrxrrxIob2C4wyXRA9Ktv46dNCZdwglrXu 2N7G6JE9ya819nOVI008oQR2B7XcmcoJFUYbLhTkbTjGT8/E11NUB3iH5Cv+cZhZYpaS dQ3+WvKgRDETCY8KhvNDwKfYr7VsKvwKTbBlrSOe83nxBB72mMZ4CR+h1LXmNkjVvm/Q ryOxo8GjEMehHUGXpK0bBVyoLPIwds9tRaLr/uJjViDjZd+2aIlghJJNV6GxQzSDuKg7 7e9ueGI38Sh0WnkPeHjhaQsbQgfcESfLZwEdVyiDeUQ+Yh2nSyNNWw/R+oaeXEQGYb+b ES1g== X-Gm-Message-State: AN3rC/5YkdYWm1JslT1XIGMwVifG4zMYLvPYeueQGW4xe1g5sIn8gRce 5no5QG0ATa2xug== X-Received: by 10.99.107.198 with SMTP id g189mr29167742pgc.162.1493150375090; Tue, 25 Apr 2017 12:59:35 -0700 (PDT) From: Ashijeet Acharya To: stefanha@gmail.com Date: Wed, 26 Apr 2017 01:29:11 +0530 Message-Id: <1493150351-28918-9-git-send-email-ashijeetacharya@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1493150351-28918-1-git-send-email-ashijeetacharya@gmail.com> References: <1493150351-28918-1-git-send-email-ashijeetacharya@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PATCH v1 8/8] dmg: Remove the error messages to allow wild images 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: kwolf@redhat.com, famz@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, mreitz@redhat.com, peter@lekensteyn.nl, Ashijeet Acharya , jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We have refactored the DMG driver to accept and process images irrespective of their chunk sizes since we now have limit of 2MB on our output buffer size. Thus QEMU will not allocate huge amounts of memory no matter what the chunk size is. Remove the error messages to prevent denial-of-service in cases where untrusted files are being accessed by the user. Signed-off-by: Ashijeet Acharya --- block/dmg.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/block/dmg.c b/block/dmg.c index b0f3c84..01ec40e 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -209,7 +209,6 @@ static int dmg_read_mish_block(BDRVDMGState *s, DmgHead= erState *ds, uint8_t *buffer, uint32_t count) { uint32_t type, i; - int ret; size_t new_size; uint32_t chunk_count; int64_t offset =3D 0; @@ -258,16 +257,6 @@ 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 2 && s->sectorcounts[i] > DMG_SECTOR_MAX) { - error_report("sector count %" PRIu64 " for chunk %" PRIu32 - " is larger than max (%u)", - s->sectorcounts[i], i, DMG_SECTOR_MAX); - ret =3D -EINVAL; - goto fail; - } - /* offset in (compressed) data fork */ s->offsets[i] =3D buff_read_uint64(buffer, offset + 0x18); s->offsets[i] +=3D in_offset; @@ -275,23 +264,12 @@ static int dmg_read_mish_block(BDRVDMGState *s, DmgHe= aderState *ds, /* length in (compressed) data fork */ s->lengths[i] =3D buff_read_uint64(buffer, offset + 0x20); =20 - if (s->lengths[i] > DMG_MAX_OUTPUT) { - error_report("length %" PRIu64 " for chunk %" PRIu32 - " is larger than max (%u)", - s->lengths[i], i, DMG_MAX_OUTPUT); - ret =3D -EINVAL; - goto fail; - } - update_max_chunk_size(s, i, &ds->max_compressed_size, &ds->max_sectors_per_chunk); offset +=3D 40; } s->n_chunks +=3D chunk_count; return 0; - -fail: - return ret; } =20 static int dmg_read_resource_fork(BlockDriverState *bs, DmgHeaderState *ds, --=20 2.6.2