From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46439) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bziFY-0003Jx-Pt for qemu-devel@nongnu.org; Thu, 27 Oct 2016 06:49:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bziFW-00041K-9S for qemu-devel@nongnu.org; Thu, 27 Oct 2016 06:49:32 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:35142) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bziFW-00040h-2N for qemu-devel@nongnu.org; Thu, 27 Oct 2016 06:49:30 -0400 Received: by mail-wm0-x243.google.com with SMTP id b80so2035078wme.2 for ; Thu, 27 Oct 2016 03:49:29 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 27 Oct 2016 12:48:49 +0200 Message-Id: <1477565348-5458-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1477565348-5458-1-git-send-email-pbonzini@redhat.com> References: <1477565348-5458-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 01/20] replication: interrupt failover if the main device is closed List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, famz@redhat.com, stefanha@redhat.com Without this change, there is a race condition in tests/test-replication. Depending on how fast the failover job (active commit) runs, there is a chance of two bad things happening: 1) replication_done can be called after the secondary has been closed and hence when the BDRVReplicationState is not valid anymore. 2) two copies of the active disk are present during the /replication/secondary/stop test (that test runs immediately after /replication/secondary/start, which tests failover). This causes the corruption detector to fire. Reviewed-by: Wen Congyang Reviewed-by: Changlong Xie Signed-off-by: Paolo Bonzini --- block/replication.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/replication.c b/block/replication.c index 8bbfc8f..a2747e7 100644 --- a/block/replication.c +++ b/block/replication.c @@ -138,6 +138,9 @@ static void replication_close(BlockDriverState *bs) if (s->replication_state == BLOCK_REPLICATION_RUNNING) { replication_stop(s->rs, false, NULL); } + if (s->replication_state == BLOCK_REPLICATION_FAILOVER) { + block_job_cancel_sync(s->active_disk->bs->job); + } if (s->mode == REPLICATION_MODE_SECONDARY) { g_free(s->top_id); -- 2.7.4