vmm: make receive_memory_ranges take the requests directly

This just removes some unnecessary indirections.

On-behalf-of: SAP sebastian.eydam@sap.com
Signed-off-by: Sebastian Eydam <sebastian.eydam@cyberus-technology.de>
This commit is contained in:
Sebastian Eydam
2026-03-12 10:29:49 +01:00
committed by Bo Chen
parent 98ece1e347
commit 058954a8c1
2 changed files with 9 additions and 16 deletions

View File

@@ -892,7 +892,7 @@ impl Vmm {
},
Configured(memory_manager, guest_memory) => match req.command() {
Command::Memory => {
self.vm_receive_memory(req, socket, &guest_memory)?;
migration_transport::receive_memory_ranges(&guest_memory, req, socket)?;
Ok(Configured(memory_manager, guest_memory))
}
Command::State => {
@@ -1070,18 +1070,6 @@ impl Vmm {
Ok(())
}
fn vm_receive_memory(
&mut self,
req: &Request,
socket: &mut SocketStream,
guest_mem: &GuestMemoryAtomic<GuestMemoryMmap>,
) -> std::result::Result<(), MigratableError> {
let table = MemoryRangeTable::read_from(socket, req.length())?;
// And then the memory itself
migration_transport::receive_memory_ranges(guest_mem, &table, socket)
}
/// Performs the initial memory transmission (iteration zero) plus a
/// variable number of memory iterations with the goal to eventually migrate
/// the VM in a reasonably small downtime.

View File

@@ -19,7 +19,7 @@ use vm_memory::{
Bytes, GuestAddress, GuestAddressSpace, GuestMemoryAtomic, ReadVolatile, VolatileMemoryError,
VolatileSlice, WriteVolatile,
};
use vm_migration::protocol::{MemoryRangeTable, Request, Response};
use vm_migration::protocol::{Command, MemoryRangeTable, Request, Response};
use vm_migration::{MigratableError, Snapshot};
use crate::{GuestMemoryMmap, VmMigrationConfig};
@@ -366,12 +366,17 @@ pub(crate) fn send_memory_ranges(
)
}
/// Receive memory contents for the given range table into guest memory.
/// Receive memory contents for the given request and copy it into guest memory.
pub(crate) fn receive_memory_ranges(
guest_memory: &GuestMemoryAtomic<GuestMemoryMmap>,
ranges: &MemoryRangeTable,
req: &Request,
socket: &mut SocketStream,
) -> Result<(), MigratableError> {
debug_assert_eq!(req.command(), Command::Memory);
// Read the memory table
let ranges = MemoryRangeTable::read_from(socket, req.length())?;
// And then the memory itself
let mem = guest_memory.memory();
for range in ranges.regions() {