summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorRichard Henderson2022-04-17 20:30:04 +0200
committerRichard Henderson2022-04-20 19:51:11 +0200
commitbf619eae2eed3bde9f7c003c09bf29bdcc908b08 (patch)
treebcabd53d6842a6a600049dcb1caa927438acdea5 /include
parenttests/unit: Do not reference QemuLogFile directly (diff)
downloadqemu-bf619eae2eed3bde9f7c003c09bf29bdcc908b08.tar.gz
qemu-bf619eae2eed3bde9f7c003c09bf29bdcc908b08.tar.xz
qemu-bf619eae2eed3bde9f7c003c09bf29bdcc908b08.zip
include/exec/log: Do not reference QemuLogFile directly
Use qemu_log_trylock/unlock instead of the raw rcu_read. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20220417183019.755276-25-richard.henderson@linaro.org>
Diffstat (limited to 'include')
-rw-r--r--include/exec/log.h13
1 files changed, 4 insertions, 9 deletions
diff --git a/include/exec/log.h b/include/exec/log.h
index ad0a40cfeb..4a7375a45f 100644
--- a/include/exec/log.h
+++ b/include/exec/log.h
@@ -15,15 +15,10 @@
*/
static inline void log_cpu_state(CPUState *cpu, int flags)
{
- QemuLogFile *logfile;
-
- if (qemu_log_enabled()) {
- rcu_read_lock();
- logfile = qatomic_rcu_read(&qemu_logfile);
- if (logfile) {
- cpu_dump_state(cpu, logfile->fd, flags);
- }
- rcu_read_unlock();
+ FILE *f = qemu_log_trylock();
+ if (f) {
+ cpu_dump_state(cpu, f, flags);
+ qemu_log_unlock(f);
}
}