qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v4 12/24] linux-user: Initialize pseudo-random s


From: Laurent Vivier
Subject: Re: [Qemu-devel] [PATCH v4 12/24] linux-user: Initialize pseudo-random seeds for all guest cpus
Date: Tue, 7 May 2019 16:06:54 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

On 06/05/2019 19:33, Richard Henderson wrote:
When the -seed option is given, call qemu_guest_random_seed_main,
putting the subsystem into deterministic mode.  Pass derived seeds
to each cpu created during clone; which is a no-op unless the
subsystem is in deterministic mode.

Cc: Laurent Vivier <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Signed-off-by: Richard Henderson <address@hidden>
---
  linux-user/main.c    | 21 ++++++++++-----------
  linux-user/syscall.c |  3 +++
  2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/linux-user/main.c b/linux-user/main.c
index 3d2230320b..7dfb202e5d 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -34,6 +34,7 @@
  #include "tcg.h"
  #include "qemu/timer.h"
  #include "qemu/envlist.h"
+#include "qemu/guest-random.h"
  #include "elf.h"
  #include "trace/control.h"
  #include "target_elf.h"
@@ -48,6 +49,7 @@ static int gdbstub_port;
  static envlist_t *envlist;
  static const char *cpu_model;
  static const char *cpu_type;
+static const char *seed_optarg;
  unsigned long mmap_min_addr;
  unsigned long guest_base;
  int have_guest_base;
@@ -290,15 +292,9 @@ static void handle_arg_pagesize(const char *arg)
      }
  }
-static void handle_arg_randseed(const char *arg)
+static void handle_arg_seed(const char *arg)
  {
-    unsigned long long seed;
-
-    if (parse_uint_full(arg, &seed, 0) != 0 || seed > UINT_MAX) {
-        fprintf(stderr, "Invalid seed number: %s\n", arg);
-        exit(EXIT_FAILURE);
-    }
-    srand(seed);

It's a detail, but I think you can't remove this srand() in this patch: you initialize qemu_guest_random() sequence but the code continues to use rand() to have a random number, so the seed value is in fact ignored. you can remove it in PATCH 16.

Thanks,
Laurent



reply via email to

[Prev in Thread] Current Thread [Next in Thread]