Message ID | 1360153926-9492-10-git-send-email-benoit@irqsave.net |
---|---|
State | New |
Headers | show |
On Wed, Feb 06, 2013 at 01:31:42PM +0100, Benoît Canet wrote: > diff --git a/configure b/configure > index 0657b1a..389f8aa 100755 > --- a/configure > +++ b/configure > @@ -1749,6 +1749,28 @@ EOF > fi > > ########################################## > +# QCOW Deduplication gnutls detection > +cat > $TMPC <<EOF > +#include <gnutls/gnutls.h> > +#include <gnutls/crypto.h> > +int main(void) {char data[4096], digest[32]; > +gnutls_hash_fast(GNUTLS_DIG_SHA256, data, 4096, digest); > +return 0; > +} > +EOF > +qcow_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null` > +qcow_tls_libs=`$pkg_config --libs gnutls 2> /dev/null` > +if compile_prog "$qcow_tls_cflags" "$qcow_tls_libs" ; then > + qcow_tls=yes > + libs_softmmu="$qcow_tls_libs $libs_softmmu" > + libs_tools="$qcow_tls_libs $libs_softmmu" > + QEMU_CFLAGS="$QEMU_CFLAGS $qcow_tls_cflags" > +else > + echo "gnutls > 2.10.0 required to compile QEMU" > + exit 1 > +fi > + > +########################################## > # VNC SASL detection > if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then > cat > $TMPC <<EOF VNC already depends on gnutls. Can the gnultls probe be reused? No point probing twice, once for dedup and once for vnc. Stefan
diff --git a/block/qcow2-dedup.c b/block/qcow2-dedup.c index a424af8..45b2326 100644 --- a/block/qcow2-dedup.c +++ b/block/qcow2-dedup.c @@ -25,6 +25,8 @@ * THE SOFTWARE. */ +#include <gnutls/gnutls.h> +#include <gnutls/crypto.h> #include "block/block_int.h" #include "qemu-common.h" #include "qcow2.h" @@ -157,7 +159,16 @@ static int qcow2_compute_cluster_hash(BlockDriverState *bs, QCowHash *hash, uint8_t *data) { - return 0; + BDRVQcowState *s = bs->opaque; + switch (s->dedup_hash_algo) { + case QCOW_HASH_SHA256: + return gnutls_hash_fast(GNUTLS_DIG_SHA256, data, + s->cluster_size, hash->data); + default: + error_report("Invalid deduplication hash algorithm %i", + s->dedup_hash_algo); + abort(); + } } /* diff --git a/configure b/configure index 0657b1a..389f8aa 100755 --- a/configure +++ b/configure @@ -1749,6 +1749,28 @@ EOF fi ########################################## +# QCOW Deduplication gnutls detection +cat > $TMPC <<EOF +#include <gnutls/gnutls.h> +#include <gnutls/crypto.h> +int main(void) {char data[4096], digest[32]; +gnutls_hash_fast(GNUTLS_DIG_SHA256, data, 4096, digest); +return 0; +} +EOF +qcow_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null` +qcow_tls_libs=`$pkg_config --libs gnutls 2> /dev/null` +if compile_prog "$qcow_tls_cflags" "$qcow_tls_libs" ; then + qcow_tls=yes + libs_softmmu="$qcow_tls_libs $libs_softmmu" + libs_tools="$qcow_tls_libs $libs_softmmu" + QEMU_CFLAGS="$QEMU_CFLAGS $qcow_tls_cflags" +else + echo "gnutls > 2.10.0 required to compile QEMU" + exit 1 +fi + +########################################## # VNC SASL detection if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then cat > $TMPC <<EOF
Add detection of libgnutls used to compute SHA256 hashes Signed-off-by: Benoit Canet <benoit@irqsave.net> --- block/qcow2-dedup.c | 13 ++++++++++++- configure | 22 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-)