aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/guest-random.c13
-rw-r--r--util/module.c1
2 files changed, 12 insertions, 2 deletions
diff --git a/util/guest-random.c b/util/guest-random.c
index 9453968bd7..086115bd67 100644
--- a/util/guest-random.c
+++ b/util/guest-random.c
@@ -14,6 +14,7 @@
#include "qapi/error.h"
#include "qemu/guest-random.h"
#include "crypto/random.h"
+#include "sysemu/replay.h"
static __thread GRand *thread_rand;
@@ -44,13 +45,21 @@ static int glib_random_bytes(void *buf, size_t len)
int qemu_guest_getrandom(void *buf, size_t len, Error **errp)
{
+ int ret;
+ if (replay_mode == REPLAY_MODE_PLAY) {
+ return replay_read_random(buf, len);
+ }
if (unlikely(deterministic)) {
/* Deterministic implementation using Glib's Mersenne Twister. */
- return glib_random_bytes(buf, len);
+ ret = glib_random_bytes(buf, len);
} else {
/* Non-deterministic implementation using crypto routines. */
- return qcrypto_random_bytes(buf, len, errp);
+ ret = qcrypto_random_bytes(buf, len, errp);
+ }
+ if (replay_mode == REPLAY_MODE_RECORD) {
+ replay_save_random(ret, buf, len);
}
+ return ret;
}
void qemu_guest_getrandom_nofail(void *buf, size_t len)
diff --git a/util/module.c b/util/module.c
index e9fe3e5422..8c5315a7a3 100644
--- a/util/module.c
+++ b/util/module.c
@@ -214,6 +214,7 @@ bool module_load_one(const char *prefix, const char *lib_name)
if (!success) {
g_hash_table_remove(loaded_modules, module_name);
+ g_free(module_name);
}
for (i = 0; i < n_dirs; i++) {