mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-09-02 06:51:53 -06:00
bsd-user: Implement --seed and initialize random state
Copy --seed implementation (translated from linux-user's newer command line scheme to the older one bsd-user still uses). Initialize the randomness with the glib if a specific seed is specified or use the qcrypto library if not. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
790baacc63
commit
03ecf078fa
1 changed files with 18 additions and 0 deletions
|
@ -45,6 +45,8 @@
|
||||||
#include "qemu/cutils.h"
|
#include "qemu/cutils.h"
|
||||||
#include "exec/log.h"
|
#include "exec/log.h"
|
||||||
#include "trace/control.h"
|
#include "trace/control.h"
|
||||||
|
#include "crypto/init.h"
|
||||||
|
#include "qemu/guest-random.h"
|
||||||
|
|
||||||
#include "host-os.h"
|
#include "host-os.h"
|
||||||
#include "target_arch_cpu.h"
|
#include "target_arch_cpu.h"
|
||||||
|
@ -203,6 +205,7 @@ int main(int argc, char **argv)
|
||||||
const char *cpu_type;
|
const char *cpu_type;
|
||||||
const char *log_file = NULL;
|
const char *log_file = NULL;
|
||||||
const char *log_mask = NULL;
|
const char *log_mask = NULL;
|
||||||
|
const char *seed_optarg = NULL;
|
||||||
struct target_pt_regs regs1, *regs = ®s1;
|
struct target_pt_regs regs1, *regs = ®s1;
|
||||||
struct image_info info1, *info = &info1;
|
struct image_info info1, *info = &info1;
|
||||||
struct bsd_binprm bprm;
|
struct bsd_binprm bprm;
|
||||||
|
@ -331,6 +334,8 @@ int main(int argc, char **argv)
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
optind++;
|
optind++;
|
||||||
|
} else if (!strcmp(r, "seed")) {
|
||||||
|
seed_optarg = optarg;
|
||||||
} else if (!strcmp(r, "singlestep")) {
|
} else if (!strcmp(r, "singlestep")) {
|
||||||
singlestep = 1;
|
singlestep = 1;
|
||||||
} else if (!strcmp(r, "strace")) {
|
} else if (!strcmp(r, "strace")) {
|
||||||
|
@ -403,6 +408,19 @@ int main(int argc, char **argv)
|
||||||
target_environ = envlist_to_environ(envlist, NULL);
|
target_environ = envlist_to_environ(envlist, NULL);
|
||||||
envlist_free(envlist);
|
envlist_free(envlist);
|
||||||
|
|
||||||
|
{
|
||||||
|
Error *err = NULL;
|
||||||
|
if (seed_optarg != NULL) {
|
||||||
|
qemu_guest_random_seed_main(seed_optarg, &err);
|
||||||
|
} else {
|
||||||
|
qcrypto_init(&err);
|
||||||
|
}
|
||||||
|
if (err) {
|
||||||
|
error_reportf_err(err, "cannot initialize crypto: ");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now that page sizes are configured we can do
|
* Now that page sizes are configured we can do
|
||||||
* proper page alignment for guest_base.
|
* proper page alignment for guest_base.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue