From nobody Wed Nov 5 10:51:22 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 1534428093331487.69232438711447; Thu, 16 Aug 2018 07:01:33 -0700 (PDT) Received: from localhost ([::1]:55803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqIq4-00019Z-GL for importer@patchew.org; Thu, 16 Aug 2018 10:01:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqInj-0006AQ-QH for qemu-devel@nongnu.org; Thu, 16 Aug 2018 09:59:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fqIng-0000E0-5q for qemu-devel@nongnu.org; Thu, 16 Aug 2018 09:58:58 -0400 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]:35188) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fqInc-0000B1-MX; Thu, 16 Aug 2018 09:58:53 -0400 Received: by mail-qk0-x242.google.com with SMTP id u21-v6so3775525qku.2; Thu, 16 Aug 2018 06:58:51 -0700 (PDT) Received: from localhost.localdomain ([177.83.75.169]) by smtp.gmail.com with ESMTPSA id p13-v6sm16454824qki.12.2018.08.16.06.58.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 06:58:50 -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=/TxzpofLgoIWk2lknsUfRFFhqk6o962sSnFN6K2b+cY=; b=rCChTum8C8rjBoZd2WkmrDfkGKB9ANIR22cUzlyCCDBfXrpMGzb4gcb+ZTgc/JymVp CLWHU10bDDdDD7n9ZKl8grTtGiDeLee0i7KjJG725ccDLlzkiSLf89Fs1wYrg18LSqCZ a6Ii+sRzy+yjIJRQj1H70Ug2teerMxDMCyuoDNXRHATu1h+rk/lXlxf8zrQ+nQyYz3sj OJcNVAm12+9KFKG14aNJ8ovC4zx+Snn6ea/PVNiFgBtiHOJBrYzN7ABYVgQMDA3wvEBG 1NsJyMt9mT2rICh3szXMIvkwm909pFtQ4xDhKIBYITZTMvqaYQeMe3yU35U1jHRStj+x 1fIQ== 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=/TxzpofLgoIWk2lknsUfRFFhqk6o962sSnFN6K2b+cY=; b=VWEo6i0NolgIaffpJRvSAkkyCha/2WpixZJhemUWJLhmM639NzF45tJzc1vYGQm8MZ Lqcq+aEQJQaToHmlf3vlFEbivM/tXMJ6zu8EM78G081nzefcfoX0wDJceTuW12zMGkhB riuYia0AQVDiVwgzcCZjMoTRiJOE7CieX3+kpa5DdL+iq/jgKVhqPmvItX0vLwXDR0Uk 9XrHrM/aPlRupS4u5siIKS0kR1kapg2kifhfDEcHLN0WOGokuAJiePGFCxbYVUiKd0lU NECETV67t4KtxfMiso9MKlRcs3qOVAVBE4zL8JhXFEVnCdC8UNmpLeyWhU1H1RuVnlYp fGMw== X-Gm-Message-State: AOUpUlGDubK9C5apEi/GyhUY7zBiuJzABCkXLB76piq+3fPafO5lqAKz 00JlX4okEWnMcUWH0cyEC9T3WM0O X-Google-Smtp-Source: AA+uWPxBhcwLDsbFpkihWP/xqYSKYBcPbeYRsHn5SZ6Rox3yYRl2HxrgjLdv8ruvS1mYrwDh4++vvA== X-Received: by 2002:a37:9d54:: with SMTP id g81-v6mr27016185qke.186.1534427931231; Thu, 16 Aug 2018 06:58:51 -0700 (PDT) From: Julio Faracco To: qemu-devel@nongnu.org Date: Thu, 16 Aug 2018 10:58:34 -0300 Message-Id: <20180816135837.13149-2-jcfaracco@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180816135837.13149-1-jcfaracco@gmail.com> References: <20180816135837.13149-1-jcfaracco@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::242 Subject: [Qemu-devel] [PATCH v2 1/4] block: adding lzfse decompressing support as a module. 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, qemu-block@nongnu.org, stefanha@redhat.com, mreitz@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: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" QEMU dmg support includes zlib and bzip2, but it does not contains lzfse support. This commit adds the source file to extend compression support for new DMGs. Signed-off-by: Julio Faracco --- block/dmg-lzfse.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 block/dmg-lzfse.c diff --git a/block/dmg-lzfse.c b/block/dmg-lzfse.c new file mode 100644 index 0000000000..19d25bc646 --- /dev/null +++ b/block/dmg-lzfse.c @@ -0,0 +1,49 @@ +/* + * DMG lzfse uncompression + * + * Copyright (c) 2018 Julio Cesar Faracco + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "dmg.h" +#include + +static int dmg_uncompress_lzfse_do(char *next_in, unsigned int avail_in, + char *next_out, unsigned int avail_out) +{ + size_t out_size =3D lzfse_decode_buffer((uint8_t *) next_out, avail_ou= t, + (uint8_t *) next_in, avail_in, + NULL); + + /* We need to decode the single chunk only. */ + /* So, out_size =3D=3D avail_out is not an error here. */ + if (out_size > 0) { + return out_size; + } + return -1; +} + +__attribute__((constructor)) +static void dmg_lzfse_init(void) +{ + assert(!dmg_uncompress_lzfse); + dmg_uncompress_lzfse =3D dmg_uncompress_lzfse_do; +} --=20 2.17.1 From nobody Wed Nov 5 10:51:22 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 1534428351055116.79852508176077; Thu, 16 Aug 2018 07:05:51 -0700 (PDT) Received: from localhost ([::1]:55829 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqIuI-0004YK-DN for importer@patchew.org; Thu, 16 Aug 2018 10:05:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38007) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqInl-0006Bs-Ay for qemu-devel@nongnu.org; Thu, 16 Aug 2018 09:59:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fqInj-0000GO-NS for qemu-devel@nongnu.org; Thu, 16 Aug 2018 09:59:00 -0400 Received: from mail-qt0-x22d.google.com ([2607:f8b0:400d:c0d::22d]:40086) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fqIng-0000Cf-2I; Thu, 16 Aug 2018 09:58:56 -0400 Received: by mail-qt0-x22d.google.com with SMTP id h4-v6so4726463qtj.7; Thu, 16 Aug 2018 06:58:54 -0700 (PDT) Received: from localhost.localdomain ([177.83.75.169]) by smtp.gmail.com with ESMTPSA id p13-v6sm16454824qki.12.2018.08.16.06.58.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 06:58:52 -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=9Tysv4rRpd3yCi6Nay0RDf+L5nX1JGpSrGQJfubXBVk=; b=KeymZFRtgvKKz7tkS4r8gX8dvubITCZtRxf56AqrJjQGE2dbfkIu6bykdJx9l8iJXG ViX4EbySHkqjtAqxP2PdH1tXNzH0unGBxUYuswl8fslpv/UP71skWUE+7GzApMN57uk4 IXxr//WOxo8iADWJi8/e/NNXyT69OLpdLwHB+EVtrHh8WelvkJNALoqDwqveNr55Vt7i KKvJgP9zGgEvJLzIczcwzpnkPFRQnrJSfxMhXwMBCjTFtoVIFL8rhiHprhSrnEAbG6na zo5h1RbUF7BgN2mzLP6rQhee96KPjujob4whAZ7eUTVm0+YoWwaSy7S6dcK0ub73LFG6 TVoA== 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=9Tysv4rRpd3yCi6Nay0RDf+L5nX1JGpSrGQJfubXBVk=; b=k6aB05zpfPGNGUHVyD60pP/Mujaes3/xp+yUHSFD1Wfv2fl5vauVRQRsHVrdf8fnee BHkiogcT8asHI61RW0emFK64Om2605owMdxBRVDTlEBB02kLUl4/ECiFcd0cRnr6UC+O NvM0P2+jDDhh7LHw2XEdBv44Ro1xHCIzbYQFKa9m66LlTrWvrhOm4QTxdFR0bFTZQDbB 2NWlDAX77O7xcehoF5El0uUepu4LSn8XBEpafvNVCZEm2Xl132J7o3ejWCfc13nLA8GA Dm1j6lFKhXlZ4rewwSprrSUxbLe50NFwkvZhp9TLnB645ynAmkxQnTFbGPDdd8OimV2f VXWg== X-Gm-Message-State: AOUpUlFFlLliVY+ajHshNrKuhN/XukoM0B0HpSMRjyLjbQ5hYLzYul0R zA9Yj7LsnwmV33gYt7/dfvMpGrMp X-Google-Smtp-Source: AA+uWPz2bN9+NI0qKyVBiwRCZKWikGy1CYdk7mAJHhqUCa37+MAlQ0syVM66dPv6x4QV4B6IoBsm6Q== X-Received: by 2002:aed:2317:: with SMTP id h23-v6mr29136313qtc.85.1534427933341; Thu, 16 Aug 2018 06:58:53 -0700 (PDT) From: Julio Faracco To: qemu-devel@nongnu.org Date: Thu, 16 Aug 2018 10:58:35 -0300 Message-Id: <20180816135837.13149-3-jcfaracco@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180816135837.13149-1-jcfaracco@gmail.com> References: <20180816135837.13149-1-jcfaracco@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::22d Subject: [Qemu-devel] [PATCH v2 2/4] configure: adding support to lzfse library. 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, qemu-block@nongnu.org, stefanha@redhat.com, mreitz@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: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This commit includes the support to lzfse opensource library. With this library dmg block driver can decompress images with this type of compression inside. Signed-off-by: Julio Faracco --- block/Makefile.objs | 2 ++ configure | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/block/Makefile.objs b/block/Makefile.objs index c8337bf186..f4ddbb9c7b 100644 --- a/block/Makefile.objs +++ b/block/Makefile.objs @@ -47,6 +47,8 @@ ssh.o-cflags :=3D $(LIBSSH2_CFLAGS) ssh.o-libs :=3D $(LIBSSH2_LIBS) block-obj-$(if $(CONFIG_BZIP2),m,n) +=3D dmg-bz2.o dmg-bz2.o-libs :=3D $(BZIP2_LIBS) +block-obj-$(if $(CONFIG_LZFSE),m,n) +=3D dmg-lzfse.o +dmg-lzfse.o-libs :=3D $(LZFSE_LIBS) qcow.o-libs :=3D -lz linux-aio.o-libs :=3D -laio parallels.o-cflags :=3D $(LIBXML2_CFLAGS) diff --git a/configure b/configure index 2a7796ea80..c5a4628f98 100755 --- a/configure +++ b/configure @@ -432,6 +432,7 @@ capstone=3D"" lzo=3D"" snappy=3D"" bzip2=3D"" +lzfse=3D"" guest_agent=3D"" guest_agent_with_vss=3D"no" guest_agent_ntddscsi=3D"no" @@ -1300,6 +1301,10 @@ for opt do ;; --enable-bzip2) bzip2=3D"yes" ;; + --enable-lzfse) lzfse=3D"yes" + ;; + --disable-lzfse) lzfse=3D"no" + ;; --enable-guest-agent) guest_agent=3D"yes" ;; --disable-guest-agent) guest_agent=3D"no" @@ -1689,6 +1694,8 @@ disabled with --disable-FEATURE, default is enabled i= f available: snappy support of snappy compression library bzip2 support of bzip2 compression library (for reading bzip2-compressed dmg images) + lzfse support of lzfse compression library + (for reading lzfse-compressed dmg images) seccomp seccomp support coroutine-pool coroutine freelist (better performance) glusterfs GlusterFS backend @@ -2213,6 +2220,24 @@ EOF fi fi =20 +########################################## +# lzfse check + +if test "$lzfse" !=3D "no" ; then + cat > $TMPC << EOF +#include +int main(void) { lzfse_decode_scratch_size(); return 0; } +EOF + if compile_prog "" "-llzfse" ; then + lzfse=3D"yes" + else + if test "$lzfse" =3D "yes"; then + feature_not_found "lzfse" "Install lzfse devel" + fi + lzfse=3D"no" + fi +fi + ########################################## # libseccomp check =20 @@ -6001,6 +6026,7 @@ echo "Live block migration $live_block_migration" echo "lzo support $lzo" echo "snappy support $snappy" echo "bzip2 support $bzip2" +echo "lzfse support $lzfse" echo "NUMA host support $numa" echo "libxml2 $libxml2" echo "tcmalloc support $tcmalloc" @@ -6525,6 +6551,11 @@ if test "$bzip2" =3D "yes" ; then echo "BZIP2_LIBS=3D-lbz2" >> $config_host_mak fi =20 +if test "$lzfse" =3D "yes" ; then + echo "CONFIG_LZFSE=3Dy" >> $config_host_mak + echo "LZFSE_LIBS=3D-llzfse" >> $config_host_mak +fi + if test "$libiscsi" =3D "yes" ; then echo "CONFIG_LIBISCSI=3Dm" >> $config_host_mak echo "LIBISCSI_CFLAGS=3D$libiscsi_cflags" >> $config_host_mak --=20 2.17.1 From nobody Wed Nov 5 10:51:22 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 1534428293627882.1948087170772; Thu, 16 Aug 2018 07:04:53 -0700 (PDT) Received: from localhost ([::1]:55826 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqItQ-0003aK-7N for importer@patchew.org; Thu, 16 Aug 2018 10:04:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38006) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqInl-0006Br-Aw for qemu-devel@nongnu.org; Thu, 16 Aug 2018 09:59:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fqInj-0000Gl-Pf for qemu-devel@nongnu.org; Thu, 16 Aug 2018 09:59:00 -0400 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]:34202) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fqIng-0000Dk-PB; Thu, 16 Aug 2018 09:58:58 -0400 Received: by mail-qt0-x242.google.com with SMTP id m13-v6so4751517qth.1; Thu, 16 Aug 2018 06:58:56 -0700 (PDT) Received: from localhost.localdomain ([177.83.75.169]) by smtp.gmail.com with ESMTPSA id p13-v6sm16454824qki.12.2018.08.16.06.58.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 06:58:54 -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=NM/TVz2txh2dTUWoK7dh7L5SubuA3O4s/CJVw731UUM=; b=JKfWeo4hciUde0+/prIhYjbqP7rpk38RjOa7vgAyXFbNk588cPsHRaY+6HQk8fGRqZ mdJpxnTgX0UTWmJMtoWGZ64qe3GlS4PBQIZet4r3ohTwnl3Uy7rP9gg2jtKpRJajeBgs J0t6q54mSgO6NVw4zzbZpli76f5L0Jxg+o2frRH7VWJofidb+XcjJg3mmEUYnksir5Xd B4i4yzk8mdCrbYTBtf84LvTU4UR6v3bQlUg6yNQjOx3I4kcC1ykfiQoMvo4f/UUVQx3q 1otecyftXSf3AVPRRl7d3coJqNBaxLQeUOIHAA+Js5PybVuaNdN5OGdOCiJ98XfCsN4n Lqyw== 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=NM/TVz2txh2dTUWoK7dh7L5SubuA3O4s/CJVw731UUM=; b=MFPniWBVcAi/P7oeDWjLWm7sVI0FC9VDLNm///4+7kNCTPrNovM6YxggIBPwGAN9v6 sXJi0gJfEJpqeXE62OaCUFzZkerB1x9Sr36azqn76oRT2uiNFxdlPYOq2Y/bJaaTSkhh sGVgPEdMYYfyt0x8EXS/zzbLgDO1BA65gLhFvGeN885OEvxmzg0rqQRvPE7JoTz4fBSe eirS4lyQWqk9LiffNg02hfjcvZ+ndEtH3UtIfrfz8S4ay8g6iGWDBEeeKRo7TNktN2CH w8G1MKv1arxfrqa+c0Y5VdbTflrYisWJdSdfHqPJCDYsatAEOqCpzgEeYvirwHlNynxI aC/w== X-Gm-Message-State: AOUpUlGsbSctlYqkgXIoYkjk8S/vGO2/dUYVgfF5O4ljl20ZvUavYAYl cyHyc+nylV/VeMMBB6tA3YEZRfF4 X-Google-Smtp-Source: AA+uWPwBiBSr0qUyczbDcW/aXQ7HD8S3koDSEv+fVu2klV2kyEhDx6vYnoobod38HPqOzHk3+Yw3Bg== X-Received: by 2002:ac8:13c3:: with SMTP id i3-v6mr30057248qtj.54.1534427935449; Thu, 16 Aug 2018 06:58:55 -0700 (PDT) From: Julio Faracco To: qemu-devel@nongnu.org Date: Thu, 16 Aug 2018 10:58:36 -0300 Message-Id: <20180816135837.13149-4-jcfaracco@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180816135837.13149-1-jcfaracco@gmail.com> References: <20180816135837.13149-1-jcfaracco@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::242 Subject: [Qemu-devel] [PATCH v2 3/4] dmg: including dmg-lzfse module inside dmg block driver. 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, qemu-block@nongnu.org, stefanha@redhat.com, mreitz@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: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This commit includes the support to new module dmg-lzfse into dmg block driver. It includes the support for block type ULFO (0x80000007). Signed-off-by: Julio Faracco --- block/dmg.c | 28 ++++++++++++++++++++++++++++ block/dmg.h | 3 +++ 2 files changed, 31 insertions(+) diff --git a/block/dmg.c b/block/dmg.c index c9b3c519c4..615f818c5a 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -33,6 +33,9 @@ int (*dmg_uncompress_bz2)(char *next_in, unsigned int avail_in, char *next_out, unsigned int avail_out); =20 +int (*dmg_uncompress_lzfse)(char *next_in, unsigned int avail_in, + char *next_out, unsigned int avail_out); + enum { /* Limit chunk sizes to prevent unreasonable amounts of memory being u= sed * or truncating when converting to 32-bit types @@ -107,6 +110,7 @@ static void update_max_chunk_size(BDRVDMGState *s, uint= 32_t chunk, switch (s->types[chunk]) { case 0x80000005: /* zlib compressed */ case 0x80000006: /* bzip2 compressed */ + case 0x80000007: /* lzfse compressed */ compressed_size =3D s->lengths[chunk]; uncompressed_sectors =3D s->sectorcounts[chunk]; break; @@ -188,6 +192,8 @@ static bool dmg_is_known_block_type(uint32_t entry_type) return true; case 0x80000006: /* bzip2 */ return !!dmg_uncompress_bz2; + case 0x80000007: /* lzfse */ + return !!dmg_uncompress_lzfse; default: return false; } @@ -431,6 +437,7 @@ static int dmg_open(BlockDriverState *bs, QDict *option= s, int flags, } =20 block_module_load_one("dmg-bz2"); + block_module_load_one("dmg-lzfse"); =20 s->n_chunks =3D 0; s->offsets =3D s->lengths =3D s->sectors =3D s->sectorcounts =3D NULL; @@ -629,6 +636,27 @@ static inline int dmg_read_chunk(BlockDriverState *bs,= uint64_t sector_num) return ret; } break; + case 0x80000007: + if (!dmg_uncompress_lzfse) { + 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_lzfse((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]); diff --git a/block/dmg.h b/block/dmg.h index 2ecf239ba5..f28929998f 100644 --- a/block/dmg.h +++ b/block/dmg.h @@ -55,4 +55,7 @@ typedef struct BDRVDMGState { extern int (*dmg_uncompress_bz2)(char *next_in, unsigned int avail_in, char *next_out, unsigned int avail_out); =20 +extern int (*dmg_uncompress_lzfse)(char *next_in, unsigned int avail_in, + char *next_out, unsigned int avail_out); + #endif --=20 2.17.1 From nobody Wed Nov 5 10:51:22 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 1534429213941484.0351905864652; Thu, 16 Aug 2018 07:20:13 -0700 (PDT) Received: from localhost ([::1]:55967 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqJ86-0002V7-Io for importer@patchew.org; Thu, 16 Aug 2018 10:20:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38061) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqIno-0006FG-Ce for qemu-devel@nongnu.org; Thu, 16 Aug 2018 09:59:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fqInl-0000Hq-0Z for qemu-devel@nongnu.org; Thu, 16 Aug 2018 09:59:04 -0400 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]:46201) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fqInj-0000F4-I2; Thu, 16 Aug 2018 09:58:59 -0400 Received: by mail-qt0-x242.google.com with SMTP id d4-v6so4704574qtn.13; Thu, 16 Aug 2018 06:58:58 -0700 (PDT) Received: from localhost.localdomain ([177.83.75.169]) by smtp.gmail.com with ESMTPSA id p13-v6sm16454824qki.12.2018.08.16.06.58.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 06:58:57 -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=h7/Szol+ROAWCt2ccsKOVzB5/cZAfQ7tIQ+od8CDv9I=; b=vgRNFNBL6LZwLiGOO1D8nOBs5K7YoCOI3k6hA0UdN76gPQAWYgnIjhltQrYqNaMa2c cdOPLNNtpeVd492LpUdc7tKAba96M6rvm4QxPT++CErEryy79bCKaoWnxYUKCOTq7G5Y UwByqzR+FDR+RPdVUcM+ZbmmRmOiU9z0LPui8zzkZHOjjrqbevsconI+fweRHTao08hb TyJYrvoQpEO+lg9PK6JF0CbxshJ0IJRKjGuA985foHjjfOnVI3UbfsBqoIUmmnUAez6y NY4U0MVLMHcHnHRPEnzPFl/jNz4hrP3Y8NsWFSM1hpMNHBhK4nhHEx0k/sJVYtlh6lN/ qb/A== 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=h7/Szol+ROAWCt2ccsKOVzB5/cZAfQ7tIQ+od8CDv9I=; b=ebXCENuz2ITTTB6MBXXZJXqsfLUSxIK6CvgQIhy9ZH2OhenHYhyMtR2ZFMGx5Hh5db UOiG3H9KOVZtGKxgPk+Rx2e9q/HnOtjnMAjr4OBBXnMXbgjvAU/pdh0sYAQqoMYFNuRj T8MIXzl6JSNms+W1yq61drYVW2S/GNzxc/BI6p7aZfNFP3/pnfJ3+5mTg9O+1qDVDVGV ymXvbWI98Il+9e38z6uzazxJFZx1HiHm25fHt/W7V6NCQMslEbULef2UPDkaDVv5vzSD rQB1JTHa6g+lmOdfEZ5OXQzHGWEgqlFePRxhJFtFzAxQ04Y/euoL/Mq7tuHKazIaDHoC 0isg== X-Gm-Message-State: AOUpUlGX7+EXBt3XsFligmhZaLywYUjOBYnG/NKWkJb4KHBiFr5Mph91 ouCfa0AOvS9nq0j5VYU6t32CQ7CS X-Google-Smtp-Source: AA+uWPzVQNlVlV4ZzkkubdSxSHD99o6OoCgl3+HH6X0KsgZQ8zdwKhff/08xVcS8DbyqLhR9QuCrcQ== X-Received: by 2002:ac8:110c:: with SMTP id c12-v6mr29703731qtj.269.1534427937637; Thu, 16 Aug 2018 06:58:57 -0700 (PDT) From: Julio Faracco To: qemu-devel@nongnu.org Date: Thu, 16 Aug 2018 10:58:37 -0300 Message-Id: <20180816135837.13149-5-jcfaracco@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180816135837.13149-1-jcfaracco@gmail.com> References: <20180816135837.13149-1-jcfaracco@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::242 Subject: [Qemu-devel] [PATCH v2 4/4] dmg: exchanging hardcoded dmg UDIF block types to enum. 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, qemu-block@nongnu.org, stefanha@redhat.com, mreitz@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: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This change is better to understand what kind of block type is being handled by the code. Using a syntax similar to the DMG documentation is easier than tracking all hex values assigned to a block type. Signed-off-by: Julio Faracco --- block/dmg.c | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/block/dmg.c b/block/dmg.c index 615f818c5a..6d055594df 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -44,6 +44,19 @@ enum { DMG_SECTORCOUNTS_MAX =3D DMG_LENGTHS_MAX / 512, }; =20 +enum { + /* DMG Block Type */ + UDZE =3D 0, /* Zeroes */ + UDRW, /* RAW type */ + UDIG, /* Ignore */ + UDCO =3D 0x80000004, + UDZO, + UDBZ, + ULFO, + UDCM =3D 0x7ffffffe, /* Comments */ + UDLE /* Last Entry */ +}; + static int dmg_probe(const uint8_t *buf, int buf_size, const char *filenam= e) { int len; @@ -108,16 +121,16 @@ static void update_max_chunk_size(BDRVDMGState *s, ui= nt32_t chunk, uint32_t uncompressed_sectors =3D 0; =20 switch (s->types[chunk]) { - case 0x80000005: /* zlib compressed */ - case 0x80000006: /* bzip2 compressed */ - case 0x80000007: /* lzfse compressed */ + case UDZO: /* zlib compressed */ + case UDBZ: /* bzip2 compressed */ + case ULFO: /* lzfse compressed */ compressed_size =3D s->lengths[chunk]; uncompressed_sectors =3D s->sectorcounts[chunk]; break; - case 1: /* copy */ + case UDRW: /* copy */ uncompressed_sectors =3D DIV_ROUND_UP(s->lengths[chunk], 512); break; - case 2: /* zero */ + case UDIG: /* zero */ /* 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= . */ @@ -186,13 +199,13 @@ typedef struct DmgHeaderState { static bool dmg_is_known_block_type(uint32_t entry_type) { switch (entry_type) { - case 0x00000001: /* uncompressed */ - case 0x00000002: /* zeroes */ - case 0x80000005: /* zlib */ + case UDRW: /* uncompressed */ + case UDIG: /* zeroes */ + case UDZO: /* zlib */ return true; - case 0x80000006: /* bzip2 */ + case UDBZ: /* bzip2 */ return !!dmg_uncompress_bz2; - case 0x80000007: /* lzfse */ + case ULFO: /* lzfse */ return !!dmg_uncompress_lzfse; default: return false; @@ -592,7 +605,7 @@ static inline int dmg_read_chunk(BlockDriverState *bs, = uint64_t sector_num) =20 s->current_chunk =3D s->n_chunks; switch (s->types[chunk]) { /* block entry type */ - case 0x80000005: { /* zlib compressed */ + case UDZO: { /* zlib compressed */ /* we need to buffer, because only the chunk as whole can be * inflated. */ ret =3D bdrv_pread(bs->file, s->offsets[chunk], @@ -615,7 +628,7 @@ static inline int dmg_read_chunk(BlockDriverState *bs, = uint64_t sector_num) return -1; } break; } - case 0x80000006: /* bzip2 compressed */ + case UDBZ: /* bzip2 compressed */ if (!dmg_uncompress_bz2) { break; } @@ -636,7 +649,7 @@ static inline int dmg_read_chunk(BlockDriverState *bs, = uint64_t sector_num) return ret; } break; - case 0x80000007: + case ULFO: if (!dmg_uncompress_lzfse) { break; } @@ -657,14 +670,14 @@ static inline int dmg_read_chunk(BlockDriverState *bs= , uint64_t sector_num) return ret; } break; - case 1: /* copy */ + case UDRW: /* 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 */ + case UDIG: /* zero */ /* see dmg_read, it is treated specially. No buffer needs to be * pre-filled, the zeroes can be set directly. */ break; --=20 2.17.1