summaryrefslogtreecommitdiffstats
path: root/monitor
diff options
context:
space:
mode:
authorEmanuele Giuseppe Esposito2022-09-26 11:32:04 +0200
committerKevin Wolf2022-10-07 12:11:41 +0200
commit880eeec61329abc0aead900f0037fce91571b1ec (patch)
tree684676e354ff54754203f40579d6b7eb969805c7 /monitor
parentblock/mirror.c: use of job helpers in drivers (diff)
downloadqemu-880eeec61329abc0aead900f0037fce91571b1ec.tar.gz
qemu-880eeec61329abc0aead900f0037fce91571b1ec.tar.xz
qemu-880eeec61329abc0aead900f0037fce91571b1ec.zip
jobs: group together API calls under the same job lock
Now that the API offers also _locked() functions, take advantage of it and give also the caller control to take the lock and call _locked functions. This makes sense especially when we have for loops, because it makes no sense to have: for(job = job_next(); ...) where each job_next() takes the lock internally. Instead we want JOB_LOCK_GUARD(); for(job = job_next_locked(); ...) In addition, protect also direct field accesses, by either creating a new critical section or widening the existing ones. Note: at this stage, job_{lock/unlock} and job lock guard macros are *nop*. Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Message-Id: <20220926093214.506243-12-eesposit@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'monitor')
-rw-r--r--monitor/qmp-cmds.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
index 7314cd813d..81c8fdadf8 100644
--- a/monitor/qmp-cmds.c
+++ b/monitor/qmp-cmds.c
@@ -135,8 +135,11 @@ void qmp_cont(Error **errp)
blk_iostatus_reset(blk);
}
- for (job = block_job_next(NULL); job; job = block_job_next(job)) {
- block_job_iostatus_reset(job);
+ WITH_JOB_LOCK_GUARD() {
+ for (job = block_job_next_locked(NULL); job;
+ job = block_job_next_locked(job)) {
+ block_job_iostatus_reset_locked(job);
+ }
}
/* Continuing after completed migration. Images have been inactivated to