vm-migration: Extend Migratable trait

Add new methods to the Migratable trait so that each device implementing
this trait can be notified when the migration starts/stops, as well as
when a dirty bitmap must be returned.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2021-08-04 11:06:54 +02:00 committed by Bo Chen
parent 79425b6aa8
commit c1b962048c

View File

@ -6,6 +6,7 @@
#[macro_use]
extern crate serde_derive;
use crate::protocol::MemoryRangeTable;
use anyhow::anyhow;
use serde::{Deserialize, Serialize};
use thiserror::Error;
@ -46,6 +47,15 @@ pub enum MigratableError {
#[error("Socket error: {0}")]
MigrateSocket(#[source] std::io::Error),
#[error("Failed to start migration for migratable component: {0}")]
MigrateStart(#[source] anyhow::Error),
#[error("Failed to stop migration for migratable component: {0}")]
MigrateStop(#[source] anyhow::Error),
#[error("Failed to retrieve dirty ranges for migratable component: {0}")]
MigrateDirtyRanges(#[source] anyhow::Error),
}
/// A Pausable component can be paused and resumed.
@ -279,4 +289,16 @@ pub trait Transportable: Pausable + Snapshottable {
/// and Snapshottable.
/// Moreover a migratable component can be transported to a remote or local
/// destination and thus must be Transportable.
pub trait Migratable: Send + Pausable + Snapshottable + Transportable {}
pub trait Migratable: Send + Pausable + Snapshottable + Transportable {
fn start_dirty_log(&mut self) -> std::result::Result<(), MigratableError> {
Ok(())
}
fn stop_dirty_log(&mut self) -> std::result::Result<(), MigratableError> {
Ok(())
}
fn dirty_log(&mut self) -> std::result::Result<MemoryRangeTable, MigratableError> {
Ok(MemoryRangeTable::default())
}
}