Skip to contentSkip to conversation

quorum: Only compile when supported

PATCH In review Fam Zheng 5 participants 16 messages Jun 28, 2016 – Jul 6, 2016 Block layer

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH 1/1 quorum: Only compile when supported

This was the only exceptional module init function that does something else than a simple list of bdrv_register() calls, in all the block drivers.

The qcrypto_hash_supports is actually a static check, determined at compile time. Follow the block-job-$(CONFIG_FOO) convention for consistency.

---
 block/Makefile.objs | 2 +-
 block/quorum.c      | 4 ----
 2 files changed, 1 insertion(+), 5 deletions(-)
block/Makefile.objs +1 -1
index 44a5416..c87d605 100644
@@ -3,7 +3,7 @@ block-obj-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o qcow2-c
 block-obj-y += qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o
 block-obj-y += qed-check.o
 block-obj-$(CONFIG_VHDX) += vhdx.o vhdx-endian.o vhdx-log.o
-block-obj-y += quorum.o
+block-obj-$(CONFIG_GNUTLS_HASH) += quorum.o
 block-obj-y += parallels.o blkdebug.o blkverify.o blkreplay.o
 block-obj-y += block-backend.o snapshot.o qapi.o
 block-obj-$(CONFIG_WIN32) += raw-win32.o win32-aio.o
block/quorum.c +0 -4
index 331b726..18fbed8 100644
@@ -1113,10 +1113,6 @@ static BlockDriver bdrv_quorum = {
 
 static void bdrv_quorum_init(void)
 {
-    if (!qcrypto_hash_supports(QCRYPTO_HASH_ALG_SHA256)) {
-        /* SHA256 hash support is required for quorum device */
-        return;
-    }
     bdrv_register(&bdrv_quorum);
 }
 
Signature · 1 line
2.9.0
#2 lore raw
In reply to Fam Zheng
Quoted 3 lines · Fam Zheng

This was the only exceptional module init function that does something else than a simple list of bdrv_register() calls, in all the block drivers.

This sounds like this patch specifically wants to drop the check from bdrv_quorum_init().

I think keeping the check would be better; while we can probably assume that SHA256 is supported if CONFIG_GNUTLS_HASH is defined, it would still technically be better to actually check for that support.

However, since this is probably only a theoretical issue, if there's a good reason (like preparation for dynamic block driver modules) for having to drop the check from bdrv_quorum_init(), I think it's alright to do so.

Max

Quoted 39 lines

The qcrypto_hash_supports is actually a static check, determined at compile time. Follow the block-job-$(CONFIG_FOO) convention for consistency.

---
 block/Makefile.objs | 2 +-
 block/quorum.c      | 4 ----
 2 files changed, 1 insertion(+), 5 deletions(-)
block/Makefile.objs +1 -1
index 44a5416..c87d605 100644
@@ -3,7 +3,7 @@ block-obj-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o qcow2-c
 block-obj-y += qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o
 block-obj-y += qed-check.o
 block-obj-$(CONFIG_VHDX) += vhdx.o vhdx-endian.o vhdx-log.o
-block-obj-y += quorum.o
+block-obj-$(CONFIG_GNUTLS_HASH) += quorum.o
 block-obj-y += parallels.o blkdebug.o blkverify.o blkreplay.o
 block-obj-y += block-backend.o snapshot.o qapi.o
 block-obj-$(CONFIG_WIN32) += raw-win32.o win32-aio.o
block/quorum.c +0 -4
index 331b726..18fbed8 100644
@@ -1113,10 +1113,6 @@ static BlockDriver bdrv_quorum = {
 
 static void bdrv_quorum_init(void)
 {
-    if (!qcrypto_hash_supports(QCRYPTO_HASH_ALG_SHA256)) {
-        /* SHA256 hash support is required for quorum device */
-        return;
-    }
     bdrv_register(&bdrv_quorum);
 }
 
#3 lore raw
Quoted 10 lines · Max Reitz
Quoted 3 lines

This was the only exceptional module init function that does something else than a simple list of bdrv_register() calls, in all the block drivers.

This sounds like this patch specifically wants to drop the check from bdrv_quorum_init().

I think keeping the check would be better; while we can probably assume that SHA256 is supported if CONFIG_GNUTLS_HASH is defined, it would still technically be better to actually check for that support.

Right, but SHA256 was added to GNUTLS almost 10 years ago, so I don't think that adding such check has any practical effect.

Berto

author
#4 lore raw
In reply to Max Reitz
Quoted 11 lines · Max Reitz
Quoted 3 lines · Fam Zheng

This was the only exceptional module init function that does something else than a simple list of bdrv_register() calls, in all the block drivers.

This sounds like this patch specifically wants to drop the check from bdrv_quorum_init().

I think keeping the check would be better; while we can probably assume that SHA256 is supported if CONFIG_GNUTLS_HASH is defined, it would still technically be better to actually check for that support.

This one is effectively a static check so I think it's practically okay to skip it, and yes, the idea is this makes it easier to do dynamic driver loading.

Thanks,
Fam

Quoted 49 lines

However, since this is probably only a theoretical issue, if there's a good reason (like preparation for dynamic block driver modules) for having to drop the check from bdrv_quorum_init(), I think it's alright to do so.

Max

Quoted 39 lines

The qcrypto_hash_supports is actually a static check, determined at compile time. Follow the block-job-$(CONFIG_FOO) convention for consistency.

---
 block/Makefile.objs | 2 +-
 block/quorum.c      | 4 ----
 2 files changed, 1 insertion(+), 5 deletions(-)
block/Makefile.objs +1 -1
index 44a5416..c87d605 100644
@@ -3,7 +3,7 @@ block-obj-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o qcow2-c
 block-obj-y += qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o
 block-obj-y += qed-check.o
 block-obj-$(CONFIG_VHDX) += vhdx.o vhdx-endian.o vhdx-log.o
-block-obj-y += quorum.o
+block-obj-$(CONFIG_GNUTLS_HASH) += quorum.o
 block-obj-y += parallels.o blkdebug.o blkverify.o blkreplay.o
 block-obj-y += block-backend.o snapshot.o qapi.o
 block-obj-$(CONFIG_WIN32) += raw-win32.o win32-aio.o
block/quorum.c +0 -4
index 331b726..18fbed8 100644
@@ -1113,10 +1113,6 @@ static BlockDriver bdrv_quorum = {
 
 static void bdrv_quorum_init(void)
 {
-    if (!qcrypto_hash_supports(QCRYPTO_HASH_ALG_SHA256)) {
-        /* SHA256 hash support is required for quorum device */
-        return;
-    }
     bdrv_register(&bdrv_quorum);
 }
 
#5 lore raw
In reply to Fam Zheng

Dear Fam (or Zheng?),

Quoted 7 lines · Fam Zheng

This was the only exceptional module init function that does something else than a simple list of bdrv_register() calls, in all the block drivers.

The qcrypto_hash_supports is actually a static check, determined at compile time. Follow the block-job-$(CONFIG_FOO) convention for consistency.

Good idea.

[block/Makefile.objs]

block/Makefile.objs block-obj-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o qcow2-c · line 6

Quoted 6 lines
block/Makefile.objs +1 -1
@@ -3,7 +3,7 @@ block-obj-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o qcow2-c
 block-obj-y += qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o
 block-obj-y += qed-check.o
 block-obj-$(CONFIG_VHDX) += vhdx.o vhdx-endian.o vhdx-log.o
-block-obj-y += quorum.o
+block-obj-$(CONFIG_GNUTLS_HASH) += quorum.o

[...]
[block/quorum.c]

block/quorum.c static BlockDriver bdrv_quorum = { · line 1116

Quoted 7 lines
block/quorum.c +0 -4
 static void bdrv_quorum_init(void)
 {
-    if (!qcrypto_hash_supports(QCRYPTO_HASH_ALG_SHA256)) {
-        /* SHA256 hash support is required for quorum device */
-        return;
-    }
     bdrv_register(&bdrv_quorum);

The quorum driver needs SHA256 which was introduced in gnutls 2.11.1. However configure sets CONFIG_GNUTLS_HASH when gnutls 2.9.10+ is present. You should either bump the version in configure or add an explicit configure check for SHA256.

Sascha

Signature · 3 lines
Softwareentwicklung Sascha Silbe, Niederhofenstraße 5/1, 71229 Leonberg
https://se-silbe.de/
USt-IdNr. DE281696641
author
#6 lore raw
Quoted 1 line · Sascha Silbe

Dear Fam (or Zheng?),

Hi Sascha,

Zheng is the last name here. :)

Quoted 31 lines
Quoted 7 lines · Fam Zheng

This was the only exceptional module init function that does something else than a simple list of bdrv_register() calls, in all the block drivers.

The qcrypto_hash_supports is actually a static check, determined at compile time. Follow the block-job-$(CONFIG_FOO) convention for consistency.

Good idea.

[block/Makefile.objs]

block/Makefile.objs block-obj-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o qcow2-c · line 6

Quoted 6 lines
block/Makefile.objs +1 -1
@@ -3,7 +3,7 @@ block-obj-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o qcow2-c
 block-obj-y += qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o
 block-obj-y += qed-check.o
 block-obj-$(CONFIG_VHDX) += vhdx.o vhdx-endian.o vhdx-log.o
-block-obj-y += quorum.o
+block-obj-$(CONFIG_GNUTLS_HASH) += quorum.o

[...]
[block/quorum.c]

block/quorum.c static BlockDriver bdrv_quorum = { · line 1116

Quoted 7 lines
block/quorum.c +0 -4
 static void bdrv_quorum_init(void)
 {
-    if (!qcrypto_hash_supports(QCRYPTO_HASH_ALG_SHA256)) {
-        /* SHA256 hash support is required for quorum device */
-        return;
-    }
     bdrv_register(&bdrv_quorum);
Quoted 4 lines

The quorum driver needs SHA256 which was introduced in gnutls 2.11.1. However configure sets CONFIG_GNUTLS_HASH when gnutls 2.9.10+ is present. You should either bump the version in configure or add an explicit configure check for SHA256.

Yes, I just noticed commit 0c16c056a4f removed CONFIG_GNUTLS_HASH so I need to rebase anyway (that commit also fixed this version requirement we have been missing as you mentioned). Thanks for reviewing!

Fam

#7 lore raw
In reply to Sascha Silbe
Quoted 1 line · Sascha Silbe

The quorum driver needs SHA256 which was introduced in gnutls 2.11.1.

Are you sure about that?

* Version 1.7.4 (released 2007-02-05)

[...]

** API and ABI modifications:
GNUTLS_MAC_SHA256,
GNUTLS_MAC_SHA384,
GNUTLS_MAC_SHA512: New gnutls_mac_algorithm_t values. GNUTLS_DIG_SHA256,
GNUTLS_DIG_SHA384,
GNUTLS_DIG_SHA512: New gnutls_digest_algorithm_t values. GNUTLS_SIGN_RSA_SHA256,
GNUTLS_SIGN_RSA_SHA384,
GNUTLS_SIGN_RSA_SHA512: New gnutls_sign_algorithm_t values.

https://gitlab.com/gnutls/gnutls/blob/master/NEWS#L6570

Berto

#8 lore raw

Dear Alberto,

Quoted 4 lines · Alberto Garcia
Quoted 1 line · Sascha Silbe

The quorum driver needs SHA256 which was introduced in gnutls 2.11.1.

Quoted 8 lines

Are you sure about that?

* Version 1.7.4 (released 2007-02-05)

[...]

** API and ABI modifications:
GNUTLS_MAC_SHA256,

[...]

You are right, I misinterpreted the gnutls 2.11.1 NEWS entry. It added the RSA_NULL_SHA256 cipher suite, not the SHA256 hash algorithm.

So the existing configure check is good enough, no need to bump the required gnutls version.

Sascha

Signature · 3 lines
Softwareentwicklung Sascha Silbe, Niederhofenstraße 5/1, 71229 Leonberg
https://se-silbe.de/
USt-IdNr. DE281696641
#9 lore raw
In reply to Fam Zheng
Quoted 9 lines · Fam Zheng

This was the only exceptional module init function that does something else than a simple list of bdrv_register() calls, in all the block drivers.

The qcrypto_hash_supports is actually a static check, determined at compile time. Follow the block-job-$(CONFIG_FOO) convention for consistency.

The point of using qcrypto_hash_supports() is that it isolates the block code Makefile rules from the details of the current specific impl of the hash APIs in QEMU. As a prime example of why this is important, try rebasing to GIT master, and you'll find we no longer use gnutls for the hash APIs. We choose between libgcrypt, nettle or a empty stub for hash impls now. I think it is a backwards step to add back these makefile conditionals

Quoted 37 lines
---
 block/Makefile.objs | 2 +-
 block/quorum.c      | 4 ----
 2 files changed, 1 insertion(+), 5 deletions(-)
block/Makefile.objs +1 -1
index 44a5416..c87d605 100644
@@ -3,7 +3,7 @@ block-obj-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o qcow2-c
 block-obj-y += qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o
 block-obj-y += qed-check.o
 block-obj-$(CONFIG_VHDX) += vhdx.o vhdx-endian.o vhdx-log.o
-block-obj-y += quorum.o
+block-obj-$(CONFIG_GNUTLS_HASH) += quorum.o
 block-obj-y += parallels.o blkdebug.o blkverify.o blkreplay.o
 block-obj-y += block-backend.o snapshot.o qapi.o
 block-obj-$(CONFIG_WIN32) += raw-win32.o win32-aio.o
block/quorum.c +0 -4
index 331b726..18fbed8 100644
@@ -1113,10 +1113,6 @@ static BlockDriver bdrv_quorum = {
 
 static void bdrv_quorum_init(void)
 {
-    if (!qcrypto_hash_supports(QCRYPTO_HASH_ALG_SHA256)) {
-        /* SHA256 hash support is required for quorum device */
-        return;
-    }
     bdrv_register(&bdrv_quorum);
 }
 
Signature · 1 line
2.9.0

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
author
#10 lore raw
Quoted 11 lines · Daniel P. Berrange
Quoted 9 lines · Fam Zheng

This was the only exceptional module init function that does something else than a simple list of bdrv_register() calls, in all the block drivers.

The qcrypto_hash_supports is actually a static check, determined at compile time. Follow the block-job-$(CONFIG_FOO) convention for consistency.

Quoted 7 lines

The point of using qcrypto_hash_supports() is that it isolates the block code Makefile rules from the details of the current specific impl of the hash APIs in QEMU. As a prime example of why this is important, try rebasing to GIT master, and you'll find we no longer use gnutls for the hash APIs. We choose between libgcrypt, nettle or a empty stub for hash impls now. I think it is a backwards step to add back these makefile conditionals

I don't want to spoil the isolation, but I think it's also worth to keep the reasoning of whether a driver is supported as simple as possible. In other words, if it's determined at configure time, there is no reason to use a runtime check, right?

Fam

Quoted 46 lines
Quoted 38 lines
---
 block/Makefile.objs | 2 +-
 block/quorum.c      | 4 ----
 2 files changed, 1 insertion(+), 5 deletions(-)
block/Makefile.objs +1 -1
index 44a5416..c87d605 100644
@@ -3,7 +3,7 @@ block-obj-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o qcow2-c
 block-obj-y += qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o
 block-obj-y += qed-check.o
 block-obj-$(CONFIG_VHDX) += vhdx.o vhdx-endian.o vhdx-log.o
-block-obj-y += quorum.o
+block-obj-$(CONFIG_GNUTLS_HASH) += quorum.o
 block-obj-y += parallels.o blkdebug.o blkverify.o blkreplay.o
 block-obj-y += block-backend.o snapshot.o qapi.o
 block-obj-$(CONFIG_WIN32) += raw-win32.o win32-aio.o
block/quorum.c +0 -4
index 331b726..18fbed8 100644
@@ -1113,10 +1113,6 @@ static BlockDriver bdrv_quorum = {
 
 static void bdrv_quorum_init(void)
 {
-    if (!qcrypto_hash_supports(QCRYPTO_HASH_ALG_SHA256)) {
-        /* SHA256 hash support is required for quorum device */
-        return;
-    }
     bdrv_register(&bdrv_quorum);
 }
 
Signature · 1 line
2.9.0

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#11 lore raw
Quoted 20 lines · Fam Zheng
Quoted 11 lines · Daniel P. Berrange
Quoted 9 lines · Fam Zheng

This was the only exceptional module init function that does something else than a simple list of bdrv_register() calls, in all the block drivers.

The qcrypto_hash_supports is actually a static check, determined at compile time. Follow the block-job-$(CONFIG_FOO) convention for consistency.

Quoted 7 lines

The point of using qcrypto_hash_supports() is that it isolates the block code Makefile rules from the details of the current specific impl of the hash APIs in QEMU. As a prime example of why this is important, try rebasing to GIT master, and you'll find we no longer use gnutls for the hash APIs. We choose between libgcrypt, nettle or a empty stub for hash impls now. I think it is a backwards step to add back these makefile conditionals

Quoted 4 lines

I don't want to spoil the isolation, but I think it's also worth to keep the reasoning of whether a driver is supported as simple as possible. In other words, if it's determined at configure time, there is no reason to use a runtime check, right?

While the crypto algorithms may all be built-in at compile time, there can be situations where they are forbidden from use at runtime. For example the FIPS mode activation will disable many algorithms from use. You might say that this doesn't matter since FIPs mode dosn't affect SHA256, but the point of having the generic crypto API inside QEMU is to stop us sprinkling these kind of ad-hoc assumptions about crypto policies across the code base.

Can you backup and explain more detail what the actual problem you're trying to solve is. IIUC, it is related to module loading, but I'm not seeing exactly what it is. Surely when we load the quorum.so module, we'll just invoke the bdrv_quorum_init() method as normal, so I would have expected the current logic to continue to "just work". ie, just because we load a module, does not mean that module should be required to register its block driver.

The other alternative though is to simply remove the hash check from the init method *and* unconditionally compile it, and simply allow the quorum_open() method do the qcrypto_hash_supports() check. This would be the same way that the LUKS block driver works - it has many crypto algorithms in use, chosen dynamically, so it has no choice but to test this at open() time.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
block/quorum.c +0 -0
index 331b726..18fbed8 100644
@@ -1113,10 +1113,6 @@ static BlockDriver bdrv_quorum = {
 
Quoted 8 lines
Quoted 8 lines

block/quorum.c static BlockDriver bdrv_quorum = { · line 1117

Quoted 8 lines
block/quorum.c +0 -4
 static void bdrv_quorum_init(void)
 {
-    if (!qcrypto_hash_supports(QCRYPTO_HASH_ALG_SHA256)) {
-        /* SHA256 hash support is required for quorum device */
-        return;
-    }
     bdrv_register(&bdrv_quorum);
 }

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
author
#12 lore raw
Quoted 4 lines · Daniel P. Berrange

Can you backup and explain more detail what the actual problem you're trying to solve is. IIUC, it is related to module loading, but I'm not seeing exactly what it is.

This patch originated when I was researching all drivers' block_init functions about module loading, and realized this is the only one "runtime check" and is poorly established as it's actually "static". The unnecessity is more of the reason behind the patch.

Its relationship with module loading is, it makes implementing this idea easier:

https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg07580.html

Quoted 4 lines

Surely when we load the quorum.so module, we'll just invoke the bdrv_quorum_init() method as normal, so I would have expected the current logic to continue to "just work". ie, just because we load a module, does not mean that module should be required to register its block driver.

You are right, module init function can do anything it wants, as long as we really need it to. It's just not clear to me quorum is the case.

BTW thanks for sending the reverting series!

Quoted 7 lines

The other alternative though is to simply remove the hash check from the init method *and* unconditionally compile it, and simply allow the quorum_open() method do the qcrypto_hash_supports() check. This would be the same way that the LUKS block driver works - it has many crypto algorithms in use, chosen dynamically, so it has no choice but to test this at open() time.

This sounds good too.

Fam

Quoted 23 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
block/quorum.c +0 -0
index 331b726..18fbed8 100644
@@ -1113,10 +1113,6 @@ static BlockDriver bdrv_quorum = {
 
Quoted 8 lines
Quoted 8 lines

block/quorum.c static BlockDriver bdrv_quorum = { · line 1117

Quoted 8 lines
block/quorum.c +0 -4
 static void bdrv_quorum_init(void)
 {
-    if (!qcrypto_hash_supports(QCRYPTO_HASH_ALG_SHA256)) {
-        /* SHA256 hash support is required for quorum device */
-        return;
-    }
     bdrv_register(&bdrv_quorum);
 }

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#13 lore raw
In reply to Daniel P. Berrange
Quoted 7 lines · Daniel P. Berrange

The point of using qcrypto_hash_supports() is that it isolates the block code Makefile rules from the details of the current specific impl of the hash APIs in QEMU. As a prime example of why this is important, try rebasing to GIT master, and you'll find we no longer use gnutls for the hash APIs. We choose between libgcrypt, nettle or a empty stub for hash impls now. I think it is a backwards step to add back these makefile conditionals

Now that you mention this I wonder why we are not using glib for the hashing functions. GChecksum is available since glib 2.16 (QEMU requires 2.22) and it supports MD5, SHA1, SHA256 and SHA512. I see that in git master there's now a few algorithms more, but for the Quorum case those ones are enough.

Berto

#14 lore raw
Quoted 10 lines · Alberto Garcia
Quoted 7 lines · Daniel P. Berrange

The point of using qcrypto_hash_supports() is that it isolates the block code Makefile rules from the details of the current specific impl of the hash APIs in QEMU. As a prime example of why this is important, try rebasing to GIT master, and you'll find we no longer use gnutls for the hash APIs. We choose between libgcrypt, nettle or a empty stub for hash impls now. I think it is a backwards step to add back these makefile conditionals

Quoted 5 lines

Now that you mention this I wonder why we are not using glib for the hashing functions. GChecksum is available since glib 2.16 (QEMU requires 2.22) and it supports MD5, SHA1, SHA256 and SHA512. I see that in git master there's now a few algorithms more, but for the Quorum case those ones are enough.

The GChecksum API is inadequate for QEMU's needs, due to its limited range of algorithms. We absolutely do not want different areas of the code using different APIs either. The goal of the crypto APIs is to provide a standard internal API for all cryptographic related operations for use across the whole codebase. This has clarified much of our code by removing countless #ifdef conditionals from the code and similar from the build system. It also facilitates people auditing QEMU use & implementation of crypto as there is only one place to look at to review. It also ensures that QEMU is only using certified secure crypto libraries, not some custom re-implementation of the crypto algorithms that have never been through a security review. Finally is ensures that QEMU correctly responds to runtime configurable changes, such as FIPS mode which restricts use of certain crypto algorithms at runtime, even if they're technically available at compile time.

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#15 lore raw
Quoted 17 lines · Daniel P. Berrange
Quoted 10 lines · Alberto Garcia
Quoted 7 lines · Daniel P. Berrange

The point of using qcrypto_hash_supports() is that it isolates the block code Makefile rules from the details of the current specific impl of the hash APIs in QEMU. As a prime example of why this is important, try rebasing to GIT master, and you'll find we no longer use gnutls for the hash APIs. We choose between libgcrypt, nettle or a empty stub for hash impls now. I think it is a backwards step to add back these makefile conditionals

Quoted 5 lines

Now that you mention this I wonder why we are not using glib for the hashing functions. GChecksum is available since glib 2.16 (QEMU requires 2.22) and it supports MD5, SHA1, SHA256 and SHA512. I see that in git master there's now a few algorithms more, but for the Quorum case those ones are enough.

Quoted 14 lines

The GChecksum API is inadequate for QEMU's needs, due to its limited range of algorithms. We absolutely do not want different areas of the code using different APIs either. The goal of the crypto APIs is to provide a standard internal API for all cryptographic related operations for use across the whole codebase. This has clarified much of our code by removing countless #ifdef conditionals from the code and similar from the build system. It also facilitates people auditing QEMU use & implementation of crypto as there is only one place to look at to review. It also ensures that QEMU is only using certified secure crypto libraries, not some custom re-implementation of the crypto algorithms that have never been through a security review. Finally is ensures that QEMU correctly responds to runtime configurable changes, such as FIPS mode which restricts use of certain crypto algorithms at runtime, even if they're technically available at compile time.

Acutally, having said that, what we could do is to replace the no-op stub hash impl, with a GCheckusum based impl. That way if neither gcrypt or nettle are available, we can fallback to GChecksum for a sub-set of the hash algorithms.

That would allow us to move the gcrypto_hash_supports() check out of the quorum register method, and into its open() method, and avoid any Makefile.objs conditionals.

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|