(
&self,
snapshot: bool,
)
| 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 { |
no test coverage detected