* [PULL v3 00/62] Misc patches for soft freeze
@ 2020-03-17 15:19 Paolo Bonzini
2020-03-17 15:19 ` [PULL v3 35/62] lockable: add QEMU_MAKE_LOCKABLE_NONNULL Paolo Bonzini
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Paolo Bonzini @ 2020-03-17 15:19 UTC (permalink / raw)
To: qemu-devel
The following changes since commit a98135f727595382e200d04c2996e868b7925a01:
Merge remote-tracking branch 'remotes/kraxel/tags/vga-20200316-pull-request' into staging (2020-03-16 14:55:59 +0000)
are available in the git repository at:
git://github.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to 32b9523ad5b44dea87792d5d8f71a87e8cc5803b:
hw/arm: Let devices own the MemoryRegion they create (2020-03-17 15:18:50 +0100)
----------------------------------------------------------------
* Bugfixes all over the place
* get/set_uint cleanups (Felipe)
* Lock guard support (Stefan)
* MemoryRegion ownership cleanup (Philippe)
* AVX512 optimization for buffer_is_zero (Robert)
----------------------------------------------------------------
Christian Ehrhardt (1):
modules: load modules from versioned /var/run dir
Christophe de Dinechin (1):
scsi/qemu-pr-helper: Fix out-of-bounds access to trnptid_list[]
Colin Xu (1):
MAINTAINERS: Add entry for Guest X86 HAXM CPUs
Dr. David Alan Gilbert (1):
exec/rom_reset: Free rom data during inmigrate skip
Eduardo Habkost (1):
Use -isystem for linux-headers dir
Felipe Franciosi (4):
qom/object: enable setter for uint types
ich9: fix getter type for sci_int property
ich9: Simplify ich9_lpc_initfn
qom/object: Use common get/set uint helpers
Jan Kiszka (1):
hw/i386/intel_iommu: Fix out-of-bounds access on guest IRT
Joe Richey (1):
optionrom/pvh: scan entire RSDP Area
Julio Faracco (1):
i386: Fix GCC warning with snprintf when HAX is enabled
Kashyap Chamarthy (1):
qemu-cpu-models.rst: Document -noTSX, mds-no, taa-no, and tsx-ctrl
Longpeng (Mike) (1):
cpus: avoid pause_all_vcpus getting stuck due to race
Marc-André Lureau (1):
build-sys: do not make qemu-ga link with pixman
Matt Borgerson (1):
memory: Fix start offset for bitmap log_clear hook
Paolo Bonzini (2):
oslib-posix: initialize mutex and condition variable
lockable: add QEMU_MAKE_LOCKABLE_NONNULL
Peter Maydell (1):
softmmu/vl.c: Handle '-cpu help' and '-device help' before 'no default machine'
Philippe Mathieu-Daudé (36):
misc: Replace zero-length arrays with flexible array member (automatic)
misc: Replace zero-length arrays with flexible array member (manual)
configure: Fix building with SASL on Windows
tests/docker: Install SASL library to extend code coverage on amd64
Makefile: Align 'help' target output
Makefile: Let the 'help' target list the tools targets
hw/audio/fmopl: Move ENV_CURVE to .heap to save 32KiB of .bss
hw/audio/intel-hda: Use memory region alias to reduce .rodata by 4.34MB
hw/usb/quirks: Use smaller types to reduce .rodata by 10KiB
ui/curses: Make control_characters[] array const
ui/curses: Move arrays to .heap to save 74KiB of .bss
memory: Correctly return alias region type
memory: Simplify memory_region_init_rom_nomigrate() to ease review
scripts/cocci: Rename memory-region-{init-ram -> housekeeping}
scripts/cocci: Patch to replace memory_region_init_{ram,readonly -> rom}
hw/arm: Use memory_region_init_rom() with read-only regions
hw/display: Use memory_region_init_rom() with read-only regions
hw/m68k: Use memory_region_init_rom() with read-only regions
hw/net: Use memory_region_init_rom() with read-only regions
hw/pci-host: Use memory_region_init_rom() with read-only regions
hw/ppc: Use memory_region_init_rom() with read-only regions
hw/riscv: Use memory_region_init_rom() with read-only regions
hw/sh4: Use memory_region_init_rom() with read-only regions
hw/sparc: Use memory_region_init_rom() with read-only regions
scripts/cocci: Patch to detect potential use of memory_region_init_rom
scripts/cocci: Patch to remove unnecessary memory_region_set_readonly()
scripts/cocci: Patch to let devices own their MemoryRegions
hw/core: Let devices own the MemoryRegion they create
hw/display: Let devices own the MemoryRegion they create
hw/dma: Let devices own the MemoryRegion they create
hw/riscv: Let devices own the MemoryRegion they create
hw/char: Let devices own the MemoryRegion they create
hw/arm/stm32: Use memory_region_init_rom() with read-only regions
hw/ppc/ppc405: Use memory_region_init_rom() with read-only regions
hw/arm: Remove unnecessary memory_region_set_readonly() on ROM alias
hw/arm: Let devices own the MemoryRegion they create
Robert Hoo (2):
configure: add configure option avx512f_opt
util: add util function buffer_zero_avx512()
Stefan Hajnoczi (2):
lockable: add lock guards
lockable: add QemuRecMutex support
Sunil Muthuswamy (3):
WHPX: TSC get and set should be dependent on VM state
WHPX: Use QEMU values for trapped CPUID
WHPX: Use proper synchronization primitives while processing
MAINTAINERS | 12 ++
Makefile | 49 +++--
Makefile.target | 2 +-
block/linux-aio.c | 2 +-
block/vmdk.c | 2 +-
bsd-user/qemu.h | 2 +-
configure | 62 +++++-
contrib/libvhost-user/libvhost-user.h | 2 +-
contrib/vhost-user-gpu/Makefile.objs | 6 +-
.../vhost-user-gpu/{main.c => vhost-user-gpu.c} | 0
cpus.c | 6 +-
docs/interop/vhost-user.rst | 4 +-
docs/system/cpu-models-x86.rst.inc | 57 +++++-
exec.c | 9 +-
hw/acpi/ich9.c | 99 +---------
hw/acpi/nvdimm.c | 6 +-
hw/acpi/pcihp.c | 7 +-
hw/acpi/piix4.c | 12 +-
hw/arm/exynos4210.c | 14 +-
hw/arm/fsl-imx25.c | 10 +-
hw/arm/fsl-imx31.c | 6 +-
hw/arm/fsl-imx6.c | 6 +-
hw/arm/fsl-imx6ul.c | 9 +-
hw/arm/mainstone.c | 3 +-
hw/arm/msf2-soc.c | 6 +-
hw/arm/nrf51_soc.c | 2 +-
hw/arm/omap_sx1.c | 6 +-
hw/arm/palm.c | 3 +-
hw/arm/spitz.c | 3 +-
hw/arm/stellaris.c | 3 +-
hw/arm/stm32f205_soc.c | 11 +-
hw/arm/stm32f405_soc.c | 12 +-
hw/arm/tosa.c | 3 +-
hw/arm/xlnx-zynqmp.c | 11 +-
hw/audio/fmopl.c | 4 +-
hw/audio/intel-hda.c | 24 +--
hw/char/sclpconsole-lm.c | 2 +-
hw/char/sclpconsole.c | 2 +-
hw/char/serial.c | 7 +-
hw/core/loader.c | 25 ++-
hw/core/platform-bus.c | 3 +-
hw/display/cg3.c | 5 +-
hw/display/g364fb.c | 3 +-
hw/display/macfb.c | 4 +-
hw/display/tcx.c | 5 +-
hw/dma/i8257.c | 2 +-
hw/dma/rc4030.c | 4 +-
hw/dma/soc_dma.c | 2 +-
hw/i386/intel_iommu.c | 6 +
hw/i386/x86.c | 2 +-
hw/isa/lpc_ich9.c | 27 +--
hw/m68k/bootinfo.h | 2 +-
hw/m68k/q800.c | 3 +-
hw/misc/edu.c | 13 +-
hw/misc/omap_l4.c | 2 +-
hw/net/dp8393x.c | 5 +-
hw/nvram/eeprom93xx.c | 2 +-
hw/pci-host/prep.c | 5 +-
hw/pci-host/q35.c | 14 +-
hw/ppc/mac_newworld.c | 3 +-
hw/ppc/mac_oldworld.c | 3 +-
hw/ppc/ppc405_boards.c | 6 +-
hw/ppc/spapr.c | 36 +---
hw/ppc/spapr_drc.c | 3 +-
hw/rdma/vmw/pvrdma_qp_ops.c | 4 +-
hw/riscv/sifive_e.c | 9 +-
hw/riscv/sifive_u.c | 2 +-
hw/s390x/virtio-ccw.c | 2 +-
hw/sh4/shix.c | 3 +-
hw/sparc/leon3.c | 3 +-
hw/usb/dev-network.c | 2 +-
hw/usb/dev-smartcard-reader.c | 4 +-
hw/usb/quirks.c | 4 +-
hw/usb/quirks.h | 22 ++-
hw/virtio/virtio.c | 4 +-
hw/xen/xen_pt.h | 2 +-
include/hw/acpi/acpi-defs.h | 16 +-
include/hw/arm/smmu-common.h | 2 +-
include/hw/boards.h | 2 +-
include/hw/i386/intel_iommu.h | 3 +-
include/hw/s390x/event-facility.h | 2 +-
include/hw/s390x/sclp.h | 8 +-
include/hw/virtio/virtio-iommu.h | 2 +-
include/qemu/cpuid.h | 3 +
include/qemu/lockable.h | 86 ++++++++-
include/qom/object.h | 48 ++++-
include/sysemu/cryptodev.h | 2 +-
include/sysemu/whpx.h | 7 +
include/tcg/tcg.h | 2 +-
memory.c | 31 +--
net/queue.c | 2 +-
pc-bios/optionrom/pvh_main.c | 2 +-
pc-bios/s390-ccw/bootmap.h | 2 +-
pc-bios/s390-ccw/sclp.h | 2 +-
plugins/core.c | 7 +-
plugins/loader.c | 16 +-
qom/object.c | 212 ++++++++++++++++++---
.../coccinelle/memory-region-housekeeping.cocci | 159 ++++++++++++++++
scripts/coccinelle/memory-region-init-ram.cocci | 38 ----
scsi/qemu-pr-helper.c | 17 +-
softmmu/vl.c | 26 ++-
target/arm/cpu.c | 22 +--
target/i386/hax-posix.c | 33 +---
target/i386/hax-windows.c | 33 +---
target/i386/sev.c | 106 +----------
target/i386/whp-dispatch.h | 9 +
target/i386/whpx-all.c | 162 +++++++++++-----
target/s390x/ioinst.c | 2 +-
tests/docker/dockerfiles/debian-amd64.docker | 1 +
tests/qtest/libqos/ahci.h | 2 +-
ui/console.c | 4 +-
ui/curses.c | 10 +-
util/bufferiszero.c | 71 ++++++-
util/module.c | 14 ++
util/oslib-posix.c | 7 +
util/qemu-timer.c | 23 ++-
116 files changed, 1161 insertions(+), 767 deletions(-)
rename contrib/vhost-user-gpu/{main.c => vhost-user-gpu.c} (100%)
create mode 100644 scripts/coccinelle/memory-region-housekeeping.cocci
delete mode 100644 scripts/coccinelle/memory-region-init-ram.cocci
--
1.8.3.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PULL v3 35/62] lockable: add QEMU_MAKE_LOCKABLE_NONNULL
2020-03-17 15:19 [PULL v3 00/62] Misc patches for soft freeze Paolo Bonzini
@ 2020-03-17 15:19 ` Paolo Bonzini
2020-03-17 15:19 ` [PULL v3 36/62] lockable: add lock guards Paolo Bonzini
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2020-03-17 15:19 UTC (permalink / raw)
To: qemu-devel
This will be needed for lock guards, because if the lock is NULL the
dummy for loop of the lock guard never runs. This can cause confusion
and dummy warnings in the compiler, but even if it did not, aborting
with a NULL pointer dereference is a less surprising behavior.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
include/qemu/lockable.h | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/include/qemu/lockable.h b/include/qemu/lockable.h
index 84ea794..313d4d9 100644
--- a/include/qemu/lockable.h
+++ b/include/qemu/lockable.h
@@ -65,7 +65,7 @@ qemu_make_lockable(void *x, QemuLockable *lockable)
* In C++ it would be different, but then C++ wouldn't need QemuLockable
* either...
*/
-#define QEMU_MAKE_LOCKABLE_(x) qemu_make_lockable((x), &(QemuLockable) { \
+#define QEMU_MAKE_LOCKABLE_(x) (&(QemuLockable) { \
.object = (x), \
.lock = QEMU_LOCK_FUNC(x), \
.unlock = QEMU_UNLOCK_FUNC(x), \
@@ -76,11 +76,24 @@ qemu_make_lockable(void *x, QemuLockable *lockable)
* @x: a lock object (currently one of QemuMutex, CoMutex, QemuSpin).
*
* Returns a QemuLockable object that can be passed around
- * to a function that can operate with locks of any kind.
+ * to a function that can operate with locks of any kind, or
+ * NULL if @x is %NULL.
*/
#define QEMU_MAKE_LOCKABLE(x) \
QEMU_GENERIC(x, \
(QemuLockable *, (x)), \
+ qemu_make_lockable((x), QEMU_MAKE_LOCKABLE_(x)))
+
+/* QEMU_MAKE_LOCKABLE_NONNULL - Make a polymorphic QemuLockable
+ *
+ * @x: a lock object (currently one of QemuMutex, CoMutex, QemuSpin).
+ *
+ * Returns a QemuLockable object that can be passed around
+ * to a function that can operate with locks of any kind.
+ */
+#define QEMU_MAKE_LOCKABLE_NONNULL(x) \
+ QEMU_GENERIC(x, \
+ (QemuLockable *, (x)), \
QEMU_MAKE_LOCKABLE_(x))
static inline void qemu_lockable_lock(QemuLockable *x)
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PULL v3 36/62] lockable: add lock guards
2020-03-17 15:19 [PULL v3 00/62] Misc patches for soft freeze Paolo Bonzini
2020-03-17 15:19 ` [PULL v3 35/62] lockable: add QEMU_MAKE_LOCKABLE_NONNULL Paolo Bonzini
@ 2020-03-17 15:19 ` Paolo Bonzini
2020-03-17 15:19 ` [PULL v3 37/62] lockable: add QemuRecMutex support Paolo Bonzini
2020-03-17 21:04 ` [PULL v3 00/62] Misc patches for soft freeze Peter Maydell
3 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2020-03-17 15:19 UTC (permalink / raw)
To: qemu-devel; +Cc: Stefan Hajnoczi
From: Stefan Hajnoczi <stefanha@redhat.com>
This patch introduces two lock guard macros that automatically unlock a
lock object (QemuMutex and others):
void f(void) {
QEMU_LOCK_GUARD(&mutex);
if (!may_fail()) {
return; /* automatically unlocks mutex */
}
...
}
and:
WITH_QEMU_LOCK_GUARD(&mutex) {
if (!may_fail()) {
return; /* automatically unlocks mutex */
}
}
/* automatically unlocks mutex here */
...
Convert qemu-timer.c functions that benefit from these macros as an
example. Manual qemu_mutex_lock/unlock() callers are left unmodified in
cases where clarity would not improve by switching to the macros.
Many other QemuMutex users remain in the codebase that might benefit
from lock guards. Over time they can be converted, if that is
desirable.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
[Use QEMU_MAKE_LOCKABLE_NONNULL. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
include/qemu/lockable.h | 65 +++++++++++++++++++++++++++++++++++++++++++++++++
util/qemu-timer.c | 23 +++++++++--------
2 files changed, 76 insertions(+), 12 deletions(-)
diff --git a/include/qemu/lockable.h b/include/qemu/lockable.h
index 313d4d9..90342ba 100644
--- a/include/qemu/lockable.h
+++ b/include/qemu/lockable.h
@@ -106,4 +106,69 @@ static inline void qemu_lockable_unlock(QemuLockable *x)
x->unlock(x->object);
}
+static inline QemuLockable *qemu_lockable_auto_lock(QemuLockable *x)
+{
+ qemu_lockable_lock(x);
+ return x;
+}
+
+static inline void qemu_lockable_auto_unlock(QemuLockable *x)
+{
+ if (x) {
+ qemu_lockable_unlock(x);
+ }
+}
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(QemuLockable, qemu_lockable_auto_unlock)
+
+#define WITH_QEMU_LOCK_GUARD_(x, var) \
+ for (g_autoptr(QemuLockable) var = \
+ qemu_lockable_auto_lock(QEMU_MAKE_LOCKABLE_NONNULL((x))); \
+ var; \
+ qemu_lockable_auto_unlock(var), var = NULL)
+
+/**
+ * WITH_QEMU_LOCK_GUARD - Lock a lock object for scope
+ *
+ * @x: a lock object (currently one of QemuMutex, CoMutex, QemuSpin).
+ *
+ * This macro defines a lock scope such that entering the scope takes the lock
+ * and leaving the scope releases the lock. Return statements are allowed
+ * within the scope and release the lock. Break and continue statements leave
+ * the scope early and release the lock.
+ *
+ * WITH_QEMU_LOCK_GUARD(&mutex) {
+ * ...
+ * if (error) {
+ * return; <-- mutex is automatically unlocked
+ * }
+ *
+ * if (early_exit) {
+ * break; <-- leave this scope early
+ * }
+ * ...
+ * }
+ */
+#define WITH_QEMU_LOCK_GUARD(x) \
+ WITH_QEMU_LOCK_GUARD_((x), qemu_lockable_auto##__COUNTER__)
+
+/**
+ * QEMU_LOCK_GUARD - Lock an object until the end of the scope
+ *
+ * @x: a lock object (currently one of QemuMutex, CoMutex, QemuSpin).
+ *
+ * This macro takes a lock until the end of the scope. Return statements
+ * release the lock.
+ *
+ * ... <-- mutex not locked
+ * QEMU_LOCK_GUARD(&mutex); <-- mutex locked from here onwards
+ * ...
+ * if (error) {
+ * return; <-- mutex is automatically unlocked
+ * }
+ */
+#define QEMU_LOCK_GUARD(x) \
+ g_autoptr(QemuLockable) qemu_lockable_auto##__COUNTER__ = \
+ qemu_lockable_auto_lock(QEMU_MAKE_LOCKABLE((x)))
+
#endif
diff --git a/util/qemu-timer.c b/util/qemu-timer.c
index ef52d28..d548d3c 100644
--- a/util/qemu-timer.c
+++ b/util/qemu-timer.c
@@ -25,6 +25,7 @@
#include "qemu/osdep.h"
#include "qemu/main-loop.h"
#include "qemu/timer.h"
+#include "qemu/lockable.h"
#include "sysemu/replay.h"
#include "sysemu/cpus.h"
@@ -186,13 +187,12 @@ bool timerlist_expired(QEMUTimerList *timer_list)
return false;
}
- qemu_mutex_lock(&timer_list->active_timers_lock);
- if (!timer_list->active_timers) {
- qemu_mutex_unlock(&timer_list->active_timers_lock);
- return false;
+ WITH_QEMU_LOCK_GUARD(&timer_list->active_timers_lock) {
+ if (!timer_list->active_timers) {
+ return false;
+ }
+ expire_time = timer_list->active_timers->expire_time;
}
- expire_time = timer_list->active_timers->expire_time;
- qemu_mutex_unlock(&timer_list->active_timers_lock);
return expire_time <= qemu_clock_get_ns(timer_list->clock->type);
}
@@ -225,13 +225,12 @@ int64_t timerlist_deadline_ns(QEMUTimerList *timer_list)
* value but ->notify_cb() is called when the deadline changes. Therefore
* the caller should notice the change and there is no race condition.
*/
- qemu_mutex_lock(&timer_list->active_timers_lock);
- if (!timer_list->active_timers) {
- qemu_mutex_unlock(&timer_list->active_timers_lock);
- return -1;
+ WITH_QEMU_LOCK_GUARD(&timer_list->active_timers_lock) {
+ if (!timer_list->active_timers) {
+ return -1;
+ }
+ expire_time = timer_list->active_timers->expire_time;
}
- expire_time = timer_list->active_timers->expire_time;
- qemu_mutex_unlock(&timer_list->active_timers_lock);
delta = expire_time - qemu_clock_get_ns(timer_list->clock->type);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PULL v3 37/62] lockable: add QemuRecMutex support
2020-03-17 15:19 [PULL v3 00/62] Misc patches for soft freeze Paolo Bonzini
2020-03-17 15:19 ` [PULL v3 35/62] lockable: add QEMU_MAKE_LOCKABLE_NONNULL Paolo Bonzini
2020-03-17 15:19 ` [PULL v3 36/62] lockable: add lock guards Paolo Bonzini
@ 2020-03-17 15:19 ` Paolo Bonzini
2020-03-17 21:04 ` [PULL v3 00/62] Misc patches for soft freeze Peter Maydell
3 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2020-03-17 15:19 UTC (permalink / raw)
To: qemu-devel; +Cc: Stefan Hajnoczi
From: Stefan Hajnoczi <stefanha@redhat.com>
The polymorphic locking macros don't support QemuRecMutex yet. Add it
so that lock guards can be used with QemuRecMutex.
Convert TCG plugins functions that benefit from these macros. Manual
qemu_rec_mutex_lock/unlock() callers are left unmodified in cases where
clarity would not improve by switching to the macros.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
include/qemu/lockable.h | 6 ++++--
plugins/core.c | 7 +++----
plugins/loader.c | 16 ++++++++--------
3 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/include/qemu/lockable.h b/include/qemu/lockable.h
index 90342ba..1aeb2cb 100644
--- a/include/qemu/lockable.h
+++ b/include/qemu/lockable.h
@@ -50,6 +50,7 @@ qemu_make_lockable(void *x, QemuLockable *lockable)
#define QEMU_LOCK_FUNC(x) ((QemuLockUnlockFunc *) \
QEMU_GENERIC(x, \
(QemuMutex *, qemu_mutex_lock), \
+ (QemuRecMutex *, qemu_rec_mutex_lock), \
(CoMutex *, qemu_co_mutex_lock), \
(QemuSpin *, qemu_spin_lock), \
unknown_lock_type))
@@ -57,6 +58,7 @@ qemu_make_lockable(void *x, QemuLockable *lockable)
#define QEMU_UNLOCK_FUNC(x) ((QemuLockUnlockFunc *) \
QEMU_GENERIC(x, \
(QemuMutex *, qemu_mutex_unlock), \
+ (QemuRecMutex *, qemu_rec_mutex_unlock), \
(CoMutex *, qemu_co_mutex_unlock), \
(QemuSpin *, qemu_spin_unlock), \
unknown_lock_type))
@@ -73,7 +75,7 @@ qemu_make_lockable(void *x, QemuLockable *lockable)
/* QEMU_MAKE_LOCKABLE - Make a polymorphic QemuLockable
*
- * @x: a lock object (currently one of QemuMutex, CoMutex, QemuSpin).
+ * @x: a lock object (currently one of QemuMutex, QemuRecMutex, CoMutex, QemuSpin).
*
* Returns a QemuLockable object that can be passed around
* to a function that can operate with locks of any kind, or
@@ -86,7 +88,7 @@ qemu_make_lockable(void *x, QemuLockable *lockable)
/* QEMU_MAKE_LOCKABLE_NONNULL - Make a polymorphic QemuLockable
*
- * @x: a lock object (currently one of QemuMutex, CoMutex, QemuSpin).
+ * @x: a lock object (currently one of QemuMutex, QemuRecMutex, CoMutex, QemuSpin).
*
* Returns a QemuLockable object that can be passed around
* to a function that can operate with locks of any kind.
diff --git a/plugins/core.c b/plugins/core.c
index ed86301..51bfc94 100644
--- a/plugins/core.c
+++ b/plugins/core.c
@@ -15,6 +15,7 @@
#include "qemu/error-report.h"
#include "qemu/config-file.h"
#include "qapi/error.h"
+#include "qemu/lockable.h"
#include "qemu/option.h"
#include "qemu/rcu_queue.h"
#include "qemu/xxhash.h"
@@ -150,11 +151,11 @@ do_plugin_register_cb(qemu_plugin_id_t id, enum qemu_plugin_event ev,
{
struct qemu_plugin_ctx *ctx;
- qemu_rec_mutex_lock(&plugin.lock);
+ QEMU_LOCK_GUARD(&plugin.lock);
ctx = plugin_id_to_ctx_locked(id);
/* if the plugin is on its way out, ignore this request */
if (unlikely(ctx->uninstalling)) {
- goto out_unlock;
+ return;
}
if (func) {
struct qemu_plugin_cb *cb = ctx->callbacks[ev];
@@ -178,8 +179,6 @@ do_plugin_register_cb(qemu_plugin_id_t id, enum qemu_plugin_event ev,
} else {
plugin_unregister_cb__locked(ctx, ev);
}
- out_unlock:
- qemu_rec_mutex_unlock(&plugin.lock);
}
void plugin_register_cb(qemu_plugin_id_t id, enum qemu_plugin_event ev,
diff --git a/plugins/loader.c b/plugins/loader.c
index 15fc7e5..685d334 100644
--- a/plugins/loader.c
+++ b/plugins/loader.c
@@ -19,6 +19,7 @@
#include "qemu/error-report.h"
#include "qemu/config-file.h"
#include "qapi/error.h"
+#include "qemu/lockable.h"
#include "qemu/option.h"
#include "qemu/rcu_queue.h"
#include "qemu/qht.h"
@@ -367,15 +368,14 @@ void plugin_reset_uninstall(qemu_plugin_id_t id,
struct qemu_plugin_reset_data *data;
struct qemu_plugin_ctx *ctx;
- qemu_rec_mutex_lock(&plugin.lock);
- ctx = plugin_id_to_ctx_locked(id);
- if (ctx->uninstalling || (reset && ctx->resetting)) {
- qemu_rec_mutex_unlock(&plugin.lock);
- return;
+ WITH_QEMU_LOCK_GUARD(&plugin.lock) {
+ ctx = plugin_id_to_ctx_locked(id);
+ if (ctx->uninstalling || (reset && ctx->resetting)) {
+ return;
+ }
+ ctx->resetting = reset;
+ ctx->uninstalling = !reset;
}
- ctx->resetting = reset;
- ctx->uninstalling = !reset;
- qemu_rec_mutex_unlock(&plugin.lock);
data = g_new(struct qemu_plugin_reset_data, 1);
data->ctx = ctx;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PULL v3 00/62] Misc patches for soft freeze
2020-03-17 15:19 [PULL v3 00/62] Misc patches for soft freeze Paolo Bonzini
` (2 preceding siblings ...)
2020-03-17 15:19 ` [PULL v3 37/62] lockable: add QemuRecMutex support Paolo Bonzini
@ 2020-03-17 21:04 ` Peter Maydell
3 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2020-03-17 21:04 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: QEMU Developers
On Tue, 17 Mar 2020 at 15:30, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> The following changes since commit a98135f727595382e200d04c2996e868b7925a01:
>
> Merge remote-tracking branch 'remotes/kraxel/tags/vga-20200316-pull-request' into staging (2020-03-16 14:55:59 +0000)
>
> are available in the git repository at:
>
>
> git://github.com/bonzini/qemu.git tags/for-upstream
>
> for you to fetch changes up to 32b9523ad5b44dea87792d5d8f71a87e8cc5803b:
>
> hw/arm: Let devices own the MemoryRegion they create (2020-03-17 15:18:50 +0100)
>
> ----------------------------------------------------------------
> * Bugfixes all over the place
> * get/set_uint cleanups (Felipe)
> * Lock guard support (Stefan)
> * MemoryRegion ownership cleanup (Philippe)
> * AVX512 optimization for buffer_is_zero (Robert)
>
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/5.0
for any user-visible changes.
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-03-17 21:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-17 15:19 [PULL v3 00/62] Misc patches for soft freeze Paolo Bonzini
2020-03-17 15:19 ` [PULL v3 35/62] lockable: add QEMU_MAKE_LOCKABLE_NONNULL Paolo Bonzini
2020-03-17 15:19 ` [PULL v3 36/62] lockable: add lock guards Paolo Bonzini
2020-03-17 15:19 ` [PULL v3 37/62] lockable: add QemuRecMutex support Paolo Bonzini
2020-03-17 21:04 ` [PULL v3 00/62] Misc patches for soft freeze Peter Maydell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).