@@ -39,6 +39,7 @@
#include "trace/control.h"
#include "target_elf.h"
#include "cpu_loop-common.h"
+#include "crypto/random.h"
char *exec_path;
@@ -688,17 +689,26 @@ int main(int argc, char **argv, char **envp)
if (seed_optarg == NULL) {
seed_optarg = getenv("QEMU_RAND_SEED");
}
- if (seed_optarg != NULL) {
- unsigned long long seed;
+ {
+ Error *err = NULL;
+ if (seed_optarg != NULL) {
+ unsigned long long seed;
- /* This will go away with the last user of rand(). */
- if (parse_uint_full(seed_optarg, &seed, 0) != 0) {
- fprintf(stderr, "Invalid seed number: %s\n", seed_optarg);
- exit(EXIT_FAILURE);
+ /* This will go away with the last user of rand(). */
+ if (parse_uint_full(seed_optarg, &seed, 0) != 0) {
+ fprintf(stderr, "Invalid seed number: %s\n", seed_optarg);
+ exit(EXIT_FAILURE);
+ }
+ srand(seed);
+
+ qemu_guest_random_seed_main(seed_optarg, &err);
+ } else {
+ qcrypto_random_init(&err);
+ }
+ if (err) {
+ error_reportf_err(err, "cannot initialize crypto: ");
+ exit(1);
}
- srand(seed);
-
- qemu_guest_random_seed_main(seed_optarg, &error_fatal);
}
target_environ = envlist_to_environ(envlist, NULL);