From c89b8e061fa6144267e6b6ad0a2e4a2ab901a7af Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Tue, 10 Jan 2023 09:26:08 +0000 Subject: [PATCH] Revert "vmm: Deprecate MemoryZoneConfig::file" This reverts commit 9fb0274479afe2bcebdf53245b542b1261ad0985. A user was identified of this functionality. See: #4837 Signed-off-by: Rob Bradford --- docs/memory.md | 27 ++++++++++++++++++++++- src/main.rs | 2 +- vmm/src/api/openapi/cloud-hypervisor.yaml | 2 ++ vmm/src/config.rs | 4 ---- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/docs/memory.md b/docs/memory.md index ad7a57f2b..dcae83ab7 100644 --- a/docs/memory.md +++ b/docs/memory.md @@ -207,6 +207,7 @@ describing how every memory region is backed and exposed to the guest. struct MemoryZoneConfig { id: String, size: u64, + file: Option, shared: bool, hugepages: bool, hugepage_size: Option, @@ -218,7 +219,7 @@ struct MemoryZoneConfig { ``` ``` ---memory-zone User defined memory zone parameters "size=,shared=on|off,hugepages=on|off,hugepage_size=,host_numa_node=,id=,hotplug_size=,hotplugged_size=,prefault=on|off" +--memory-zone User defined memory zone parameters "size=,file=,shared=on|off,hugepages=on|off,hugepage_size=,host_numa_node=,id=,hotplug_size=,hotplugged_size=,prefault=on|off" ``` This parameter expects one or more occurences, allowing for a list of memory @@ -263,6 +264,30 @@ _Example_ --memory-zone id=mem0,size=1G ``` +### `file` + +Path to the file backing the memory zone. This can be either a file or a +directory. In case of a file, it will be opened and used as the backing file +for the `mmap(2)` operation. In case of a directory, a temporary file with no +hard link on the filesystem will be created. This file will be used as the +backing file for the `mmap(2)` operation. + +This option can be particularly useful when trying to back a part of the guest +RAM with a well known file. In the context of the snapshot/restore feature, and +if the provided path is a file, the snapshot operation will not perform any +copy of the guest RAM content for this specific memory zone since the user has +access to it and it would duplicate data already stored on the current +filesystem. + +Value is a string. + +_Example_ + +``` +--memory size=0 +--memory-zone id=mem0,size=1G,file=/foo/bar +``` + ### `shared` Specifies if the memory zone must be `mmap(2)` with `MAP_SHARED` flag. diff --git a/src/main.rs b/src/main.rs index 51a34dac0..b9007bad3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -175,7 +175,7 @@ fn create_app(default_vcpus: String, default_memory: String, default_rng: String .long("memory-zone") .help( "User defined memory zone parameters \ - \"size=,\ + \"size=,file=,\ shared=on|off,\ hugepages=on|off,hugepage_size=,\ host_numa_node=,\ diff --git a/vmm/src/api/openapi/cloud-hypervisor.yaml b/vmm/src/api/openapi/cloud-hypervisor.yaml index 962e8c1c6..dee8bdbf0 100644 --- a/vmm/src/api/openapi/cloud-hypervisor.yaml +++ b/vmm/src/api/openapi/cloud-hypervisor.yaml @@ -668,6 +668,8 @@ components: type: integer format: int64 default: 512 MB + file: + type: string mergeable: type: boolean default: false diff --git a/vmm/src/config.rs b/vmm/src/config.rs index 145494108..7af624fc3 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -2009,10 +2009,6 @@ impl VmConfig { if let Some(zones) = &self.memory.zones { for zone in zones.iter() { - if zone.file.is_some() { - warn!("MemoryZoneConfig::file is deprecated and will be removed in future release (#4837)"); - } - let id = zone.id.clone(); Self::validate_identifier(&mut id_list, &Some(id))?; }