diff options
author | Richard Henderson <richard.henderson@linaro.org> | 2022-04-17 11:29:56 -0700 |
---|---|---|
committer | Richard Henderson <richard.henderson@linaro.org> | 2022-04-20 10:51:11 -0700 |
commit | 095e9855b774b9da9b84c9cf21cbd856ae482670 (patch) | |
tree | 78d370d5696532223fef2e7f31eae699326ee4d0 /util | |
parent | 9aee8f2c299c50bcad3af31c6e2bfdbe27338247 (diff) | |
download | qemu-095e9855b774b9da9b84c9cf21cbd856ae482670.zip qemu-095e9855b774b9da9b84c9cf21cbd856ae482670.tar.gz qemu-095e9855b774b9da9b84c9cf21cbd856ae482670.tar.bz2 |
util/log: Use qemu_log_trylock/unlock in qemu_log
Avoid using QemuLogFile and RCU directly.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20220417183019.755276-17-richard.henderson@linaro.org>
Diffstat (limited to 'util')
-rw-r--r-- | util/log.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -62,23 +62,22 @@ void qemu_log_unlock(FILE *fd) /* Return the number of characters emitted. */ int qemu_log(const char *fmt, ...) { + FILE *f = qemu_log_trylock(); int ret = 0; - QemuLogFile *logfile; - rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); - if (logfile) { + if (f) { va_list ap; + va_start(ap, fmt); - ret = vfprintf(logfile->fd, fmt, ap); + ret = vfprintf(f, fmt, ap); va_end(ap); + qemu_log_unlock(f); /* Don't pass back error results. */ if (ret < 0) { ret = 0; } } - rcu_read_unlock(); return ret; } |