MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / memory_range_table

Method memory_range_table

vmm/src/memory_manager.rs:2541–2578  ·  view source on GitHub ↗
(
        &self,
        snapshot: bool,
    )

Source from the content-addressed store, hash-verified

2539 }
2540
2541 pub fn memory_range_table(
2542 &self,
2543 snapshot: bool,
2544 ) -> std::result::Result<MemoryRangeTable, MigratableError> {
2545 let mut table = MemoryRangeTable::default();
2546
2547 for memory_zone in self.memory_zones.values() {
2548 if let Some(virtio_mem_zone) = memory_zone.virtio_mem_zone() {
2549 table.extend(virtio_mem_zone.plugged_ranges());
2550 }
2551
2552 for region in memory_zone.regions() {
2553 if snapshot
2554 && let Some(file_offset) = region.file_offset()
2555 && (region.flags() & libc::MAP_SHARED == libc::MAP_SHARED)
2556 && Self::is_hardlink(file_offset.file())
2557 {
2558 // In this very specific case, we know the memory
2559 // region is backed by a file on the host filesystem
2560 // that can be accessed by the user, and additionally
2561 // the mapping is shared, which means that modifications
2562 // to the content are written to the actual file.
2563 // When meeting these conditions, we can skip the
2564 // copy of the memory content for this specific region,
2565 // as we can assume the user will have it saved through
2566 // the backing file already.
2567 continue;
2568 }
2569
2570 table.push(MemoryRange {
2571 gpa: region.start_addr().raw_value(),
2572 length: region.len(),
2573 });
2574 }
2575 }
2576
2577 Ok(table)
2578 }
2579
2580 pub fn snapshot_data(&self) -> MemoryManagerSnapshotData {
2581 MemoryManagerSnapshotData {

Callers 2

snapshotMethod · 0.45

Calls 9

virtio_mem_zoneMethod · 0.80
plugged_rangesMethod · 0.80
fileMethod · 0.80
start_addrMethod · 0.80
extendMethod · 0.45
regionsMethod · 0.45
flagsMethod · 0.45
pushMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected