Skip to contentSkip to conversation

Mechanical conversion to QEMU_LOCK_GUARD

PATCH In review Evgeny Kolmakov 3 participants 6 messages May 22 – May 26

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Mechanical conversion to QEMU_LOCK_GUARD

This trivial series replaces manual qemu_mutex_(un)lock() calls with the safer QEMU_LOCK_GUARD() macro in
net/colo-compare.c: colo_notify_compares_event(), block/io.c: bdrv_co_get_self_request().

Evgeny Kolmakov (2):
net/colo-compare: Use QEMU_LOCK_GUARD to simplify mutex handling block/io: Use QEMU_LOCK_GUARD to simplify mutex handling

 block/io.c         | 4 +---
 net/colo-compare.c | 8 ++------
 2 files changed, 3 insertions(+), 9 deletions(-)
Signature · 1 line
2.43.0
#3 lore raw

PATCH 2/2 block/io: Use QEMU_LOCK_GUARD to simplify mutex handling

Replace qemu_mutex_(un)lock() calls with QEMU_LOCK_GUARD().

---
 block/io.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
block/io.c +1 -3
index e8fb4ede4d..1020047888 100644
@@ -719,14 +719,12 @@ BdrvTrackedRequest *coroutine_fn bdrv_co_get_self_request(BlockDriverState *bs)
     Coroutine *self = qemu_coroutine_self();
     IO_CODE();
 
-    qemu_mutex_lock(&bs->reqs_lock);
+    QEMU_LOCK_GUARD(&bs->reqs_lock);
     QLIST_FOREACH(req, &bs->tracked_requests, list) {
         if (req->co == self) {
-            qemu_mutex_unlock(&bs->reqs_lock);
             return req;
         }
     }
-    qemu_mutex_unlock(&bs->reqs_lock);
 
     return NULL;
 }
Signature · 1 line
2.43.0
#1 lore raw

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

In reply to Evgeny Kolmakov

Replace qemu_mutex_(un)lock() calls with the QEMU_LOCK_GUARD().

---
 net/colo-compare.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
net/colo-compare.c +2 -6
index 823b8aa323..5986fb1e88 100644
@@ -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)
Signature · 1 line
2.43.0
Reviewed-by on the v1 series
#5 lore raw
In reply to Evgeny Kolmakov
Quoted 6 lines · Evgeny Kolmakov

This trivial series replaces manual qemu_mutex_(un)lock() calls with the safer QEMU_LOCK_GUARD() macro in
net/colo-compare.c: colo_notify_compares_event(), block/io.c: bdrv_co_get_self_request().

Quoted 8 lines

Evgeny Kolmakov (2):
net/colo-compare: Use QEMU_LOCK_GUARD to simplify mutex handling block/io: Use QEMU_LOCK_GUARD to simplify mutex handling

 block/io.c         | 4 +---
 net/colo-compare.c | 8 ++------
 2 files changed, 3 insertions(+), 9 deletions(-)

LGTM.
For this series:

Quoted 3 lines

--
2.43.0