diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2020-03-16 11:09:57 +0000 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2020-03-17 15:18:45 +0100 |
commit | ac90871cf8030753a7bcef26fa1662c4e3c90078 (patch) | |
tree | a7d926092e7da574dfee46b04a30e4c7591ecfd6 /plugins/core.c | |
parent | 3284c3ddc48ba8fc853858c95d87dcc2ab160b29 (diff) | |
download | qemu-ac90871cf8030753a7bcef26fa1662c4e3c90078.zip qemu-ac90871cf8030753a7bcef26fa1662c4e3c90078.tar.gz qemu-ac90871cf8030753a7bcef26fa1662c4e3c90078.tar.bz2 |
lockable: add QemuRecMutex support
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>
Diffstat (limited to 'plugins/core.c')
-rw-r--r-- | plugins/core.c | 7 |
1 files changed, 3 insertions, 4 deletions
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, |