mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
hypervisor: Implement start/stop_dirty_log for MSHV
This patch modify the existing live migration code to support MSHV. Adds couple of new functions to enable and disable dirty page tracking. Add missing IOCTL to the seccomp rules for live migration. Adds necessary flags for MSHV. This changes don't affect KVM functionality at all. In order to get better performance it is good to enable dirty page tracking when we start live migration and disable it when the migration is done. Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
@@ -34,6 +34,7 @@ use std::fs::File;
|
||||
use std::os::unix::io::AsRawFd;
|
||||
|
||||
const DIRTY_BITMAP_CLEAR_DIRTY: u64 = 0x4;
|
||||
const DIRTY_BITMAP_SET_DIRTY: u64 = 0x8;
|
||||
pub const PAGE_SHIFT: usize = 12;
|
||||
|
||||
#[derive(Debug, Default, Copy, Clone, Serialize, Deserialize)]
|
||||
@@ -905,17 +906,27 @@ impl vm::Vm for MshvVm {
|
||||
/// Start logging dirty pages
|
||||
///
|
||||
fn start_dirty_log(&self) -> vm::Result<()> {
|
||||
Err(vm::HypervisorVmError::StartDirtyLog(anyhow!(
|
||||
"functionality not implemented"
|
||||
)))
|
||||
self.fd
|
||||
.enable_dirty_page_tracking()
|
||||
.map_err(|e| vm::HypervisorVmError::StartDirtyLog(e.into()))
|
||||
}
|
||||
///
|
||||
/// Stop logging dirty pages
|
||||
///
|
||||
fn stop_dirty_log(&self) -> vm::Result<()> {
|
||||
Err(vm::HypervisorVmError::StopDirtyLog(anyhow!(
|
||||
"functionality not implemented"
|
||||
)))
|
||||
let dirty_log_slots = self.dirty_log_slots.read().unwrap();
|
||||
// Before disabling the dirty page tracking we need
|
||||
// to set the dirty bits in the Hypervisor
|
||||
// This is a requirement from Microsoft Hypervisor
|
||||
for (_, s) in dirty_log_slots.iter() {
|
||||
self.fd
|
||||
.get_dirty_log(s.guest_pfn, s.memory_size as usize, DIRTY_BITMAP_SET_DIRTY)
|
||||
.map_err(|e| vm::HypervisorVmError::StartDirtyLog(e.into()))?;
|
||||
}
|
||||
self.fd
|
||||
.disable_dirty_page_tracking()
|
||||
.map_err(|e| vm::HypervisorVmError::StartDirtyLog(e.into()))?;
|
||||
Ok(())
|
||||
}
|
||||
///
|
||||
/// Get dirty pages bitmap (one bit per page)
|
||||
|
||||
Reference in New Issue
Block a user