virtio-devices, vm-migration: Update MigratableError types

Make sure the error types match the function from the Migratable trait.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2021-08-06 14:57:32 +02:00 committed by Bo Chen
parent 204be8611c
commit 1c3f8236e7
4 changed files with 18 additions and 24 deletions

View File

@ -410,13 +410,13 @@ impl Migratable for Blk {
.unwrap()
.start_dirty_log(last_ram_addr)
.map_err(|e| {
MigratableError::MigrateStart(anyhow!(
MigratableError::StartDirtyLog(anyhow!(
"Error starting migration for vhost-user-blk backend: {:?}",
e
))
})
} else {
Err(MigratableError::MigrateStart(anyhow!(
Err(MigratableError::StartDirtyLog(anyhow!(
"Missing guest memory"
)))
}
@ -424,7 +424,7 @@ impl Migratable for Blk {
fn stop_dirty_log(&mut self) -> std::result::Result<(), MigratableError> {
self.vu.lock().unwrap().stop_dirty_log().map_err(|e| {
MigratableError::MigrateStop(anyhow!(
MigratableError::StopDirtyLog(anyhow!(
"Error stopping migration for vhost-user-blk backend: {:?}",
e
))
@ -439,15 +439,13 @@ impl Migratable for Blk {
.unwrap()
.dirty_log(last_ram_addr)
.map_err(|e| {
MigratableError::MigrateDirtyRanges(anyhow!(
MigratableError::DirtyLog(anyhow!(
"Error retrieving dirty ranges from vhost-user-blk backend: {:?}",
e
))
})
} else {
Err(MigratableError::MigrateDirtyRanges(anyhow!(
"Missing guest memory"
)))
Err(MigratableError::DirtyLog(anyhow!("Missing guest memory")))
}
}
}

View File

@ -691,13 +691,13 @@ impl Migratable for Fs {
.unwrap()
.start_dirty_log(last_ram_addr)
.map_err(|e| {
MigratableError::MigrateStart(anyhow!(
MigratableError::StartDirtyLog(anyhow!(
"Error starting migration for vhost-user-fs backend: {:?}",
e
))
})
} else {
Err(MigratableError::MigrateStart(anyhow!(
Err(MigratableError::StartDirtyLog(anyhow!(
"Missing guest memory"
)))
}
@ -705,7 +705,7 @@ impl Migratable for Fs {
fn stop_dirty_log(&mut self) -> std::result::Result<(), MigratableError> {
self.vu.lock().unwrap().stop_dirty_log().map_err(|e| {
MigratableError::MigrateStop(anyhow!(
MigratableError::StopDirtyLog(anyhow!(
"Error stopping migration for vhost-user-fs backend: {:?}",
e
))
@ -720,15 +720,13 @@ impl Migratable for Fs {
.unwrap()
.dirty_log(last_ram_addr)
.map_err(|e| {
MigratableError::MigrateDirtyRanges(anyhow!(
MigratableError::DirtyLog(anyhow!(
"Error retrieving dirty ranges from vhost-user-fs backend: {:?}",
e
))
})
} else {
Err(MigratableError::MigrateDirtyRanges(anyhow!(
"Missing guest memory"
)))
Err(MigratableError::DirtyLog(anyhow!("Missing guest memory")))
}
}
}

View File

@ -497,13 +497,13 @@ impl Migratable for Net {
.unwrap()
.start_dirty_log(last_ram_addr)
.map_err(|e| {
MigratableError::MigrateStart(anyhow!(
MigratableError::StartDirtyLog(anyhow!(
"Error starting migration for vhost-user-net backend: {:?}",
e
))
})
} else {
Err(MigratableError::MigrateStart(anyhow!(
Err(MigratableError::StartDirtyLog(anyhow!(
"Missing guest memory"
)))
}
@ -511,7 +511,7 @@ impl Migratable for Net {
fn stop_dirty_log(&mut self) -> std::result::Result<(), MigratableError> {
self.vu.lock().unwrap().stop_dirty_log().map_err(|e| {
MigratableError::MigrateStop(anyhow!(
MigratableError::StopDirtyLog(anyhow!(
"Error stopping migration for vhost-user-net backend: {:?}",
e
))
@ -526,15 +526,13 @@ impl Migratable for Net {
.unwrap()
.dirty_log(last_ram_addr)
.map_err(|e| {
MigratableError::MigrateDirtyRanges(anyhow!(
MigratableError::DirtyLog(anyhow!(
"Error retrieving dirty ranges from vhost-user-net backend: {:?}",
e
))
})
} else {
Err(MigratableError::MigrateDirtyRanges(anyhow!(
"Missing guest memory"
)))
Err(MigratableError::DirtyLog(anyhow!("Missing guest memory")))
}
}
}

View File

@ -49,13 +49,13 @@ pub enum MigratableError {
MigrateSocket(#[source] std::io::Error),
#[error("Failed to start migration for migratable component: {0}")]
MigrateStart(#[source] anyhow::Error),
StartDirtyLog(#[source] anyhow::Error),
#[error("Failed to stop migration for migratable component: {0}")]
MigrateStop(#[source] anyhow::Error),
StopDirtyLog(#[source] anyhow::Error),
#[error("Failed to retrieve dirty ranges for migratable component: {0}")]
MigrateDirtyRanges(#[source] anyhow::Error),
DirtyLog(#[source] anyhow::Error),
}
/// A Pausable component can be paused and resumed.