linux-user: Call qcrypto_init if not using -seed

When not using -seed, we will use the crypto subsystem
for random numbers.

Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2019-03-13 13:53:22 -07:00
parent 5ebdd77494
commit a573e9bac6
1 changed files with 19 additions and 9 deletions

View File

@ -39,6 +39,7 @@
#include "trace/control.h"
#include "target_elf.h"
#include "cpu_loop-common.h"
#include "crypto/init.h"
char *exec_path;
@ -688,6 +689,8 @@ int main(int argc, char **argv, char **envp)
if (seed_optarg == NULL) {
seed_optarg = getenv("QEMU_RAND_SEED");
}
{
Error *err = NULL;
if (seed_optarg != NULL) {
unsigned long long seed;
@ -698,7 +701,14 @@ int main(int argc, char **argv, char **envp)
}
srand(seed);
qemu_guest_random_seed_main(seed_optarg, &error_fatal);
qemu_guest_random_seed_main(seed_optarg, &err);
} else {
qcrypto_init(&err);
}
if (err) {
error_reportf_err(err, "cannot initialize crypto: ");
exit(1);
}
}
target_environ = envlist_to_environ(envlist, NULL);