Skip to content

Commit

Permalink
replication: interrupt failover if the main device is closed
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Changlong Xie <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Fam Zheng <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Fam Zheng <[email protected]>
  • Loading branch information
bonzini authored and Fam Zheng committed Oct 28, 2016
1 parent 9879b75 commit 50ab0e0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions block/replication.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 50ab0e0

Please sign in to comment.