From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54856) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bst5S-0000xh-Ed for qemu-devel@nongnu.org; Sat, 08 Oct 2016 10:58:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bst5N-0004Ih-IJ for qemu-devel@nongnu.org; Sat, 08 Oct 2016 10:58:54 -0400 Received: from mail-pa0-x241.google.com ([2607:f8b0:400e:c03::241]:33204) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bst5N-0004HP-B2 for qemu-devel@nongnu.org; Sat, 08 Oct 2016 10:58:49 -0400 Received: by mail-pa0-x241.google.com with SMTP id hh10so4262835pac.0 for ; Sat, 08 Oct 2016 07:58:47 -0700 (PDT) References: <1475842893-11763-1-git-send-email-pbonzini@redhat.com> From: Wen Congyang Message-ID: <57F9099E.9040703@gmail.com> Date: Sat, 8 Oct 2016 22:58:38 +0800 MIME-Version: 1.0 In-Reply-To: <1475842893-11763-1-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] replication: interrupt failover if the main device is closed List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org Cc: arei.gonglei@huawei.com, stefanha@redhat.com, zhang.zhanghailiang@huawei.com At 2016/10/7 20:21, Paolo Bonzini wrote: > 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. > > Signed-off-by: Paolo Bonzini This patch looks fine to me. Reviewed-by: Wen Congyang > --- > block/replication.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/block/replication.c b/block/replication.c > index 3bd1cf1..5231a00 100644 > --- a/block/replication.c > +++ b/block/replication.c > @@ -133,6 +133,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); >