mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-01 11:05:46 +00:00
vmm: Add fallback handling for sending live migration
This patch adds a fallback path for sending live migration, where it ensures the following behavior of source VM post live-migration: 1. The source VM will be paused only when the migration is completed successfully, or otherwise it will keep running; 2. The source VM will always stop dirty pages logging. Fixes: #2895 Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
parent
eabcbb5159
commit
902fe20d41
@ -999,6 +999,7 @@ impl Vmm {
|
||||
send_data_migration.destination_url
|
||||
);
|
||||
if let Some(ref mut vm) = self.vm {
|
||||
match {
|
||||
let path = Self::socket_url_to_path(&send_data_migration.destination_url)?;
|
||||
let mut socket = UnixStream::connect(&path).map_err(|e| {
|
||||
MigratableError::MigrateSend(anyhow!("Error connecting to UNIX socket: {}", e))
|
||||
@ -1101,9 +1102,6 @@ impl Vmm {
|
||||
// Send last batch of dirty pages
|
||||
Self::vm_maybe_send_dirty_pages(vm, &mut socket)?;
|
||||
|
||||
// Stop logging dirty pages
|
||||
vm.stop_memory_dirty_log()?;
|
||||
|
||||
// Capture snapshot and send it
|
||||
let vm_snapshot = vm.snapshot()?;
|
||||
let snapshot_data = serde_json::to_vec(&vm_snapshot).unwrap();
|
||||
@ -1134,6 +1132,28 @@ impl Vmm {
|
||||
}
|
||||
info!("Migration complete");
|
||||
Ok(())
|
||||
} {
|
||||
// Stop logging dirty pages and keep the source VM paused unpon successful migration
|
||||
Ok(()) => {
|
||||
// Stop logging dirty pages
|
||||
vm.stop_memory_dirty_log()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
// Ensure the source VM continue to run upon unsuccessful migration
|
||||
Err(e) => {
|
||||
error!("Migration failed: {:?}", e);
|
||||
|
||||
// Stop logging dirty pages
|
||||
vm.stop_memory_dirty_log()?;
|
||||
|
||||
if vm.get_state().unwrap() == VmState::Paused {
|
||||
vm.resume()?;
|
||||
}
|
||||
|
||||
e
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Err(MigratableError::MigrateSend(anyhow!("VM is not running")))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user