mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-11-05 03:21:13 +00:00
vmm: Support using an existing FD for memory
If this FD (wrapped in a File) is supplied when the RAM region is being created use that over creating a new one. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
271e17bd79
commit
eeba1d3ad8
@ -480,6 +480,7 @@ impl MemoryManager {
|
||||
zone.hugepages,
|
||||
zone.hugepage_size,
|
||||
zone.host_numa_node,
|
||||
None,
|
||||
)?;
|
||||
|
||||
// Add region to the list of regions associated with the
|
||||
@ -555,6 +556,7 @@ impl MemoryManager {
|
||||
zone_config.hugepages,
|
||||
zone_config.hugepage_size,
|
||||
zone_config.host_numa_node,
|
||||
None,
|
||||
)?;
|
||||
memory_regions.push(Arc::clone(®ion));
|
||||
if let Some(memory_zone) = memory_zones.get_mut(&guest_ram_mapping.zone_id) {
|
||||
@ -939,6 +941,7 @@ impl MemoryManager {
|
||||
zone.hugepages,
|
||||
zone.hugepage_size,
|
||||
zone.host_numa_node,
|
||||
None,
|
||||
)?;
|
||||
|
||||
guest_memory = guest_memory
|
||||
@ -1227,9 +1230,13 @@ impl MemoryManager {
|
||||
hugepages: bool,
|
||||
hugepage_size: Option<u64>,
|
||||
host_numa_node: Option<u32>,
|
||||
existing_memory_file: Option<File>,
|
||||
) -> Result<Arc<GuestRegionMmap>, Error> {
|
||||
let (f, f_off) =
|
||||
Self::open_memory_file(backing_file, file_offset, size, hugepages, hugepage_size)?;
|
||||
let (f, f_off) = if let Some(f) = existing_memory_file {
|
||||
(f, file_offset)
|
||||
} else {
|
||||
Self::open_memory_file(backing_file, file_offset, size, hugepages, hugepage_size)?
|
||||
};
|
||||
|
||||
let mut mmap_flags = libc::MAP_NORESERVE
|
||||
| if shared {
|
||||
@ -1343,6 +1350,7 @@ impl MemoryManager {
|
||||
self.hugepages,
|
||||
self.hugepage_size,
|
||||
None,
|
||||
None,
|
||||
)?;
|
||||
|
||||
// Map it into the guest
|
||||
|
Loading…
Reference in New Issue
Block a user