From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36692) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGVxq-0008K8-CD for qemu-devel@nongnu.org; Fri, 15 Mar 2013 10:50:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UGVxh-0004lp-7V for qemu-devel@nongnu.org; Fri, 15 Mar 2013 10:50:34 -0400 Received: from nodalink.pck.nerim.net ([62.212.105.220]:59575 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGVxg-0004lZ-Q7 for qemu-devel@nongnu.org; Fri, 15 Mar 2013 10:50:25 -0400 From: =?UTF-8?q?Beno=C3=AEt=20Canet?= Date: Fri, 15 Mar 2013 15:49:24 +0100 Message-Id: <1363358986-8360-11-git-send-email-benoit@irqsave.net> In-Reply-To: <1363358986-8360-1-git-send-email-benoit@irqsave.net> References: <1363358986-8360-1-git-send-email-benoit@irqsave.net> Subject: [Qemu-devel] [RFC V7 10/32] qcow2: Implement qcow2_compute_cluster_hash. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, =?UTF-8?q?Beno=C3=AEt=20Canet?= , stefanha@redhat.com Also factorize detection of libgnutls with vnc tls. Signed-off-by: Benoit Canet --- 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 3210d26..089b999 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 +#include +#endif static int qcow2_dedup_read_write_hash(BlockDriverState *bs, QCowHash *hash, @@ -159,7 +163,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 84317c6..0b8c92e 100755 --- a/configure +++ b/configure @@ -228,6 +228,7 @@ glusterfs="" virtio_blk_data_plane="" gtk="" gtkabi="2.0" +sha256_dedup="yes" # parse CC options first for opt do @@ -905,6 +906,10 @@ for opt do ;; --with-gtkabi=*) gtkabi="$optarg" ;; + --disable-sha256-dedup) sha256_dedup="no" + ;; + --enable-sha256-dedup) sha256_dedup="yes" + ;; *) echo "ERROR: unknown option $opt"; show_help="yes" ;; esac @@ -1158,6 +1163,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 "" @@ -1763,32 +1770,60 @@ EOF fi ########################################## -# VNC TLS/WS detection -if test "$vnc" = "yes" -a \( "$vnc_tls" != "no" -o "$vnc_ws" != "no" \) ; then - cat > $TMPC < $TMPC < -int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; } +#include +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 @@ -3418,6 +3453,7 @@ echo "seccomp support $seccomp" echo "coroutine backend $coroutine_backend" 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" @@ -3786,6 +3822,10 @@ if test "$virtio_blk_data_plane" = "yes" ; then echo "CONFIG_VIRTIO_BLK_DATA_PLANE=y" >> $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