[PULL 4/8] net/colo-compare: Use QEMU_LOCK_GUARD to simplify mutex handling
Michael Tokarev <[email protected]> Fri, 12 Jun 2026 19:59:48 +0300
| Newsgroups | org.nongnu.qemu-trivial,org.nongnu.qemu-devel |
|---|---|
| Message-ID | <[email protected]> |
From: Evgeny Kolmakov <[email protected]> Replace qemu_mutex_(un)lock() calls with the QEMU_LOCK_GUARD(). Signed-off-by: Evgeny Kolmakov <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Zhang Chen <[email protected]> Reviewed-by: Michael Tokarev <[email protected]> Signed-off-by: Michael Tokarev <[email protected]> --- net/colo-compare.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 823b8aa323..5986fb1e88 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -902,14 +902,13 @@ static void check_old_packet_regular(void *opaque) void colo_notify_compares_event(void *opaque, int event, Error **errp) { CompareState *s; - qemu_mutex_lock(&colo_compare_mutex); + QEMU_LOCK_GUARD(&colo_compare_mutex); if (!colo_compare_active) { - qemu_mutex_unlock(&colo_compare_mutex); return; } - qemu_mutex_lock(&event_mtx); + QEMU_LOCK_GUARD(&event_mtx); QTAILQ_FOREACH(s, &net_compares, next) { s->event = event; qemu_bh_schedule(s->event_bh); @@ -919,9 +918,6 @@ void colo_notify_compares_event(void *opaque, int event, Error **errp) while (event_unhandled_count > 0) { qemu_cond_wait(&event_complete_cond, &event_mtx); } - - qemu_mutex_unlock(&event_mtx); - qemu_mutex_unlock(&colo_compare_mutex); } static void colo_compare_timer_init(CompareState *s) -- 2.47.3