[PATCH] block/replication.c: Avoid cancelling the job twice

Lukas Straub posted 1 patch 3 years, 12 months ago
Test docker-mingw@fedora passed
Test checkpatch passed
Test asan passed
Test docker-quick@centos7 passed
Test FreeBSD passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20200511090801.7ed5d8f3@luklap
Maintainers: Max Reitz <mreitz@redhat.com>, Xie Changlong <xiechanglong.d@gmail.com>, Wen Congyang <wencongyang2@huawei.com>, Kevin Wolf <kwolf@redhat.com>
block/replication.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] block/replication.c: Avoid cancelling the job twice
Posted by Lukas Straub 3 years, 12 months ago
If qemu in colo secondary mode is stopped, it crashes because
s->backup_job is canceled twice: First with job_cancel_sync_all()
in qemu_cleanup() and then in replication_stop().

Fix this by assigning NULL to s->backup_job when the job completes
so replication_stop() and replication_do_checkpoint() won't touch
the job.

Signed-off-by: Lukas Straub <lukasstraub2@web.de>
---
 block/replication.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/block/replication.c b/block/replication.c
index da013c2041..33f2f62a44 100644
--- a/block/replication.c
+++ b/block/replication.c
@@ -398,6 +398,8 @@ static void backup_job_cleanup(BlockDriverState *bs)
     BDRVReplicationState *s = bs->opaque;
     BlockDriverState *top_bs;
 
+    s->backup_job = NULL;
+
     top_bs = bdrv_lookup_bs(s->top_id, s->top_id, NULL);
     if (!top_bs) {
         return;
-- 
2.20.1
Re: [PATCH] block/replication.c: Avoid cancelling the job twice
Posted by Kevin Wolf 3 years, 11 months ago
Am 11.05.2020 um 09:08 hat Lukas Straub geschrieben:
> If qemu in colo secondary mode is stopped, it crashes because
> s->backup_job is canceled twice: First with job_cancel_sync_all()
> in qemu_cleanup() and then in replication_stop().
> 
> Fix this by assigning NULL to s->backup_job when the job completes
> so replication_stop() and replication_do_checkpoint() won't touch
> the job.
> 
> Signed-off-by: Lukas Straub <lukasstraub2@web.de>

Thanks, applied to the block branch.

Kevin