aboutsummaryrefslogtreecommitdiff
path: root/replay
diff options
context:
space:
mode:
Diffstat (limited to 'replay')
-rw-r--r--replay/replay-internal.c27
-rw-r--r--replay/replay-internal.h7
2 files changed, 34 insertions, 0 deletions
diff --git a/replay/replay-internal.c b/replay/replay-internal.c
index 04efeee920..efae672dfa 100644
--- a/replay/replay-internal.c
+++ b/replay/replay-internal.c
@@ -17,6 +17,13 @@
unsigned int replay_data_kind = -1;
static unsigned int replay_has_unread_data;
+/* Mutex to protect reading and writing events to the log.
+ replay_data_kind and replay_has_unread_data are also protected
+ by this mutex.
+ It also protects replay events queue which stores events to be
+ written or read to the log. */
+static QemuMutex lock;
+
/* File for replay writing */
FILE *replay_file;
@@ -153,3 +160,23 @@ void replay_finish_event(void)
replay_has_unread_data = 0;
replay_fetch_data_kind();
}
+
+void replay_mutex_init(void)
+{
+ qemu_mutex_init(&lock);
+}
+
+void replay_mutex_destroy(void)
+{
+ qemu_mutex_destroy(&lock);
+}
+
+void replay_mutex_lock(void)
+{
+ qemu_mutex_lock(&lock);
+}
+
+void replay_mutex_unlock(void)
+{
+ qemu_mutex_unlock(&lock);
+}
diff --git a/replay/replay-internal.h b/replay/replay-internal.h
index 17600deff9..8a0de0d8d8 100644
--- a/replay/replay-internal.h
+++ b/replay/replay-internal.h
@@ -33,6 +33,13 @@ int64_t replay_get_qword(void);
void replay_get_array(uint8_t *buf, size_t *size);
void replay_get_array_alloc(uint8_t **buf, size_t *size);
+/* Mutex functions for protecting replay log file */
+
+void replay_mutex_init(void);
+void replay_mutex_destroy(void);
+void replay_mutex_lock(void);
+void replay_mutex_unlock(void);
+
/*! Checks error status of the file. */
void replay_check_error(void);