From patchwork Fri Aug 10 04:07:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julio Faracco X-Patchwork-Id: 955928 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="PBMYGi2t"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ms7V4B6Jz9s5b for ; Fri, 10 Aug 2018 14:08:53 +1000 (AEST) Received: from localhost ([::1]:54170 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnyjL-0000p7-HT for incoming@patchwork.ozlabs.org; Fri, 10 Aug 2018 00:08:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnyij-0000nZ-Rm for qemu-devel@nongnu.org; Fri, 10 Aug 2018 00:08:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnyii-0002bA-Sy for qemu-devel@nongnu.org; Fri, 10 Aug 2018 00:08:13 -0400 Received: from mail-qt0-x241.google.com ([2607:f8b0:400d:c0d::241]:38463) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fnyii-0002aG-Mq; Fri, 10 Aug 2018 00:08:12 -0400 Received: by mail-qt0-x241.google.com with SMTP id w26-v6so9016349qto.5; Thu, 09 Aug 2018 21:08: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=aLrs+E6+diswMUSxliQaa8sQ5JemVMgzp57ZKMgnaeY=; b=PBMYGi2tozDmCP6oKlIE1NOn9OD6y/surhww1v+VSkZFoXWUHgD0JuKOyMgj5Tt0Gr LceraVhqyV4Sk0PJB8kyXg7ATh9Hir8VDL9pOZu6jce+FeKOPUDiqs0d7tyaFNkSv9vm AGKyRxJQtATB80qUNeja7vKwRH9VKB9n/HlRaMSSplLATlJkUFfqWN638rSlrrAr8Oh4 HvKO633O1MuOCFk7FyyyjoAh2GRd9CjLMppCsIP7gCF9Tgif74AAHpi3J3RV0EDlNZ9c IwozV3mvFBUk+mZBhtN2CKK+IPbHHPpuxl5BxLmsWExOB4Z97XQPp18NW/XWJwr4JGu4 yKFA== 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=aLrs+E6+diswMUSxliQaa8sQ5JemVMgzp57ZKMgnaeY=; b=cAd1a1fW2LidKfGh+JtfbNS6EP0SIL5nFlsggXEoIF//sJ798wusSjfBwyh8p9GzXt X74qtjGhN+L6PDFOqv1zz/aY+cZ4lA3LoUIh/MkfEoUA+op80akxbe30yg88SUdHbVL2 c77CfCKLuRexkktyLr3U+Ez04NZANcys1ncTT1wIo3OmoUtx9568IPTSoeEdFeSRlu54 RU7j4EuT5lGPb8YOmrs0dgwzTrH93P4GTLTxVVOiy5oLxO+Wv7abVw3BPM7t9/l84C+c TaOnDOPW/ibzbKA8OpVTv7w+FjNjA1+4LjlBULVtLVRABh6hLsP3pG7K6W22jnWKFykX 0p6Q== X-Gm-Message-State: AOUpUlFTaJY1vbjNZXPMoutC3Onsc6Ke3pbxioujjlUc6Y2SWFN8QQ6t 1V99pf3AkTXL6C41kSofa3pEU0u2 X-Google-Smtp-Source: AA+uWPyNgVCOfrlKXQM0/Ivy4d3sU9xYJZo7ZHRVytZZL5m5WkTPwNOP8gLj7nsCqi7FdyqueVGj7A== X-Received: by 2002:a0c:e505:: with SMTP id l5-v6mr4348375qvm.128.1533874091700; Thu, 09 Aug 2018 21:08:11 -0700 (PDT) Received: from localhost.localdomain ([186.223.91.15]) by smtp.gmail.com with ESMTPSA id s53-v6sm6561555qts.5.2018.08.09.21.08.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Aug 2018 21:08:11 -0700 (PDT) From: Julio Faracco To: qemu-devel@nongnu.org Date: Fri, 10 Aug 2018 01:07:40 -0300 Message-Id: <20180810040743.25424-2-jcfaracco@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180810040743.25424-1-jcfaracco@gmail.com> References: <20180810040743.25424-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::241 Subject: [Qemu-devel] [PATCH 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 | 54 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 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..d09b544a0a --- /dev/null +++ b/block/dmg-lzfse.c @@ -0,0 +1,54 @@ +/* + * 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"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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) +{ + void *aux; + size_t aux_allocated; + size_t out_size; + + aux_allocated = lzfse_decode_scratch_size(); + aux = g_malloc(aux_allocated); + + if (aux_allocated != 0 && aux == 0) { + return -1; + } + + out_size = lzfse_decode_buffer((uint8_t *) next_out, avail_out, + (uint8_t *) next_in, avail_in, aux); + + return out_size; +} + +__attribute__((constructor)) +static void dmg_lzfse_init(void) +{ + assert(!dmg_uncompress_lzfse); + dmg_uncompress_lzfse = dmg_uncompress_lzfse_do; +} From patchwork Fri Aug 10 04:07:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julio Faracco X-Patchwork-Id: 955931 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dU3nMXXB"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ms9s6Dzlz9s4Z for ; Fri, 10 Aug 2018 14:10:57 +1000 (AEST) Received: from localhost ([::1]:54180 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnylL-0003Ix-IG for incoming@patchwork.ozlabs.org; Fri, 10 Aug 2018 00:10:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnyio-0000ri-Ti for qemu-devel@nongnu.org; Fri, 10 Aug 2018 00:08:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnyin-0002eQ-5H for qemu-devel@nongnu.org; Fri, 10 Aug 2018 00:08:18 -0400 Received: from mail-qt0-x230.google.com ([2607:f8b0:400d:c0d::230]:43317) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fnyin-0002dq-08; Fri, 10 Aug 2018 00:08:17 -0400 Received: by mail-qt0-x230.google.com with SMTP id f18-v6so8986270qtp.10; Thu, 09 Aug 2018 21:08:16 -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=LKlDIY7t/ouvBMe8x6xTFB1lk/l9jl/KWpOoYzTpoNs=; b=dU3nMXXBCm/HrGbXHLNvPC3geDm0tHi35St7T8SLv74NwoDN5BVgKv8PPeIa2cmGOk yvczEygAFIrJMhGeqO2SY4P7/wAphMlihORdTYQI7WtW/yuYUBMpeHnr/5WVwdhWwdTG QtI5spRLAA0q4jn+hJmiDERgOHnF+0l0eZsBstZjjewrN8vXhJ6PHlKP99oUThCk2rm0 RJ0rTfXG8YA9GSrLBpJlXSbGTL4OtnvXXS1xm2ifDuXgs3QddKt2YH2v9xtXAGngrM/m 2Gt4QW46l0gEZwU35Jk95A5p5sxOcxvBNO3tVFL2UgqIY3OWjq5Yyqs1T8Hk0LgOhKOv R6CQ== 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=LKlDIY7t/ouvBMe8x6xTFB1lk/l9jl/KWpOoYzTpoNs=; b=WnQzDE6Pcwat8Wom/pgPzOLDDk5DrxPJdAN6PQ13KSlTL//OLlu37Y3xik6fUysvPL TqbBXAiAd1sDN/+Q0H8q2wy+oZ/joArfEDnggdTFclGeab7Hci4aQf/04a+nN98ntxXC YhwCZKeogkA7hW8dpGG/XGtudcv6UeqXb3mevk1g0zOJVROt3GTSDcOSS8ZkYdkG2mvw Xzi9vVr0i1CsdS5epuPmRMHp5qYlZ+YQ8l7t+PUD8u+poig9pcm7hh82sD84h9uqJHPO XE/Z1Wwz3hJLNKIvYAQPumjDdfZSTTGFGOPff/jZ4XOUiUhGZ0lANXmkumd+4X2L3kjd Bkug== X-Gm-Message-State: AOUpUlEALrW8BrMxJbZQRmDzLJqGyDqke+6ol/kzWhDEZeqHKNwAZSxt 6HolOHf1yaNKH96USI6hyEphl/N/ X-Google-Smtp-Source: AA+uWPzUWGuYkBjW6pNEl3Jf/ZFqPrAISBw0D4Uwh8MKpwkzq3unqOYD8mPyDL/IMWsq67TKUqjh8A== X-Received: by 2002:ac8:95a:: with SMTP id z26-v6mr4929966qth.211.1533874096012; Thu, 09 Aug 2018 21:08:16 -0700 (PDT) Received: from localhost.localdomain ([186.223.91.15]) by smtp.gmail.com with ESMTPSA id s53-v6sm6561555qts.5.2018.08.09.21.08.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Aug 2018 21:08:15 -0700 (PDT) From: Julio Faracco To: qemu-devel@nongnu.org Date: Fri, 10 Aug 2018 01:07:41 -0300 Message-Id: <20180810040743.25424-3-jcfaracco@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180810040743.25424-1-jcfaracco@gmail.com> References: <20180810040743.25424-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::230 Subject: [Qemu-devel] [PATCH 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 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 := $(LIBSSH2_CFLAGS) ssh.o-libs := $(LIBSSH2_LIBS) block-obj-$(if $(CONFIG_BZIP2),m,n) += dmg-bz2.o dmg-bz2.o-libs := $(BZIP2_LIBS) +block-obj-$(if $(CONFIG_LZFSE),m,n) += dmg-lzfse.o +dmg-lzfse.o-libs := $(LZFSE_LIBS) qcow.o-libs := -lz linux-aio.o-libs := -laio parallels.o-cflags := $(LIBXML2_CFLAGS) diff --git a/configure b/configure index 2a7796ea80..b12a16f2bf 100755 --- a/configure +++ b/configure @@ -432,6 +432,7 @@ capstone="" lzo="" snappy="" bzip2="" +lzfse="" guest_agent="" guest_agent_with_vss="no" guest_agent_ntddscsi="no" @@ -1300,6 +1301,10 @@ for opt do ;; --enable-bzip2) bzip2="yes" ;; + --enable-lzfse) lzfse="yes" + ;; + --disable-lzfse) lzfse="no" + ;; --enable-guest-agent) guest_agent="yes" ;; --disable-guest-agent) guest_agent="no" @@ -1689,6 +1694,8 @@ disabled with --disable-FEATURE, default is enabled if 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,25 @@ EOF fi fi +########################################## +# lzfse check + +if test "$lzfse" != "no" ; then + cat > $TMPC << EOF +#include +int main(void) { lzfse_decode_scratch_size(); return 0; } +EOF + if compile_prog "" "-llzfse" ; then + libs_softmmu="$libs_softmmu -llzfse" + lzfse="yes" + else + if test "$lzfse" = "yes"; then + feature_not_found "lzfse" "Install lzfse devel" + fi + lzfse="no" + fi +fi + ########################################## # libseccomp check @@ -6001,6 +6027,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 +6552,11 @@ if test "$bzip2" = "yes" ; then echo "BZIP2_LIBS=-lbz2" >> $config_host_mak fi +if test "$lzfse" = "yes" ; then + echo "CONFIG_LZFSE=y" >> $config_host_mak + echo "LZFSE_LIBS=-llzfse" >> $config_host_mak +fi + if test "$libiscsi" = "yes" ; then echo "CONFIG_LIBISCSI=m" >> $config_host_mak echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak From patchwork Fri Aug 10 04:07:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julio Faracco X-Patchwork-Id: 955932 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="n4PSf1jo"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ms9z31Xpz9s4Z for ; Fri, 10 Aug 2018 14:11:03 +1000 (AEST) Received: from localhost ([::1]:54185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnylR-0003pH-3s for incoming@patchwork.ozlabs.org; Fri, 10 Aug 2018 00:11:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnyir-0000u0-B0 for qemu-devel@nongnu.org; Fri, 10 Aug 2018 00:08:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnyiq-0002iN-Cn for qemu-devel@nongnu.org; Fri, 10 Aug 2018 00:08:21 -0400 Received: from mail-qt0-x241.google.com ([2607:f8b0:400d:c0d::241]:39352) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fnyiq-0002hs-7M; Fri, 10 Aug 2018 00:08:20 -0400 Received: by mail-qt0-x241.google.com with SMTP id q12-v6so9008808qtp.6; Thu, 09 Aug 2018 21:08:20 -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=n/xFIIG+C1fNrhN1pK2crLOmdXAwwmn5njoEGnl+9ME=; b=n4PSf1jon7zZHbxrQMan3ZDBWilwtl7je5wK2BGKeNSBINUZYBDkEZP9kbIIxwho4P q8mPASIGpmexwDTR4JqXjYsHbjF5pCBkSlsCeaEJwOc9CLAOZrmGpZXQLFKQ2zb9dC7W 6tOe2ep/Z+vysEwtmyHX4380CCWKaKEcS6igb5Y1LqmYdCLquzcMUqU8FLL3/eIXKhTg yx/9Pujq0t0wWIn28sIj5OWsIAH879m4T+em+xzXR6jVY50kN0n1GSr7/AQ81THSJCv8 rym/yIszw4Dnb0SRMdUWsXYslecVeR33qwP6KfwHBdDyXDpapaGb4qQZJboS8kJJybkp aSPg== 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=n/xFIIG+C1fNrhN1pK2crLOmdXAwwmn5njoEGnl+9ME=; b=dY3PsbnpVySWiY1K1UwsMQaiw2fJiAznBpGqVgQvZbNf9Bnz8uVxTWDboBgP2GDlOX PuY4WdwPgdvKu6cMExz62D3um3bGJXrBD6C9l/eeb06Hqb/XiGnt9le+aGfHxnJOe1rc mo/7otWs294ESjVtqie6CSNU2QmKRk7TqWSgsR8Bg+g9bWxAXAtdhLyxWvRcv4wmvbKU U1Dx6xb5lmP0DTGLdJvdDLVmOtQpjuYUmei48Xegb/tD9gzbTVv5ipn9yVGkU3JNVXuU rqO/qs2c9tmsnCQAgHpGZwRSPKPDIEGeAR5Dib3P7uaNPZjyo9TCMMNdwZfEUmQrLpYn 5NJQ== X-Gm-Message-State: AOUpUlERZZK1HdSDe1MyRaiWeW40kcWR6+lFvnRBUQhGqxuZ1yGH5yYA R53hAHGjhctCi+35LgwdVQPacfg6 X-Google-Smtp-Source: AA+uWPxQlD8WflxHWSpxyduR9Dh1wWGeAZfAcdb1kA7sQ+79RUuoDo6MQv7QEMUOc15jm0UFrZkVjw== X-Received: by 2002:ac8:1b49:: with SMTP id p9-v6mr4994829qtk.132.1533874099330; Thu, 09 Aug 2018 21:08:19 -0700 (PDT) Received: from localhost.localdomain ([186.223.91.15]) by smtp.gmail.com with ESMTPSA id s53-v6sm6561555qts.5.2018.08.09.21.08.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Aug 2018 21:08:18 -0700 (PDT) From: Julio Faracco To: qemu-devel@nongnu.org Date: Fri, 10 Aug 2018 01:07:42 -0300 Message-Id: <20180810040743.25424-4-jcfaracco@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180810040743.25424-1-jcfaracco@gmail.com> References: <20180810040743.25424-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::241 Subject: [Qemu-devel] [PATCH 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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..390ab67e53 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); +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 used * or truncating when converting to 32-bit types @@ -107,6 +110,7 @@ static void update_max_chunk_size(BDRVDMGState *s, uint32_t chunk, switch (s->types[chunk]) { case 0x80000005: /* zlib compressed */ case 0x80000006: /* bzip2 compressed */ + case 0x80000007: /* lzfse compressed */ compressed_size = s->lengths[chunk]; uncompressed_sectors = 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 *options, int flags, } block_module_load_one("dmg-bz2"); + block_module_load_one("dmg-lzfse"); s->n_chunks = 0; s->offsets = s->lengths = s->sectors = s->sectorcounts = 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 = bdrv_pread(bs->file, s->offsets[chunk], + s->compressed_chunk, s->lengths[chunk]); + if (ret != s->lengths[chunk]) { + return -1; + } + + ret = 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 = 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); +extern int (*dmg_uncompress_lzfse)(char *next_in, unsigned int avail_in, + char *next_out, unsigned int avail_out); + #endif From patchwork Fri Aug 10 04:07:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julio Faracco X-Patchwork-Id: 955930 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kTx7i1jG"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ms7p3hzqz9s4Z for ; Fri, 10 Aug 2018 14:09:10 +1000 (AEST) Received: from localhost ([::1]:54173 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnyjc-00015N-42 for incoming@patchwork.ozlabs.org; Fri, 10 Aug 2018 00:09:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55819) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnyj0-00012i-FR for qemu-devel@nongnu.org; Fri, 10 Aug 2018 00:08:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnyiw-0002nj-Es for qemu-devel@nongnu.org; Fri, 10 Aug 2018 00:08:30 -0400 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:35174) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fnyiw-0002n2-8v; Fri, 10 Aug 2018 00:08:26 -0400 Received: by mail-qk0-x241.google.com with SMTP id u21-v6so5586909qku.2; Thu, 09 Aug 2018 21:08:26 -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=F6sddB7xBSDnVR3yVuFsA5iYHg4qxv4ct5JruTbqyMg=; b=kTx7i1jGDoaEi2zSY3iAEfMr/hEQ+WE4nQciS9xwyLMRzmVini9fxIUgrK0SzLpgzM Xw8XpFNdWXCmo26aRYTXCzNpLwjme/rNz9iXk4zmnspy9Bpdof1pFexR8ssT5zLWb4XI +CErPtNLUg00FyNSAC6NefGDzIBGvNpRXHllFBs3KqYABgw2fx2FYZCH8iD0DE5A0P4F vyb5f1lJs6r9e5+Sr3BsqjDyM8H2I4pNQIiZVSepTHupq6EG60Flx9QMGPGqMC6wZmSj YbzAMk9mlvMvG3X/9PzYj9IEyXJC1LbRRDelFlcmIFne7X+s6XFN83X+uVKGLZ7o5aXx vygA== 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=F6sddB7xBSDnVR3yVuFsA5iYHg4qxv4ct5JruTbqyMg=; b=aOfJXSKJD9XMVOkPfx+Ye0/K2YnyebM6+f7hSBgbqeGr09Udj/2vw2kFa7aXZSGvRH 1frfvIsUTgGTthZGMv2ssDU1vTe7Dx7dpJH7jtzsrX+xxkFVujpOFXSzTESa4rpjOh24 sRsy84TLR6U0hHU6pJkW9ZgXJQ22hZmlW2AIuEzHjoVUEpIcN+iyW/sfDpuq69QIeIc9 ejPVQDhSkAw9Em/DFp+40DJexA29ACMDMn7q0LZ6CLagftJFAGIQiYuQHTc0msTwTlWP DAo3VYLlhSWWHSnGzleYHnoWKAOTZJKRq8QeZC/VBxFOIFXQ29gtH3KKQSHKqtSPRGvt w83Q== X-Gm-Message-State: AOUpUlHIlIeEap04ZjG5UCHJEWkzx9k5Up47u4zVyx8Ne5LCZHxIaETK D4qJ6AhThZvrRXU2TsEKTSkIuhPN X-Google-Smtp-Source: AA+uWPwhWIzYoEZ2sXi0LAkvr2o0gzj2rrwqZD1VqJkayBl5vIXnvHDT4K09GiPgYj05waCTarbluA== X-Received: by 2002:a37:c3cf:: with SMTP id r76-v6mr4428239qkl.150.1533874105273; Thu, 09 Aug 2018 21:08:25 -0700 (PDT) Received: from localhost.localdomain ([186.223.91.15]) by smtp.gmail.com with ESMTPSA id s53-v6sm6561555qts.5.2018.08.09.21.08.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Aug 2018 21:08:24 -0700 (PDT) From: Julio Faracco To: qemu-devel@nongnu.org Date: Fri, 10 Aug 2018 01:07:43 -0300 Message-Id: <20180810040743.25424-5-jcfaracco@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180810040743.25424-1-jcfaracco@gmail.com> References: <20180810040743.25424-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::241 Subject: [Qemu-devel] [PATCH 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 390ab67e53..ae379adb20 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -44,6 +44,19 @@ enum { DMG_SECTORCOUNTS_MAX = DMG_LENGTHS_MAX / 512, }; +enum { + /* DMG Block Type */ + UDZE=0, /* Zeroes */ + UDRW, /* RAW type */ + UDIG, /* Ignore */ + UDCO=0x80000004, + UDZO, + UDBZ, + ULFO, + UDCM=0x7ffffffe, /* Comments */ + UDLE /* Last Entry */ +}; + static int dmg_probe(const uint8_t *buf, int buf_size, const char *filename) { int len; @@ -108,16 +121,16 @@ static void update_max_chunk_size(BDRVDMGState *s, uint32_t chunk, uint32_t uncompressed_sectors = 0; switch (s->types[chunk]) { - case 0x80000005: /* zlib compressed */ - case 0x80000006: /* bzip2 compressed */ - case 0x80000007: /* lzfse compressed */ + case UDCO: /* zlib compressed */ + case UDBZ: /* bzip2 compressed */ + case ULFO: /* lzfse compressed */ compressed_size = s->lengths[chunk]; uncompressed_sectors = s->sectorcounts[chunk]; break; - case 1: /* copy */ + case UDRW: /* copy */ uncompressed_sectors = 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 used * 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 UDCO: /* 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) s->current_chunk = 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 = 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 = bdrv_pread(bs->file, s->offsets[chunk], s->uncompressed_chunk, s->lengths[chunk]); if (ret != 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;