From: "Benoît Canet" <benoit@irqsave.net>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, "Benoît Canet" <benoit@irqsave.net>,
stefanha@redhat.com
Subject: [Qemu-devel] [RFC V8 13/24] qcow2: Implement qcow2_compute_cluster_hash.
Date: Thu, 20 Jun 2013 16:26:21 +0200 [thread overview]
Message-ID: <1371738392-9594-14-git-send-email-benoit@irqsave.net> (raw)
In-Reply-To: <1371738392-9594-1-git-send-email-benoit@irqsave.net>
Also factorize detection of libgnutls with vnc tls.
Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
block/qcow2-dedup.c | 17 +++++++++-
configure | 86 +++++++++++++++++++++++++++++++++++++--------------
2 files changed, 79 insertions(+), 24 deletions(-)
diff --git a/block/qcow2-dedup.c b/block/qcow2-dedup.c
index ffbf866..2d2c15c 100644
--- a/block/qcow2-dedup.c
+++ b/block/qcow2-dedup.c
@@ -28,6 +28,10 @@
#include "block/block_int.h"
#include "qemu-common.h"
#include "qcow2.h"
+#ifdef CONFIG_SHA256_DEDUP
+#include <gnutls/gnutls.h>
+#include <gnutls/crypto.h>
+#endif
/*
* Prepare a buffer containing everything required to compute cluster
@@ -142,7 +146,18 @@ static int qcow2_compute_cluster_hash(BlockDriverState *bs,
QCowHash *hash,
uint8_t *data)
{
- return 0;
+ BDRVQcowState *s = bs->opaque;
+ switch (s->dedup_hash_algo) {
+#ifdef CONFIG_SHA256_DEDUP
+ case QCOW_HASH_SHA256:
+ return gnutls_hash_fast(GNUTLS_DIG_SHA256, data,
+ s->cluster_size, hash->data);
+#endif
+ default:
+ error_report("Invalid deduplication hash algorithm %i",
+ s->dedup_hash_algo);
+ abort();
+ }
}
/*
diff --git a/configure b/configure
index e818e8b..34b26b2 100755
--- a/configure
+++ b/configure
@@ -240,6 +240,7 @@ gtk=""
gtkabi="2.0"
tpm="no"
libssh2=""
+sha256_dedup="yes"
# parse CC options first
for opt do
@@ -930,6 +931,10 @@ for opt do
;;
--enable-libssh2) libssh2="yes"
;;
+ --disable-sha256-dedup) sha256_dedup="no"
+ ;;
+ --enable-sha256-dedup) sha256_dedup="yes"
+ ;;
*) echo "ERROR: unknown option $opt"; show_help="yes"
;;
esac
@@ -1190,6 +1195,8 @@ echo " --with-coroutine=BACKEND coroutine backend. Supported options:"
echo " gthread, ucontext, sigaltstack, windows"
echo " --enable-glusterfs enable GlusterFS backend"
echo " --disable-glusterfs disable GlusterFS backend"
+echo " --disable-sha256-dedup disable sha256 dedup"
+echo " --enable-sha256-dedup enables sha256 dedup"
echo " --enable-gcov enable test coverage analysis with gcov"
echo " --gcov=GCOV use specified gcov [$gcov_tool]"
echo " --enable-tpm enable TPM support"
@@ -1812,32 +1819,60 @@ EOF
fi
##########################################
-# VNC TLS/WS detection
-if test "$vnc" = "yes" -a \( "$vnc_tls" != "no" -o "$vnc_ws" != "no" \) ; then
- cat > $TMPC <<EOF
+# gnutls detection (factorize the VNC TLS and SHA256 deduplication test)
+cat > $TMPC <<EOF
#include <gnutls/gnutls.h>
-int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
+#include <gnutls/crypto.h>
+int main(void) {char data[4096], digest[32];
+gnutls_hash_fast(GNUTLS_DIG_SHA256, data, 4096, digest);
+return 0;
+}
EOF
- vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
- vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
- if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
- if test "$vnc_tls" != "no" ; then
- vnc_tls=yes
- fi
- if test "$vnc_ws" != "no" ; then
- vnc_ws=yes
- fi
- libs_softmmu="$vnc_tls_libs $libs_softmmu"
- QEMU_CFLAGS="$QEMU_CFLAGS $vnc_tls_cflags"
+gnu_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
+gnu_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
+if compile_prog "$gnu_tls_cflags" "$gnu_tls_libs" ; then
+ gnu_tls=yes
+else
+ gnu_tls=no
+fi
+
+##########################################
+# VNC TLS/WS
+if test "$vnc" = "yes" -a "$gnu_tls" != "no"; then
+ if test "$vnc_tls" != "no" ; then
+ libs_softmmu="$gnu_tls_libs $libs_softmmu"
+ libs_tools="$gnu_tls_libs $libs_softmmu"
+ QEMU_CFLAGS="$QEMU_CFLAGS $gnu_tls_cflags"
+ vnc_tls=yes
+ fi
+ if test "$vnc_ws" != "no" ; then
+ libs_softmmu="$gnu_tls_libs $libs_softmmu"
+ libs_tools="$gnu_tls_libs $libs_softmmu"
+ QEMU_CFLAGS="$QEMU_CFLAGS $gnu_tls_cflags"
+ vnc_ws=yes
+ fi
+else
+ if test "$vnc_tls" = "yes" ; then
+ feature_not_found "vnc-tls"
+ fi
+ if test "$vnc_ws" = "yes" ; then
+ feature_not_found "vnc-ws"
+ fi
+ vnc_tls=no
+ vnc_ws=no
+fi
+
+##########################################
+# SHA256 deduplication
+if test "$sha256_dedup" = "yes"; then
+ if test "$gnu_tls" = "yes"; then
+ libs_softmmu="$gnu_tls_libs $libs_softmmu"
+ libs_tools="$gnu_tls_libs $libs_softmmu"
+ QEMU_CFLAGS="$QEMU_CFLAGS $gnu_tls_cflags"
+ sha256_dedup=yes
else
- if test "$vnc_tls" = "yes" ; then
- feature_not_found "vnc-tls"
- fi
- if test "$vnc_ws" = "yes" ; then
- feature_not_found "vnc-ws"
- fi
- vnc_tls=no
- vnc_ws=no
+ echo "gnutls > 2.10.0 required to compile QEMU with sha256 deduplication"
+ exit 1
fi
fi
@@ -3562,6 +3597,7 @@ echo "seccomp support $seccomp"
echo "coroutine backend $coroutine"
echo "GlusterFS support $glusterfs"
echo "virtio-blk-data-plane $virtio_blk_data_plane"
+echo "sha256-dedup $sha256_dedup"
echo "gcov $gcov_tool"
echo "gcov enabled $gcov"
echo "TPM support $tpm"
@@ -3951,6 +3987,10 @@ if test "$virtio_blk_data_plane" = "yes" ; then
echo 'CONFIG_VIRTIO_BLK_DATA_PLANE=$(CONFIG_VIRTIO)' >> $config_host_mak
fi
+if test "$sha256_dedup" = "yes" ; then
+ echo "CONFIG_SHA256_DEDUP=y" >> $config_host_mak
+fi
+
# USB host support
case "$usb" in
linux)
--
1.7.10.4
next prev parent reply other threads:[~2013-06-20 14:28 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-20 14:26 [Qemu-devel] [RFC V8 00/24] QCOW2 deduplication core functionality Benoît Canet
2013-06-20 14:26 ` [Qemu-devel] [RFC V8 01/24] qcow2: Add journal specification Benoît Canet
2013-07-02 14:42 ` Stefan Hajnoczi
2013-07-02 14:54 ` Kevin Wolf
2013-07-02 21:26 ` Benoît Canet
2013-07-03 8:08 ` Kevin Wolf
2013-07-03 7:51 ` Stefan Hajnoczi
2013-07-02 21:23 ` Benoît Canet
2013-07-03 8:01 ` Stefan Hajnoczi
2013-07-03 12:35 ` Benoît Canet
2013-07-03 8:04 ` Kevin Wolf
2013-07-03 12:30 ` Benoît Canet
2013-07-03 8:12 ` Stefan Hajnoczi
2013-07-03 12:53 ` Benoît Canet
2013-07-04 7:13 ` Stefan Hajnoczi
2013-07-04 10:01 ` Benoît Canet
2013-07-16 22:45 ` Benoît Canet
2013-07-17 8:20 ` Kevin Wolf
2013-06-20 14:26 ` [Qemu-devel] [RFC V8 02/24] qcow2: Add deduplication structures and fields Benoît Canet
2013-06-20 14:26 ` [Qemu-devel] [RFC V8 03/24] qcow2: Add journal Benoît Canet
2013-06-20 14:26 ` [Qemu-devel] [RFC V8 04/24] qcow2: Create the log store Benoît Canet
2013-06-20 14:26 ` [Qemu-devel] [RFC V8 05/24] qcow2: Add the hash store Benoît Canet
2013-06-20 14:26 ` [Qemu-devel] [RFC V8 06/24] qcow2: Add the deduplication store Benoît Canet
2013-06-20 14:26 ` [Qemu-devel] [RFC V8 07/24] qcow2: Add qcow2_dedup_read_missing_and_concatenate Benoît Canet
2013-06-20 14:26 ` [Qemu-devel] [RFC V8 08/24] qcow2: Create a way to link to l2 tables when deduplicating Benoît Canet
2013-06-20 14:26 ` [Qemu-devel] [RFC V8 09/24] qcow2: Make qcow2_update_cluster_refcount public Benoît Canet
2013-06-20 14:26 ` [Qemu-devel] [RFC V8 10/24] qcow2: Add qcow2_dedup and related functions Benoît Canet
2013-06-20 14:26 ` [Qemu-devel] [RFC V8 11/24] qcow2: Add qcow2_dedup_store_new_hashes Benoît Canet
2013-06-20 14:26 ` [Qemu-devel] [RFC V8 12/24] qcow2: Do allocate on rewrite on the dedup case Benoît Canet
2013-06-20 14:26 ` Benoît Canet [this message]
2013-06-20 14:26 ` [Qemu-devel] [RFC V8 14/24] qcow2: Load and save deduplication table header extension Benoît Canet
2013-06-20 14:26 ` [Qemu-devel] [RFC V8 15/24] qcow2: Extract qcow2_set_incompat_feature and qcow2_clear_incompat_feature Benoît Canet
2013-06-20 14:26 ` [Qemu-devel] [RFC V8 16/24] block: Add qcow2_dedup format and image creation code Benoît Canet
2013-06-20 14:26 ` [Qemu-devel] [RFC V8 17/24] qcow2: Drop hash for a given cluster when dedup makes refcount > 2^16/2 Benoît Canet
2013-06-20 14:26 ` [Qemu-devel] [RFC V8 18/24] qcow2: Remove hash when cluster is deleted Benoît Canet
2013-06-20 14:26 ` [Qemu-devel] [RFC V8 19/24] qcow2: Integrate deduplication in qcow2_co_writev loop Benoît Canet
2013-06-20 14:26 ` [Qemu-devel] [RFC V8 20/24] qcow2: Serialize write requests when deduplication is activated Benoît Canet
2013-06-20 14:26 ` [Qemu-devel] [RFC V8 21/24] qcow2: Integrate SKEIN hash algorithm in deduplication Benoît Canet
2013-06-20 14:26 ` [Qemu-devel] [RFC V8 22/24] qcow2: Add qcow2_dedup_init and qcow2_dedup_close Benoît Canet
2013-06-20 14:26 ` [Qemu-devel] [RFC V8 23/24] qcow2: Enable the deduplication feature Benoît Canet
2013-06-20 14:26 ` [Qemu-devel] [RFC V8 24/24] qcow2: Enable deduplication tests Benoît Canet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1371738392-9594-14-git-send-email-benoit@irqsave.net \
--to=benoit@irqsave.net \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).