vmm: Refactor migration through Migratable trait

Now that Migratable provides the methods for starting, stopping and
retrieving the dirty pages, we move the existing code to these new
functions.

No functional change intended.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2021-08-04 16:52:31 +02:00
committed by Bo Chen
parent e9637d3733
commit 0411064271
3 changed files with 90 additions and 95 deletions

View File

@@ -2156,23 +2156,6 @@ impl Vm {
Ok(table)
}
pub fn start_memory_dirty_log(&self) -> std::result::Result<(), MigratableError> {
self.memory_manager.lock().unwrap().start_memory_dirty_log()
}
pub fn stop_memory_dirty_log(&self) -> std::result::Result<(), MigratableError> {
self.memory_manager.lock().unwrap().stop_memory_dirty_log()
}
pub fn dirty_memory_range_table(
&self,
) -> std::result::Result<MemoryRangeTable, MigratableError> {
self.memory_manager
.lock()
.unwrap()
.dirty_memory_range_table()
}
pub fn device_tree(&self) -> Arc<Mutex<DeviceTree>> {
self.device_manager.lock().unwrap().device_tree()
}
@@ -2539,7 +2522,20 @@ impl Transportable for Vm {
Ok(())
}
}
impl Migratable for Vm {}
impl Migratable for Vm {
fn start_dirty_log(&mut self) -> std::result::Result<(), MigratableError> {
self.memory_manager.lock().unwrap().start_dirty_log()
}
fn stop_dirty_log(&mut self) -> std::result::Result<(), MigratableError> {
self.memory_manager.lock().unwrap().stop_dirty_log()
}
fn dirty_log(&mut self) -> std::result::Result<MemoryRangeTable, MigratableError> {
self.memory_manager.lock().unwrap().dirty_log()
}
}
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
#[cfg(test)]