mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: memory_manager: Completely fill guest ram from snapshot
Use GuestRegionMmap::read_exact_from() to ensure that all of the file is read into the guest. This addresses an issue where GuestRegionMmap::read_from() was only copying the first 2GiB of the memory and so lead to snapshot-restore was failing when the guest RAM was 2GiB or greater. This change also propagates any error from the copying upwards. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
@@ -35,8 +35,8 @@ use vm_device::BusDevice;
|
|||||||
use vm_memory::guest_memory::FileOffset;
|
use vm_memory::guest_memory::FileOffset;
|
||||||
use vm_memory::{
|
use vm_memory::{
|
||||||
mmap::MmapRegionError, Address, Bytes, Error as MmapError, GuestAddress, GuestAddressSpace,
|
mmap::MmapRegionError, Address, Bytes, Error as MmapError, GuestAddress, GuestAddressSpace,
|
||||||
GuestMemory, GuestMemoryAtomic, GuestMemoryLoadGuard, GuestMemoryMmap, GuestMemoryRegion,
|
GuestMemory, GuestMemoryAtomic, GuestMemoryError, GuestMemoryLoadGuard, GuestMemoryMmap,
|
||||||
GuestRegionMmap, GuestUsize, MemoryRegionAddress, MmapRegion,
|
GuestMemoryRegion, GuestRegionMmap, GuestUsize, MemoryRegionAddress, MmapRegion,
|
||||||
};
|
};
|
||||||
use vm_migration::{
|
use vm_migration::{
|
||||||
Migratable, MigratableError, Pausable, Snapshot, SnapshotDataSection, Snapshottable,
|
Migratable, MigratableError, Pausable, Snapshot, SnapshotDataSection, Snapshottable,
|
||||||
@@ -235,6 +235,12 @@ pub enum Error {
|
|||||||
|
|
||||||
/// Guest address overflow
|
/// Guest address overflow
|
||||||
GuestAddressOverFlow,
|
GuestAddressOverFlow,
|
||||||
|
|
||||||
|
/// Error opening snapshot file
|
||||||
|
SnapshotOpen(io::Error),
|
||||||
|
|
||||||
|
// Error copying snapshot into region
|
||||||
|
SnapshotCopy(GuestMemoryError),
|
||||||
}
|
}
|
||||||
|
|
||||||
const ENABLE_FLAG: usize = 0;
|
const ENABLE_FLAG: usize = 0;
|
||||||
@@ -921,12 +927,12 @@ impl MemoryManager {
|
|||||||
let mut memory_region_file = OpenOptions::new()
|
let mut memory_region_file = OpenOptions::new()
|
||||||
.read(true)
|
.read(true)
|
||||||
.open(ext_backing_file)
|
.open(ext_backing_file)
|
||||||
.unwrap();
|
.map_err(Error::SnapshotOpen)?;
|
||||||
|
|
||||||
// Fill the region with the file content.
|
// Fill the region with the file content.
|
||||||
region
|
region
|
||||||
.read_from(MemoryRegionAddress(0), &mut memory_region_file, size)
|
.read_exact_from(MemoryRegionAddress(0), &mut memory_region_file, size)
|
||||||
.unwrap();
|
.map_err(Error::SnapshotCopy)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply NUMA policy if needed.
|
// Apply NUMA policy if needed.
|
||||||
|
|||||||
Reference in New Issue
Block a user