[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 42/49] monitor: do not use QTAILQ_FOREACH_SAFE across
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 42/49] monitor: do not use QTAILQ_FOREACH_SAFE across critical sections |
Date: |
Mon, 21 Jan 2019 19:06:13 +0100 |
monitor_qmp_requests_pop_any_with_lock cannot modify the monitor list
concurrently with monitor_cleanup, since the dispatch bottom half
runs in the main thread, but anyway it is a bit ugly to keep
"next" live across critical sections of monitor_lock and Coverity
complains (CID 1397072).
Replace QTAILQ_FOREACH_SAFE with a while loop and QTAILQ_FIRST,
it is cleaner and more future-proof.
Signed-off-by: Paolo Bonzini <address@hidden>
---
monitor.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/monitor.c b/monitor.c
index eb39fb0..2bacaad 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4619,8 +4619,6 @@ void monitor_init(Chardev *chr, int flags)
void monitor_cleanup(void)
{
- Monitor *mon, *next;
-
/*
* We need to explicitly stop the I/O thread (but not destroy it),
* clean up the monitor resources, then destroy the I/O thread since
@@ -4634,7 +4632,8 @@ void monitor_cleanup(void)
/* Flush output buffers and destroy monitors */
qemu_mutex_lock(&monitor_lock);
monitor_destroyed = true;
- QTAILQ_FOREACH_SAFE(mon, &mon_list, entry, next) {
+ while (!QTAILQ_EMPTY(&mon_list)) {
+ Monitor *mon = QTAILQ_FIRST(&mon_list);
QTAILQ_REMOVE(&mon_list, mon, entry);
/* Permit QAPI event emission from character frontend release */
qemu_mutex_unlock(&monitor_lock);
--
1.8.3.1
- [Qemu-devel] [PULL 26/49] pvh: Boot uncompressed kernel using direct boot ABI, (continued)
- [Qemu-devel] [PULL 26/49] pvh: Boot uncompressed kernel using direct boot ABI, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 27/49] pvh: load initrd and expose it through fw_cfg, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 38/49] contrib/elf2dmp: use GLib in PDB processing, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 41/49] configure: enable elf2dmp build for Windows hosts, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 34/49] Revert "i386: Add CPUID bit for PCONFIG", Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 35/49] target-i386: hvf: remove MPX support, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 37/49] contrib/elf2dmp: use GLib in ELF processing, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 02/49] include: update Linux headers to 4.21-rc1/5.0-rc1, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 29/49] linuxboot_dma: move common functions in a new header, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 33/49] i386: remove the 'INTEL_PT' CPUID bit from named CPU models, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 42/49] monitor: do not use QTAILQ_FOREACH_SAFE across critical sections,
Paolo Bonzini <=
- [Qemu-devel] [PULL 43/49] crypto: finish removing TABs, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 44/49] ui: vnc: finish removing TABs, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 47/49] i386: import & use bootparam.h, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 48/49] i386: allow to load initrd below 4 GB for recent linux, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 46/49] hw/core/loader.c: Read as long as possible in load_image_size(), Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 45/49] unify len and addr type for memory/address APIs, Paolo Bonzini, 2019/01/21
- [Qemu-devel] [PULL 49/49] docker: disable Xen on CentOS 7, Paolo Bonzini, 2019/01/21
- Re: [Qemu-devel] [PULL 00/49] Misc patches for 2019-01-21, Peter Maydell, 2019/01/22