mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Move MemoryRangeTable creation to the MemoryManager
The function memory_range_table() will be reused by the MemoryManager in a following patch to describe all the ranges that we should snapshot. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
@@ -41,8 +41,8 @@ use vm_memory::{
|
||||
GuestMemory, GuestMemoryAtomic, GuestMemoryError, GuestMemoryRegion, GuestUsize, MmapRegion,
|
||||
};
|
||||
use vm_migration::{
|
||||
protocol::MemoryRangeTable, Migratable, MigratableError, Pausable, Snapshot,
|
||||
SnapshotDataSection, Snapshottable, Transportable, VersionMapped,
|
||||
protocol::MemoryRange, protocol::MemoryRangeTable, Migratable, MigratableError, Pausable,
|
||||
Snapshot, SnapshotDataSection, Snapshottable, Transportable, VersionMapped,
|
||||
};
|
||||
|
||||
#[cfg(feature = "acpi")]
|
||||
@@ -1508,6 +1508,24 @@ impl MemoryManager {
|
||||
pub fn memory_zones(&self) -> &MemoryZones {
|
||||
&self.memory_zones
|
||||
}
|
||||
|
||||
pub fn memory_range_table(&self) -> std::result::Result<MemoryRangeTable, MigratableError> {
|
||||
let mut table = MemoryRangeTable::default();
|
||||
|
||||
for memory_zone in self.memory_zones.values() {
|
||||
for region in memory_zone.regions() {
|
||||
table.push(MemoryRange {
|
||||
gpa: region.start_addr().raw_value(),
|
||||
length: region.len() as u64,
|
||||
});
|
||||
}
|
||||
if let Some(virtio_mem_zone) = memory_zone.virtio_mem_zone() {
|
||||
table.extend(virtio_mem_zone.plugged_ranges());
|
||||
}
|
||||
}
|
||||
|
||||
Ok(table)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "acpi")]
|
||||
|
||||
Reference in New Issue
Block a user