aboutsummaryrefslogtreecommitdiff
path: root/util/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/log.c')
-rw-r--r--util/log.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/util/log.c b/util/log.c
index bab4d29..1a31216 100644
--- a/util/log.c
+++ b/util/log.c
@@ -34,6 +34,29 @@ int qemu_loglevel;
static int log_append = 0;
static GArray *debug_regions;
+/* Lock/unlock output. */
+
+FILE *qemu_log_lock(void)
+{
+ QemuLogFile *logfile;
+ rcu_read_lock();
+ logfile = qatomic_rcu_read(&qemu_logfile);
+ if (logfile) {
+ qemu_flockfile(logfile->fd);
+ return logfile->fd;
+ } else {
+ return NULL;
+ }
+}
+
+void qemu_log_unlock(FILE *fd)
+{
+ if (fd) {
+ qemu_funlockfile(fd);
+ }
+ rcu_read_unlock();
+}
+
/* Return the number of characters emitted. */
int qemu_log(const char *fmt, ...)
{