]> Git Repo - qemu.git/commitdiff
block: initialize qcrypto API at startup
authorDaniel P. Berrange <[email protected]>
Wed, 6 Apr 2016 11:12:06 +0000 (12:12 +0100)
committerKevin Wolf <[email protected]>
Tue, 12 Apr 2016 16:06:51 +0000 (18:06 +0200)
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 <[email protected]>
Reviewed-by: Alex Bligh <[email protected]>
Tested-by: Alex Bligh <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
qemu-img.c
qemu-io.c
qemu-nbd.c

index 17c5cfdffe4fa3fa802ae4ffa78a766d4f9db4be..169776260650ec287770faab0681af4884e6054d 100644 (file)
@@ -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) {
index 0a738f12f04eac56f7408aef755765efb7ca64b9..288bba84b9c229c4158777bc28c287881dd0bf0a 100644 (file)
--- 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();
index c2e4d3f64c2141ac1236fc11f240d56cc659e998..b5751f853b203c6170daa2cfd68c96b808e8f73c 100644 (file)
@@ -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>
@@ -519,6 +520,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]);
This page took 0.03524 seconds and 4 git commands to generate.