vmm: extract receive_memory_regions from memory manager

The memory manager is guarded by a mutex, thus parallel accesses to it
and its members are not possible. But we have to execute this function
in parallel when we introduce multiple TCP connections. Otherwise, the
workers who receive the data and write it into guest memory will block
on each other, and thus slow down the migration.

Also rename the function to receive_memory_ranges for better naming
consistency.

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-10 10:07:10 +01:00
committed by Bo Chen
parent e175ad64f2
commit ec42ee8004
3 changed files with 44 additions and 53 deletions

View File

@@ -36,7 +36,6 @@ use serde::{Deserialize, Serialize};
use signal_hook::iterator::{Handle, Signals};
use thiserror::Error;
use tracer::trace_scoped;
use vm_memory::ReadVolatile;
use vm_memory::bitmap::AtomicBitmap;
use vm_migration::protocol::*;
use vm_migration::{
@@ -1056,21 +1055,16 @@ impl Vmm {
Ok(())
}
fn vm_receive_memory<T>(
fn vm_receive_memory(
&mut self,
req: &Request,
socket: &mut T,
socket: &mut SocketStream,
memory_manager: &mut MemoryManager,
) -> std::result::Result<(), MigratableError>
where
T: Read + ReadVolatile,
{
// Read table
) -> std::result::Result<(), MigratableError> {
let table = MemoryRangeTable::read_from(socket, req.length())?;
// And then read the memory itself
memory_manager.receive_memory_regions(&table, socket)?;
Ok(())
// And then the memory itself
migration_transport::receive_memory_ranges(&memory_manager.guest_memory(), &table, socket)
}
/// Performs the initial memory transmission (iteration zero) plus a