thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-replication-assert-we-own-context-before-job_cancel_.patch

902636
From 46887feac666d0d7633ff3f5af5721fe2a80a8ab Mon Sep 17 00:00:00 2001
902636
From: Kevin Wolf <kwolf@redhat.com>
902636
Date: Wed, 8 Apr 2020 17:29:13 +0100
902636
Subject: [PATCH 2/6] replication: assert we own context before job_cancel_sync
902636
902636
RH-Author: Kevin Wolf <kwolf@redhat.com>
902636
Message-id: <20200408172917.18712-3-kwolf@redhat.com>
902636
Patchwork-id: 94595
902636
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH 2/6] replication: assert we own context before job_cancel_sync
902636
Bugzilla: 1817621
902636
RH-Acked-by: Eric Blake <eblake@redhat.com>
902636
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
902636
RH-Acked-by: Max Reitz <mreitz@redhat.com>
902636
902636
From: Stefan Reiter <s.reiter@proxmox.com>
902636
902636
job_cancel_sync requires the job's lock to be held, all other callers
902636
already do this (replication_stop, drive_backup_abort,
902636
blockdev_backup_abort, job_cancel_sync_all, cancel_common).
902636
902636
In this case we're in a BlockDriver handler, so we already have a lock,
902636
just assert that it is the same as the one used for the commit_job.
902636
902636
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
902636
Message-Id: <20200407115651.69472-3-s.reiter@proxmox.com>
902636
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
902636
(cherry picked from commit 08558e33257ec796594bd411261028a93414a70c)
902636
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
902636
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
902636
---
902636
 block/replication.c | 5 ++++-
902636
 1 file changed, 4 insertions(+), 1 deletion(-)
902636
902636
diff --git a/block/replication.c b/block/replication.c
902636
index 99532ce..0ce27ee 100644
902636
--- a/block/replication.c
902636
+++ b/block/replication.c
902636
@@ -144,12 +144,15 @@ fail:
902636
 static void replication_close(BlockDriverState *bs)
902636
 {
902636
     BDRVReplicationState *s = bs->opaque;
902636
+    Job *commit_job;
902636
 
902636
     if (s->stage == BLOCK_REPLICATION_RUNNING) {
902636
         replication_stop(s->rs, false, NULL);
902636
     }
902636
     if (s->stage == BLOCK_REPLICATION_FAILOVER) {
902636
-        job_cancel_sync(&s->commit_job->job);
902636
+        commit_job = &s->commit_job->job;
902636
+        assert(commit_job->aio_context == qemu_get_current_aio_context());
902636
+        job_cancel_sync(commit_job);
902636
     }
902636
 
902636
     if (s->mode == REPLICATION_MODE_SECONDARY) {
902636
-- 
902636
1.8.3.1
902636