qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: initialize qcrypto API at startup
@ 2016-04-06 11:12 Daniel P. Berrange
  2016-04-06 11:41 ` Alex Bligh
  2016-04-07  9:43 ` Kevin Wolf
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel P. Berrange @ 2016-04-06 11:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Alex Bligh, qemu-block

Any programs which call the qcrypto APIs should ensure that
qcrypto_init() has been called before anything else which
can use crypto. Essentially this means right at the start
of the main method before initializing anything else.

This is important because some versions of gnutls/gcrypt
require explicit initialization before use.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 qemu-img.c | 6 ++++++
 qemu-io.c  | 6 ++++++
 qemu-nbd.c | 7 +++++++
 3 files changed, 19 insertions(+)

diff --git a/qemu-img.c b/qemu-img.c
index 17c5cfd..1697762 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -37,6 +37,7 @@
 #include "block/block_int.h"
 #include "block/blockjob.h"
 #include "block/qapi.h"
+#include "crypto/init.h"
 #include <getopt.h>
 
 #define QEMU_IMG_VERSION "qemu-img version " QEMU_VERSION QEMU_PKGVERSION \
@@ -3486,6 +3487,11 @@ int main(int argc, char **argv)
         exit(EXIT_FAILURE);
     }
 
+    if (qcrypto_init(&local_error) < 0) {
+        error_reportf_err(local_error, "cannot initialize crypto: ");
+        exit(1);
+    }
+
     module_call_init(MODULE_INIT_QOM);
     bdrv_init();
     if (argc < 2) {
diff --git a/qemu-io.c b/qemu-io.c
index 0a738f1..288bba8 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -23,6 +23,7 @@
 #include "sysemu/block-backend.h"
 #include "block/block_int.h"
 #include "trace/control.h"
+#include "crypto/init.h"
 
 #define CMD_NOFILE_OK   0x01
 
@@ -443,6 +444,11 @@ int main(int argc, char **argv)
     progname = basename(argv[0]);
     qemu_init_exec_dir(argv[0]);
 
+    if (qcrypto_init(&local_error) < 0) {
+        error_reportf_err(local_error, "cannot initialize crypto: ");
+        exit(1);
+    }
+
     module_call_init(MODULE_INIT_QOM);
     qemu_add_opts(&qemu_object_opts);
     bdrv_init();
diff --git a/qemu-nbd.c b/qemu-nbd.c
index ca4a724..fa91ca3 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -31,6 +31,7 @@
 #include "qapi/qmp/qstring.h"
 #include "qom/object_interfaces.h"
 #include "io/channel-socket.h"
+#include "crypto/init.h"
 
 #include <getopt.h>
 #include <libgen.h>
@@ -518,6 +519,12 @@ int main(int argc, char **argv)
     memset(&sa_sigterm, 0, sizeof(sa_sigterm));
     sa_sigterm.sa_handler = termsig_handler;
     sigaction(SIGTERM, &sa_sigterm, NULL);
+
+    if (qcrypto_init(&local_err) < 0) {
+        error_reportf_err(local_err, "cannot initialize crypto: ");
+        exit(1);
+    }
+
     module_call_init(MODULE_INIT_QOM);
     qemu_add_opts(&qemu_object_opts);
     qemu_init_exec_dir(argv[0]);
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] block: initialize qcrypto API at startup
  2016-04-06 11:12 [Qemu-devel] [PATCH] block: initialize qcrypto API at startup Daniel P. Berrange
@ 2016-04-06 11:41 ` Alex Bligh
  2016-04-07  9:43 ` Kevin Wolf
  1 sibling, 0 replies; 3+ messages in thread
From: Alex Bligh @ 2016-04-06 11:41 UTC (permalink / raw)
  To: Daniel P. Berrange
  Cc: Kevin Wolf, qemu-block, qemu-devel@nongnu.org, Alex Bligh


On 6 Apr 2016, at 12:12, Daniel P. Berrange <berrange@redhat.com> wrote:

> Any programs which call the qcrypto APIs should ensure that
> qcrypto_init() has been called before anything else which
> can use crypto. Essentially this means right at the start
> of the main method before initializing anything else.
> 
> This is important because some versions of gnutls/gcrypt
> require explicit initialization before use.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>

Reviewed-by: Alex Bligh <alex@alex.org.uk>
Tested-by: Alex Bligh <alex@alex.org.uk>

> ---
> qemu-img.c | 6 ++++++
> qemu-io.c  | 6 ++++++
> qemu-nbd.c | 7 +++++++
> 3 files changed, 19 insertions(+)
> 
> diff --git a/qemu-img.c b/qemu-img.c
> index 17c5cfd..1697762 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -37,6 +37,7 @@
> #include "block/block_int.h"
> #include "block/blockjob.h"
> #include "block/qapi.h"
> +#include "crypto/init.h"
> #include <getopt.h>
> 
> #define QEMU_IMG_VERSION "qemu-img version " QEMU_VERSION QEMU_PKGVERSION \
> @@ -3486,6 +3487,11 @@ int main(int argc, char **argv)
>         exit(EXIT_FAILURE);
>     }
> 
> +    if (qcrypto_init(&local_error) < 0) {
> +        error_reportf_err(local_error, "cannot initialize crypto: ");
> +        exit(1);
> +    }
> +
>     module_call_init(MODULE_INIT_QOM);
>     bdrv_init();
>     if (argc < 2) {
> diff --git a/qemu-io.c b/qemu-io.c
> index 0a738f1..288bba8 100644
> --- a/qemu-io.c
> +++ b/qemu-io.c
> @@ -23,6 +23,7 @@
> #include "sysemu/block-backend.h"
> #include "block/block_int.h"
> #include "trace/control.h"
> +#include "crypto/init.h"
> 
> #define CMD_NOFILE_OK   0x01
> 
> @@ -443,6 +444,11 @@ int main(int argc, char **argv)
>     progname = basename(argv[0]);
>     qemu_init_exec_dir(argv[0]);
> 
> +    if (qcrypto_init(&local_error) < 0) {
> +        error_reportf_err(local_error, "cannot initialize crypto: ");
> +        exit(1);
> +    }
> +
>     module_call_init(MODULE_INIT_QOM);
>     qemu_add_opts(&qemu_object_opts);
>     bdrv_init();
> diff --git a/qemu-nbd.c b/qemu-nbd.c
> index ca4a724..fa91ca3 100644
> --- a/qemu-nbd.c
> +++ b/qemu-nbd.c
> @@ -31,6 +31,7 @@
> #include "qapi/qmp/qstring.h"
> #include "qom/object_interfaces.h"
> #include "io/channel-socket.h"
> +#include "crypto/init.h"
> 
> #include <getopt.h>
> #include <libgen.h>
> @@ -518,6 +519,12 @@ int main(int argc, char **argv)
>     memset(&sa_sigterm, 0, sizeof(sa_sigterm));
>     sa_sigterm.sa_handler = termsig_handler;
>     sigaction(SIGTERM, &sa_sigterm, NULL);
> +
> +    if (qcrypto_init(&local_err) < 0) {
> +        error_reportf_err(local_err, "cannot initialize crypto: ");
> +        exit(1);
> +    }
> +
>     module_call_init(MODULE_INIT_QOM);
>     qemu_add_opts(&qemu_object_opts);
>     qemu_init_exec_dir(argv[0]);
> -- 
> 2.5.5
> 
> 

-- 
Alex Bligh

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] block: initialize qcrypto API at startup
  2016-04-06 11:12 [Qemu-devel] [PATCH] block: initialize qcrypto API at startup Daniel P. Berrange
  2016-04-06 11:41 ` Alex Bligh
@ 2016-04-07  9:43 ` Kevin Wolf
  1 sibling, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2016-04-07  9:43 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: Alex Bligh, qemu-devel, qemu-block

Am 06.04.2016 um 13:12 hat Daniel P. Berrange geschrieben:
> Any programs which call the qcrypto APIs should ensure that
> qcrypto_init() has been called before anything else which
> can use crypto. Essentially this means right at the start
> of the main method before initializing anything else.
> 
> This is important because some versions of gnutls/gcrypt
> require explicit initialization before use.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>

Thanks, applied to the block branch.

Kevin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-07  9:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-06 11:12 [Qemu-devel] [PATCH] block: initialize qcrypto API at startup Daniel P. Berrange
2016-04-06 11:41 ` Alex Bligh
2016-04-07  9:43 ` Kevin Wolf

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).