From nobody Wed Nov 5 07:34:30 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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 1541430616390758.0147778809145; Mon, 5 Nov 2018 07:10:16 -0800 (PST) Received: from localhost ([::1]:35709 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJgW7-0006ZD-0s for importer@patchew.org; Mon, 05 Nov 2018 10:10:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJgUb-0005lL-DK for qemu-devel@nongnu.org; Mon, 05 Nov 2018 10:08:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gJgUZ-00025v-1C for qemu-devel@nongnu.org; Mon, 05 Nov 2018 10:08:41 -0500 Received: from mail-qk1-x742.google.com ([2607:f8b0:4864:20::742]:42140) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gJgUY-0001j5-Qa; Mon, 05 Nov 2018 10:08:38 -0500 Received: by mail-qk1-x742.google.com with SMTP id u68so15155241qkg.9; Mon, 05 Nov 2018 07:08:37 -0800 (PST) Received: from localhost.localdomain ([177.45.6.151]) by smtp.gmail.com with ESMTPSA id v57sm5720501qtv.80.2018.11.05.07.08.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Nov 2018 07:08:35 -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=/TxzpofLgoIWk2lknsUfRFFhqk6o962sSnFN6K2b+cY=; b=SqKit7nXHCF4tgHp76BQxnJ17cknxLvLFv6lk0pDjMVJNb9BITZAFqZazX+rJO4Cib 9n1zWdOtXGGaj9w79aUGbRJ+X7yebQf+3x1//WtAD5MOyqOVV1Z2DAAUmnIt4xRxP7zL F7egosWFstq/ASai3r6G8bWTjl7DK1HEC9GWnPlIZmCkq6fiOPgdmxSeNNAZmTUHODSB RtLy3+3DQNqh0Wtes2qUYpgWLqe/HE2Q9BiJolHGeewu+eWkhy5HMxpOXIhXiB3NPHG8 cTikoz4Sf+cHaSF75ALOJHPSx4GPcxklgEeXFkBEctbOy29Aq6ZJONMo2mmq2EF3yQNB etmg== 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=gAdVhdh0593gUt5UaqIVoxx9P0FL8ANIuvK1SL4jwB7KHcuvFh6+8MR9hQQ/yb0w4+ K8cA2HkIdeMVaopwKmAMcSKAsOY04NbYaIVd9Bi4mlSitoSAj4MEik23Y/MSgcBa/mrc 4NAQoXTEEpq/hGjC6IaCxckr27SKTs8ed2KyBAfAu+HXjBZ4NnghxcQAMuhyilMMyzug nyaRff+HL5cpsR4wwuFWjK0CmPlIKj43TcQqBtDNz5YhwujWcOcbkf1QviY0Z03tQ1w6 ckM8IKa5nYcLNvIHClXh24pKIxesIA5aJlaCPGxjjiqcmQZ/aTBOPitRhg4SH9cml44E I21A== X-Gm-Message-State: AGRZ1gLIsVFzs4ZKnOrWXqLCmnBKEzLBtUpoIA/opJW7G3D829WME61B hbKXI9siGhpJxDTZfa0wLIqEPZl0 X-Google-Smtp-Source: AJdET5d8ab1uy1QeaNz7pP1ylGZGqRYBOIoj2IBZDY+bTacPA0d3ZDpZyMNq/EmxrwQLX/hPYXTtJg== X-Received: by 2002:a0c:aff9:: with SMTP id t54mr21567009qvc.93.1541430516474; Mon, 05 Nov 2018 07:08:36 -0800 (PST) From: Julio Faracco To: qemu-devel@nongnu.org Date: Mon, 5 Nov 2018 13:08:03 -0200 Message-Id: <20181105150806.13649-2-jcfaracco@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181105150806.13649-1-jcfaracco@gmail.com> References: <20181105150806.13649-1-jcfaracco@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::742 Subject: [Qemu-devel] [PATCH v3 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: Kevin Wolf , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-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 07:34:30 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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 1541430612764524.2177914200325; Mon, 5 Nov 2018 07:10:12 -0800 (PST) Received: from localhost ([::1]:35707 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJgVz-0006Ub-P5 for importer@patchew.org; Mon, 05 Nov 2018 10:10:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJgUb-0005lK-Cs for qemu-devel@nongnu.org; Mon, 05 Nov 2018 10:08:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gJgUa-0002Jz-8U for qemu-devel@nongnu.org; Mon, 05 Nov 2018 10:08:41 -0500 Received: from mail-qk1-x741.google.com ([2607:f8b0:4864:20::741]:36309) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gJgUa-0002DH-0z; Mon, 05 Nov 2018 10:08:40 -0500 Received: by mail-qk1-x741.google.com with SMTP id o125so15213710qkf.3; Mon, 05 Nov 2018 07:08:39 -0800 (PST) Received: from localhost.localdomain ([177.45.6.151]) by smtp.gmail.com with ESMTPSA id v57sm5720501qtv.80.2018.11.05.07.08.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Nov 2018 07:08: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=Ypt9ezqEebBCqb0TCU6dVPj2vej6yxKel3Owqk/F/tI=; b=fgfzjc2y7deY2jWqd6fA5/CweCNkMmtUE61ACqJj22210sprlOgf6vikHE6f29APqS P0IasuGABRyXUJCSUx7noflTNfW176ey6AgJJr6v+GXzLNDEsmUPi9F2mEA7udJl/VrV mEfUuiyTbuURn7DYpNE8TOxbptywTcwP8tGYJrtw/puHkcoFDfF0aHDnacroCp+CKZXR Ej/newn5bBjGP3fFmcP2+ReK9nmUVkt4YLbiPdySSz9lmzmhUvQTgaILzPewy6b2YZF1 mPDHfAAsmiI5XhCxBBIIea2r8qbXTERBiySrsUAKXT2+tE04LzouyWM5i2QTPZJn1Iq9 2qsA== 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=Ypt9ezqEebBCqb0TCU6dVPj2vej6yxKel3Owqk/F/tI=; b=WO6k24AcJuxPRolG8y2nXvPuUTVZ8DJ1zSrW16wxw8RT57X/7JvT/plGXPTAaZXN1I zRtvjlF4f00pspuyWOd+r5VLhsHwPg9whGequw5QX70qv9l0gDGKTpY4cO/o736ycV+W xa5IigXhJEfj0BvpwZMSwXeleNYgF2pAYtDgRT5uZliwbKEzIIQQssvL3YANXZlqhIn7 /NH4FSrpv2K/lqfQWV/ljit6b7bQ70IkQqbFhk9lZWlUFA5Hm52btPRTuhY5OvL+02L1 voprsTUUjrcsadJYPkA4kQq714fy4M0nodma7a+i/WvIiLQZPj3CfK1nyRjV2krYCOsY BaqQ== X-Gm-Message-State: AGRZ1gIFYPR07yLH0XAwra9k3H4+bhUrUImJdWTtlwfoaBXCTNBjHAkE i3ZfWDeqHQie2K/dNtZm4felZjLH X-Google-Smtp-Source: AJdET5c7limoT76Lf2HlMnR8vdLoQXfbw/ikalv6HXycq6mREKAh8tDmgzcNq7HmeGJnwUo9zeMhcA== X-Received: by 2002:a0c:ec50:: with SMTP id n16mr22291154qvq.105.1541430519026; Mon, 05 Nov 2018 07:08:39 -0800 (PST) From: Julio Faracco To: qemu-devel@nongnu.org Date: Mon, 5 Nov 2018 13:08:04 -0200 Message-Id: <20181105150806.13649-3-jcfaracco@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181105150806.13649-1-jcfaracco@gmail.com> References: <20181105150806.13649-1-jcfaracco@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::741 Subject: [Qemu-devel] [PATCH v3 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: Kevin Wolf , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-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 46ae1e8c76..56b26f0579 100755 --- a/configure +++ b/configure @@ -434,6 +434,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" @@ -1301,6 +1302,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" @@ -1700,6 +1705,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 @@ -2209,6 +2216,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 @@ -6036,6 +6061,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" @@ -6549,6 +6575,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 07:34:30 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 1541430805977476.67491756143477; Mon, 5 Nov 2018 07:13:25 -0800 (PST) Received: from localhost ([::1]:35726 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJgZA-0002Bw-Oy for importer@patchew.org; Mon, 05 Nov 2018 10:13:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48154) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJgUd-0005la-Ta for qemu-devel@nongnu.org; Mon, 05 Nov 2018 10:08:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gJgUc-0002jv-Gw for qemu-devel@nongnu.org; Mon, 05 Nov 2018 10:08:43 -0500 Received: from mail-qk1-x741.google.com ([2607:f8b0:4864:20::741]:36926) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gJgUc-0002di-8B; Mon, 05 Nov 2018 10:08:42 -0500 Received: by mail-qk1-x741.google.com with SMTP id 131so15207348qkd.4; Mon, 05 Nov 2018 07:08:42 -0800 (PST) Received: from localhost.localdomain ([177.45.6.151]) by smtp.gmail.com with ESMTPSA id v57sm5720501qtv.80.2018.11.05.07.08.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Nov 2018 07:08:40 -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=NM/TVz2txh2dTUWoK7dh7L5SubuA3O4s/CJVw731UUM=; b=S85Ggp1sMxpctt03uBx6Iw59i5Lw6eix7X9bRGaEW8bO3OKkxHLOM9GKYs1DnE12oi iNPsDOGzalxiISrs7J93CSzkUqgf38G2M72A5LBEAad8w6DX9Da7no4NTsIiRIw7xozU +ZkrRZ9K0rMUKENCgkMErQD3MpKnTukqLv7Kiy0Arc0kDQbMls4niI4+WestM0/Pu2IU iOtwLRkA9PfGhrIGH8SBVlU0nvP/jmjrd11OKiPqUsU3bCHaBg01cctxJqw4DhEH02vt hNfhoDoMmgTCJtTd/i2qNBzzTBJdgmOim2uKoeN+upNkyQvFXZ/t5d0Ue8xlV++SAdPB is7g== 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=uMUJPdnCKMBiHU2aUoXwKBIRUb7cSde677vP3cat8W+wzU/J0YZ7WnlpIeFsirmxnH MUGjqVDiMXr5E6/lHVbGiTg8I9bWWTo0jBxioppE4K/PKHOiK8XjdXH3vICm72w0MC/n MPCvH5WPoPGFvFciThr1sqPaxm/Emy22GOWeDj3hfSRYnkdaQ/xmtG3VeUdy0pDyZQjV 4jLOvnSsFjelv+zXeHMMqh1ENzK50CadhA9ehNcY4P/H+biSG1ZCEGGPC9Fmg4o8loHG CHHNkxZzxoCVZaRe1WwPoqtAeOXkNNnusTNfshLiaw/seOtHF+0q5L6umWUsTjTtckDU Z5Ew== X-Gm-Message-State: AGRZ1gJ36Ku6DvC9YXUbPrt0X0qN7s1vdSgvPgSmy2t0kIvvbl+Hz1P6 n25xhF7pJSULF1Um+3Am2xvnjl9a X-Google-Smtp-Source: AJdET5doPyb+gCI1KyQH0iW4kcKpBrutD6I+7mDolz+6SJ9yQdv+8mf2LrO80SR4F01Q0WqovFHKmQ== X-Received: by 2002:a0c:e789:: with SMTP id x9mr1569099qvn.245.1541430521384; Mon, 05 Nov 2018 07:08:41 -0800 (PST) From: Julio Faracco To: qemu-devel@nongnu.org Date: Mon, 5 Nov 2018 13:08:05 -0200 Message-Id: <20181105150806.13649-4-jcfaracco@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181105150806.13649-1-jcfaracco@gmail.com> References: <20181105150806.13649-1-jcfaracco@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::741 Subject: [Qemu-devel] [PATCH v3 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: Kevin Wolf , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-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 07:34:30 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 15414307301921001.5648753619221; Mon, 5 Nov 2018 07:12:10 -0800 (PST) Received: from localhost ([::1]:35721 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJgXq-0007r5-Cu for importer@patchew.org; Mon, 05 Nov 2018 10:12:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48188) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJgUg-0005n9-3x for qemu-devel@nongnu.org; Mon, 05 Nov 2018 10:08:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gJgUe-00035V-OH for qemu-devel@nongnu.org; Mon, 05 Nov 2018 10:08:45 -0500 Received: from mail-qk1-x743.google.com ([2607:f8b0:4864:20::743]:40670) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gJgUe-00030e-GG; Mon, 05 Nov 2018 10:08:44 -0500 Received: by mail-qk1-x743.google.com with SMTP id y16so13988458qki.7; Mon, 05 Nov 2018 07:08:44 -0800 (PST) Received: from localhost.localdomain ([177.45.6.151]) by smtp.gmail.com with ESMTPSA id v57sm5720501qtv.80.2018.11.05.07.08.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Nov 2018 07:08: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=h7/Szol+ROAWCt2ccsKOVzB5/cZAfQ7tIQ+od8CDv9I=; b=RcwcHWRPre4hGrKXRDERQNmANznPoYN9/5YmmQ5Xxdwbn1YEf8+RktNoKWVkLF34jT 3T0jDmMzxywAFPjUyCrllBm6Zj6UA3SkI8NR6Y4HuS3Iu11QmqdkzYrNb4BeXLICmOXC ov6UU4/y29510uQjjV/g0c1LwzvY8TSq55HNNz/p9ygUR1rg+oJcNbJOk0SSlENNBjq3 v4MqObisAN1Uo+qR03Kbow1nc1nzZXiLUrJBOHMvGYgFMjzKZEKJ51WqtZ2qQAis79Kn 2GTmZHatm19xkC57C85MmlPmstLmtWVkRnqhi7gTjl7s3xS357CKTWdEZJjQUrql1nbs uEuA== 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=ByCB3xI+E0dw9+zVU543qP4IqonqbJsymciJzSidAGuQmzFiIjHwJzKq0ELPFg7/0U 9MMfTQrmZ+DWHufy0ZUIaQvywp/gTMmz2PPIdEIYbI8oWtmJZy1abQk29i8FVjBAI3hv qXRybXpyKd1WkKcdoJSIw4w6PaqjjbsHsEkZegs8lpneThoA4VjcwV3gTWCHiihXeJUJ vw+sVhSQ/6YiZHpM9dYmchMe6xWkoA9HvhElAsyFHW97oviVBLjPOUwrg5lPpuiqww9k mGyIWQxQjIY9TNRd5P+DM7bawgEW8+UZjKxy1KS2JH5Pshxlgr33i7DGGqf5/rvUdmH0 uhaw== X-Gm-Message-State: AGRZ1gJsTnUbZww0wzurxJ3DTboCqdr5afu0EuHyoH1iqMNp3Smq6vaL P6DVg86H5huKvtH/Y6/laZ7XXHTA X-Google-Smtp-Source: AJdET5e7DKlkdIHLmDMAxXZjsR0lfz+2/6GFC2MhimTO9xCCei55/vx/UF92TY3vyccLznMfNuOQvg== X-Received: by 2002:a37:d10:: with SMTP id 16mr21047778qkn.39.1541430523642; Mon, 05 Nov 2018 07:08:43 -0800 (PST) From: Julio Faracco To: qemu-devel@nongnu.org Date: Mon, 5 Nov 2018 13:08:06 -0200 Message-Id: <20181105150806.13649-5-jcfaracco@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181105150806.13649-1-jcfaracco@gmail.com> References: <20181105150806.13649-1-jcfaracco@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::743 Subject: [Qemu-devel] [PATCH v3 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: Kevin Wolf , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-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