summaryrefslogtreecommitdiffstats
path: root/qemu-nbd.c
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2016-04-06 12:12:06 +0100
committerTimothy Pearson <tpearson@raptorengineering.com>2019-11-29 20:03:49 -0600
commit76a5e12d18d2a6588410f022eeac3ba4d36bdbb5 (patch)
treef06127fc3b207b9202574e53e7e53c877875604f /qemu-nbd.c
parent89cd63836594d9c859e0ab88a3d44436128abec5 (diff)
downloadhqemu-76a5e12d18d2a6588410f022eeac3ba4d36bdbb5.zip
hqemu-76a5e12d18d2a6588410f022eeac3ba4d36bdbb5.tar.gz
block: initialize qcrypto API at startup
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> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'qemu-nbd.c')
-rw-r--r--qemu-nbd.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/qemu-nbd.c b/qemu-nbd.c
index c2e4d3f..b5751f8 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>
@@ -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]);
OpenPOWER on IntegriCloud