From a1fbe750fd90d29309fd037ab98f263367aaf770 Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Sat, 17 Jun 2017 00:06:58 +0800 Subject: migration: Fix race of image locking between src and dst Previously, dst side will immediately try to lock the write byte upon receiving QEMU_VM_EOF, but at src side, bdrv_inactivate_all() is only done after sending it. If the src host is under load, dst may fail to acquire the lock due to racing with the src unlocking it. Fix this by hoisting the bdrv_inactivate_all() operation before QEMU_VM_EOF. N.B. A further improvement could possibly be done to cleanly handover locks between src and dst, so that there is no window where a third QEMU could steal the locks and prevent src and dst from running. N.B. This commit includes a minor improvement to the error handling by using qemu_file_set_error(). Reported-by: Peter Maydell Signed-off-by: Fam Zheng Message-id: 20170616160658.32290-1-famz@redhat.com Reviewed-by: Daniel P. Berrange Reviewed-by: Juan Quintela [PMM: noted qemu_file_set_error() use in commit as suggested by Daniel] Signed-off-by: Peter Maydell --- migration/colo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'migration/colo.c') diff --git a/migration/colo.c b/migration/colo.c index c436d63a19..c4ba4c328b 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -352,7 +352,7 @@ static int colo_do_checkpoint_transaction(MigrationState *s, qemu_savevm_state_header(fb); qemu_savevm_state_begin(fb); qemu_mutex_lock_iothread(); - qemu_savevm_state_complete_precopy(fb, false); + qemu_savevm_state_complete_precopy(fb, false, false); qemu_mutex_unlock_iothread(); qemu_fflush(fb); -- cgit v1.2.1