mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Use Response::ok_or_abandon() in migration logic
The use of this method removes duplicated code yet provides clarity on the logic. Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
This commit is contained in:
@@ -93,7 +93,7 @@ use vm_memory::{Address, ByteValued, GuestMemoryRegion, ReadVolatile};
|
||||
use vm_memory::{
|
||||
Bytes, GuestAddress, GuestAddressSpace, GuestMemory, GuestMemoryAtomic, WriteVolatile,
|
||||
};
|
||||
use vm_migration::protocol::{Request, Response, Status};
|
||||
use vm_migration::protocol::{Request, Response};
|
||||
use vm_migration::{
|
||||
protocol::MemoryRangeTable, snapshot_from_id, Migratable, MigratableError, Pausable, Snapshot,
|
||||
Snapshottable, Transportable,
|
||||
@@ -2241,15 +2241,10 @@ impl Vm {
|
||||
MigratableError::MigrateSend(anyhow!("Error sending memory fd: {}", e))
|
||||
})?;
|
||||
|
||||
let res = Response::read_from(socket)?;
|
||||
if res.status() != Status::Ok {
|
||||
warn!("Error during memory fd migration");
|
||||
Request::abandon().write_to(socket)?;
|
||||
Response::read_from(socket).ok();
|
||||
return Err(MigratableError::MigrateSend(anyhow!(
|
||||
"Error during memory fd migration"
|
||||
)));
|
||||
}
|
||||
Response::read_from(socket)?.ok_or_abandon(
|
||||
socket,
|
||||
MigratableError::MigrateSend(anyhow!("Error during memory fd migration")),
|
||||
)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user