@samitouri / QOSamiQemu / commits / 51395f054a

net/colo-compare: Use QEMU_LOCK_GUARD to simplify mutex handling

Replace qemu_mutex_(un)lock() calls with the QEMU_LOCK_GUARD(). Signed-off-by: Evgeny Kolmakov <randomjack94dev@gmail.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Zhang Chen <zhangckid@gmail.com> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

Evgeny Kolmakov committed May 22, 2026 at 11:06 UTC 51395f054a6e3a9eaa0ac52b8e18362d79c333ef
1 file changed +2 -6
net/colo-compare.c
+2 -6
@@ -902,14 +902,13 @@ static void check_old_packet_regular(void *opaque)
902 void colo_notify_compares_event(void *opaque, int event, Error **errp)
903 {
904 CompareState *s;
905 - qemu_mutex_lock(&colo_compare_mutex);
905 + QEMU_LOCK_GUARD(&colo_compare_mutex);
906
907 if (!colo_compare_active) {
908 - qemu_mutex_unlock(&colo_compare_mutex);
908 return;
909 }
910
912 - qemu_mutex_lock(&event_mtx);
911 + QEMU_LOCK_GUARD(&event_mtx);
912 QTAILQ_FOREACH(s, &net_compares, next) {
913 s->event = event;
914 qemu_bh_schedule(s->event_bh);
@@ -919,9 +918,6 @@ void colo_notify_compares_event(void *opaque, int event, Error **errp)
918 while (event_unhandled_count > 0) {
919 qemu_cond_wait(&event_complete_cond, &event_mtx);
920 }
922 -
923 - qemu_mutex_unlock(&event_mtx);
924 - qemu_mutex_unlock(&colo_compare_mutex);
921 }
922
923 static void colo_compare_timer_init(CompareState *s)