From db444715fd36976941c6ef58b3c2d2ad7ce62f03 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Mon, 9 Aug 2021 11:17:37 +0200 Subject: [PATCH] vmm: Shutdown VM after migration succeeded In case the migration succeeds, the destination VM will be correctly running, with potential vhost-user backends attached to it. We can't let the source VM trying to reconnect to the same backends, which is why it's safer to shutdown the source VM. Signed-off-by: Sebastien Boeuf --- vmm/src/lib.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs index 3e2f14cec..f86607527 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -1133,7 +1133,7 @@ impl Vmm { info!("Migration complete"); Ok(()) } { - // Stop logging dirty pages and keep the source VM paused unpon successful migration + // Stop logging dirty pages and shutdown the source VM paused unpon successful migration Ok(()) => { // Let every Migratable object know about the migration being complete vm.complete_migration()?; @@ -1141,6 +1141,14 @@ impl Vmm { // Stop logging dirty pages vm.stop_dirty_log()?; + // Shutdown the VM after the migration succeeded + self.exit_evt.write(1).map_err(|e| { + MigratableError::MigrateSend(anyhow!( + "Failed shutting down the VM after migration: {:?}", + e + )) + })?; + Ok(()) } // Ensure the source VM continue to run upon unsuccessful migration