mirror of
https://github.com/kata-containers/kata-containers.git
synced 2026-07-01 14:38:33 +00:00
runtime-rs: remove file_mem_backend config option
While the config knob is being parsed, it is being unused in the rust shim. This renders the config knob useless. Remove the file_mem_backend config option as there is no current users for it. As this option is being usable in the go shim, we leave it intact. For the rust shim, /dev/shm is still being used in a similar way to the go shim when filesystem sharing is enabled (virtio-fs). Future use cases where other file_mem_backends are being utilized are currently planning to define these backends in a similar manner: based on the configuration/platform, determine the proper file memory backend, but do not let end users determine the file memory backend. Signed-off-by: Manuel Huber <manuelh@nvidia.com>
This commit is contained in:
@@ -108,7 +108,7 @@ shared_fs = "none"
|
||||
```toml
|
||||
disable_image_nvdimm = true
|
||||
```
|
||||
- Disable shared memory (uncomment)
|
||||
- Disable shared memory (uncomment; only applies to Go runtime)
|
||||
```toml
|
||||
file_mem_backend = ""
|
||||
```
|
||||
|
||||
@@ -235,9 +235,6 @@ pub const KATA_ANNO_CFG_HYPERVISOR_ENABLE_HUGEPAGES: &str =
|
||||
/// A sandbox annotation to specify huge page mode of memory backend.
|
||||
pub const KATA_ANNO_CFG_HYPERVISOR_HUGEPAGE_TYPE: &str =
|
||||
"io.katacontainers.config.hypervisor.hugepage_type";
|
||||
/// A sandbox annotation to soecify file based memory backend root directory.
|
||||
pub const KATA_ANNO_CFG_HYPERVISOR_FILE_BACKED_MEM_ROOT_DIR: &str =
|
||||
"io.katacontainers.config.hypervisor.file_mem_backend";
|
||||
/// A sandbox annotation that is used to enable/disable virtio-mem.
|
||||
pub const KATA_ANNO_CFG_HYPERVISOR_VIRTIO_MEM: &str =
|
||||
"io.katacontainers.config.hypervisor.enable_virtio_mem";
|
||||
@@ -889,10 +886,6 @@ impl Annotation {
|
||||
}
|
||||
}
|
||||
}
|
||||
KATA_ANNO_CFG_HYPERVISOR_FILE_BACKED_MEM_ROOT_DIR => {
|
||||
hv.memory_info.validate_memory_backend_path(value)?;
|
||||
hv.memory_info.file_mem_backend = value.to_string();
|
||||
}
|
||||
KATA_ANNO_CFG_HYPERVISOR_VIRTIO_MEM => match self.get_value::<bool>(key) {
|
||||
Ok(r) => {
|
||||
hv.memory_info.enable_virtio_mem = r.unwrap_or_default();
|
||||
|
||||
@@ -986,18 +986,6 @@ pub struct MemoryInfo {
|
||||
#[serde(default)]
|
||||
pub memory_slots: u32,
|
||||
|
||||
/// File-based guest memory support path.
|
||||
///
|
||||
/// Disabled by default. Automatically set to `/dev/shm` for virtio-fs.
|
||||
#[serde(default)]
|
||||
pub file_mem_backend: String,
|
||||
|
||||
/// Valid file memory backends for annotations.
|
||||
///
|
||||
/// Default: empty (all annotations rejected)
|
||||
#[serde(default)]
|
||||
pub valid_file_mem_backends: Vec<String>,
|
||||
|
||||
/// Pre-allocate VM RAM (reduces container density).
|
||||
#[serde(default)]
|
||||
pub enable_mem_prealloc: bool,
|
||||
@@ -1101,15 +1089,9 @@ fn host_memory_mib() -> io::Result<u64> {
|
||||
impl MemoryInfo {
|
||||
/// Adjusts the configuration information after loading from a configuration file.
|
||||
///
|
||||
/// This method resolves the path for the file memory backend and
|
||||
/// sets `default_maxmemory` if it's currently zero, calculating it
|
||||
/// from the total system memory.
|
||||
/// This method sets `default_maxmemory` if it's currently zero,
|
||||
/// calculating it from the total system memory.
|
||||
pub fn adjust_config(&mut self) -> Result<()> {
|
||||
resolve_path!(
|
||||
self.file_mem_backend,
|
||||
"Memory backend file {} is invalid: {}"
|
||||
)?;
|
||||
|
||||
let host_memory = host_memory_mib()?;
|
||||
|
||||
if u64::from(self.default_memory) > host_memory {
|
||||
@@ -1200,13 +1182,8 @@ impl MemoryInfo {
|
||||
/// Validates the memory configuration information.
|
||||
///
|
||||
/// This ensures that critical memory parameters like `default_memory`
|
||||
/// and `memory_slots` are non-zero, and checks the validity of
|
||||
/// the memory backend file path.
|
||||
/// and `memory_slots` are non-zero.
|
||||
pub fn validate(&self) -> Result<()> {
|
||||
validate_path!(
|
||||
self.file_mem_backend,
|
||||
"Memory backend file {} is invalid: {}"
|
||||
)?;
|
||||
if self.default_memory == 0 {
|
||||
return Err(std::io::Error::other(
|
||||
"Configured memory size for guest VM is zero",
|
||||
@@ -1220,11 +1197,6 @@ impl MemoryInfo {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Validates the path of memory backend files against configured patterns.
|
||||
pub fn validate_memory_backend_path<P: AsRef<Path>>(&self, path: P) -> Result<()> {
|
||||
validate_path_pattern(&self.valid_file_mem_backends, path)
|
||||
}
|
||||
}
|
||||
|
||||
/// Configuration information for network settings.
|
||||
|
||||
@@ -13,7 +13,6 @@ mod tests {
|
||||
KATA_ANNO_CFG_HYPERVISOR_BLOCK_DEV_DRIVER, KATA_ANNO_CFG_HYPERVISOR_DEFAULT_MEMORY,
|
||||
KATA_ANNO_CFG_HYPERVISOR_DEFAULT_VCPUS, KATA_ANNO_CFG_HYPERVISOR_ENABLE_GUEST_SWAP,
|
||||
KATA_ANNO_CFG_HYPERVISOR_ENABLE_HUGEPAGES, KATA_ANNO_CFG_HYPERVISOR_ENABLE_IO_THREADS,
|
||||
KATA_ANNO_CFG_HYPERVISOR_FILE_BACKED_MEM_ROOT_DIR,
|
||||
KATA_ANNO_CFG_HYPERVISOR_GUEST_HOOK_PATH, KATA_ANNO_CFG_HYPERVISOR_INDEP_IO_THREADS,
|
||||
KATA_ANNO_CFG_HYPERVISOR_JAILER_PATH, KATA_ANNO_CFG_HYPERVISOR_KERNEL_PATH,
|
||||
KATA_ANNO_CFG_HYPERVISOR_MEMORY_PREALLOC, KATA_ANNO_CFG_HYPERVISOR_MEMORY_SLOTS,
|
||||
@@ -52,10 +51,6 @@ mod tests {
|
||||
.arg("./jvm")
|
||||
.output()
|
||||
.expect("failed to execute process");
|
||||
std::process::Command::new("mkdir")
|
||||
.arg("./test_file_backend_mem_root")
|
||||
.output()
|
||||
.expect("failed to execute process");
|
||||
std::process::Command::new("mkdir")
|
||||
.arg("./test_jailer_path")
|
||||
.output()
|
||||
@@ -131,10 +126,6 @@ mod tests {
|
||||
KATA_ANNO_CFG_HYPERVISOR_ENABLE_IO_THREADS.to_string(),
|
||||
"false".to_string(),
|
||||
);
|
||||
anno_hash.insert(
|
||||
KATA_ANNO_CFG_HYPERVISOR_FILE_BACKED_MEM_ROOT_DIR.to_string(),
|
||||
"./test_file_backend_mem_root".to_string(),
|
||||
);
|
||||
anno_hash.insert(
|
||||
KATA_ANNO_CFG_HYPERVISOR_ENABLE_HUGEPAGES.to_string(),
|
||||
"false".to_string(),
|
||||
@@ -198,10 +189,6 @@ mod tests {
|
||||
assert_eq!(hv.memory_info.default_memory, 100);
|
||||
assert!(!hv.enable_iothreads);
|
||||
assert_eq!(hv.indep_iothreads, 3);
|
||||
assert_eq!(
|
||||
hv.memory_info.file_mem_backend,
|
||||
"./test_file_backend_mem_root"
|
||||
);
|
||||
assert!(!hv.memory_info.enable_hugepages);
|
||||
assert_eq!(hv.jailer_path, "./test_jailer_path".to_string());
|
||||
assert_eq!(hv.boot_info.kernel, "./test_kernel_path");
|
||||
@@ -242,11 +229,6 @@ mod tests {
|
||||
.output()
|
||||
.expect("failed to execute process");
|
||||
|
||||
std::process::Command::new("rmdir")
|
||||
.arg("./test_file_backend_mem_root")
|
||||
.output()
|
||||
.expect("failed to execute process");
|
||||
|
||||
std::process::Command::new("rmdir")
|
||||
.arg("./test_jailer_path")
|
||||
.output()
|
||||
|
||||
@@ -19,7 +19,7 @@ default_maxvcpus = 64
|
||||
machine_type = "q35"
|
||||
confidential_guest = true
|
||||
rootless = true
|
||||
enable_annotations = ["shared_fs","path", "ctlpath","jailer_path","enable_iothreads","indep_iothreads","default_memory","memory_slots","enable_mem_prealloc","enable_hugepages","file_mem_backend","enable_virtio_mem","enable_guest_swap","default_vcpus","virtio_fs_extra_args","block_device_driver","vhost_user_store_path","kernel","guest_hook_path","block_device_cache_noflush","virtio_fs_daemon","blk_logical_sector_size","blk_physical_sector_size"]
|
||||
enable_annotations = ["shared_fs","path", "ctlpath","jailer_path","enable_iothreads","indep_iothreads","default_memory","memory_slots","enable_mem_prealloc","enable_hugepages","enable_virtio_mem","enable_guest_swap","default_vcpus","virtio_fs_extra_args","block_device_driver","vhost_user_store_path","kernel","guest_hook_path","block_device_cache_noflush","virtio_fs_daemon","blk_logical_sector_size","blk_physical_sector_size"]
|
||||
machine_accelerators="noapic"
|
||||
default_bridges = 2
|
||||
default_memory = 128
|
||||
@@ -44,8 +44,6 @@ vhost_user_store_path = "/tmp"
|
||||
valid_vhost_user_store_paths = ["/var/kata/vhost-user-store*", "/tmp/kata?","/var/tmp","./store_path"]
|
||||
enable_iommu = true
|
||||
enable_iommu_platform = true
|
||||
file_mem_backend = "/dev/shm"
|
||||
valid_file_mem_backends = ["/dev/shm","/dev/snd","./test_file_backend_mem_root"]
|
||||
pflashes = ["/proc/mounts"]
|
||||
enable_debug = true
|
||||
disable_image_nvdimm = true
|
||||
@@ -85,5 +83,3 @@ enable_pprof = true
|
||||
name="virt-container"
|
||||
hypervisor_name = "qemu"
|
||||
agent_name = "agent0"
|
||||
|
||||
|
||||
|
||||
@@ -43,8 +43,6 @@ vhost_user_store_path = "/tmp"
|
||||
valid_vhost_user_store_paths = ["/var/kata/vhost-user-store*", "/tmp/kata?"]
|
||||
enable_iommu = true
|
||||
enable_iommu_platform = true
|
||||
file_mem_backend = "/dev/shm"
|
||||
valid_file_mem_backends = ["/dev/shm"]
|
||||
pflashes = ["/proc/mounts"]
|
||||
enable_debug = true
|
||||
disable_image_nvdimm = true
|
||||
@@ -84,4 +82,3 @@ enable_pprof = true
|
||||
name="virt-container"
|
||||
hypervisor_name = "qemu"
|
||||
agent_name = "agent0"
|
||||
|
||||
|
||||
@@ -208,8 +208,6 @@ DEFINDEPIOTHREADS := 0
|
||||
DEFENABLEVHOSTUSERSTORE := false
|
||||
DEFVHOSTUSERSTOREPATH := $(PKGRUNDIR)/vhost-user
|
||||
DEFVALIDVHOSTUSERSTOREPATHS := [\"$(DEFVHOSTUSERSTOREPATH)\"]
|
||||
DEFFILEMEMBACKEND := ""
|
||||
DEFVALIDFILEMEMBACKENDS := [\"$(DEFFILEMEMBACKEND)\"]
|
||||
DEFMSIZE9P := 8192
|
||||
DEFVFIOMODE := guest-kernel
|
||||
DEFBINDMOUNTS := []
|
||||
@@ -716,8 +714,6 @@ USER_VARS += DEFSECCOMPSANDBOXPARAM
|
||||
USER_VARS += DEFENABLEVHOSTUSERSTORE
|
||||
USER_VARS += DEFVHOSTUSERSTOREPATH
|
||||
USER_VARS += DEFVALIDVHOSTUSERSTOREPATHS
|
||||
USER_VARS += DEFFILEMEMBACKEND
|
||||
USER_VARS += DEFVALIDFILEMEMBACKENDS
|
||||
USER_VARS += DEFMSIZE9P
|
||||
USER_VARS += DEFENTROPYSOURCE
|
||||
USER_VARS += DEFVALIDENTROPYSOURCES
|
||||
|
||||
@@ -327,17 +327,6 @@ enable_iommu_platform = false
|
||||
# Your distribution recommends: @DEFVALIDVHOSTUSERSTOREPATHS@
|
||||
valid_vhost_user_store_paths = @DEFVALIDVHOSTUSERSTOREPATHS@
|
||||
|
||||
# Enable file based guest memory support. The default is an empty string which
|
||||
# will disable this feature. In the case of virtio-fs, this is enabled
|
||||
# automatically and '/dev/shm' is used as the backing folder.
|
||||
# This option will be ignored if VM templating is enabled.
|
||||
file_mem_backend = "@DEFFILEMEMBACKEND@"
|
||||
|
||||
# List of valid annotations values for the file_mem_backend annotation
|
||||
# The default if not set is empty (all annotations rejected.)
|
||||
# Your distribution recommends: @DEFVALIDFILEMEMBACKENDS@
|
||||
valid_file_mem_backends = @DEFVALIDFILEMEMBACKENDS@
|
||||
|
||||
# -pflash can add image file to VM. The arguments of it should be in format
|
||||
# of ["/path/to/flash0.img", "/path/to/flash1.img"]
|
||||
pflashes = []
|
||||
|
||||
@@ -326,17 +326,6 @@ valid_vhost_user_store_paths = @DEFVALIDVHOSTUSERSTOREPATHS@
|
||||
# Zero disables reconnecting, and the default is zero.
|
||||
vhost_user_reconnect_timeout_sec = 0
|
||||
|
||||
# Enable file based guest memory support. The default is an empty string which
|
||||
# will disable this feature. In the case of virtio-fs, this is enabled
|
||||
# automatically and '/dev/shm' is used as the backing folder.
|
||||
# This option will be ignored if VM templating is enabled.
|
||||
file_mem_backend = "@DEFFILEMEMBACKEND@"
|
||||
|
||||
# List of valid annotations values for the file_mem_backend annotation
|
||||
# The default if not set is empty (all annotations rejected.)
|
||||
# Your distribution recommends: @DEFVALIDFILEMEMBACKENDS@
|
||||
valid_file_mem_backends = @DEFVALIDFILEMEMBACKENDS@
|
||||
|
||||
# -pflash can add image file to VM. The arguments of it should be in format
|
||||
# of ["/path/to/flash0.img", "/path/to/flash1.img"]
|
||||
pflashes = []
|
||||
|
||||
@@ -367,17 +367,6 @@ valid_vhost_user_store_paths = @DEFVALIDVHOSTUSERSTOREPATHS@
|
||||
# Zero disables reconnecting, and the default is zero.
|
||||
vhost_user_reconnect_timeout_sec = 0
|
||||
|
||||
# Enable file based guest memory support. The default is an empty string which
|
||||
# will disable this feature. In the case of virtio-fs, this is enabled
|
||||
# automatically and '/dev/shm' is used as the backing folder.
|
||||
# This option will be ignored if VM templating is enabled.
|
||||
file_mem_backend = "@DEFFILEMEMBACKEND@"
|
||||
|
||||
# List of valid annotations values for the file_mem_backend annotation
|
||||
# The default if not set is empty (all annotations rejected.)
|
||||
# Your distribution recommends: @DEFVALIDFILEMEMBACKENDS@
|
||||
valid_file_mem_backends = @DEFVALIDFILEMEMBACKENDS@
|
||||
|
||||
# -pflash can add image file to VM. The arguments of it should be in format
|
||||
# of ["/path/to/flash0.img", "/path/to/flash1.img"]
|
||||
pflashes = []
|
||||
|
||||
@@ -343,17 +343,6 @@ valid_vhost_user_store_paths = @DEFVALIDVHOSTUSERSTOREPATHS@
|
||||
# Zero disables reconnecting, and the default is zero.
|
||||
vhost_user_reconnect_timeout_sec = 0
|
||||
|
||||
# Enable file based guest memory support. The default is an empty string which
|
||||
# will disable this feature. In the case of virtio-fs, this is enabled
|
||||
# automatically and '/dev/shm' is used as the backing folder.
|
||||
# This option will be ignored if VM templating is enabled.
|
||||
file_mem_backend = "@DEFFILEMEMBACKEND@"
|
||||
|
||||
# List of valid annotations values for the file_mem_backend annotation
|
||||
# The default if not set is empty (all annotations rejected.)
|
||||
# Your distribution recommends: @DEFVALIDFILEMEMBACKENDS@
|
||||
valid_file_mem_backends = @DEFVALIDFILEMEMBACKENDS@
|
||||
|
||||
# -pflash can add image file to VM. The arguments of it should be in format
|
||||
# of ["/path/to/flash0.img", "/path/to/flash1.img"]
|
||||
pflashes = []
|
||||
|
||||
@@ -318,17 +318,6 @@ enable_iommu_platform = false
|
||||
# Your distribution recommends: @DEFVALIDVHOSTUSERSTOREPATHS@
|
||||
valid_vhost_user_store_paths = @DEFVALIDVHOSTUSERSTOREPATHS@
|
||||
|
||||
# Enable file based guest memory support. The default is an empty string which
|
||||
# will disable this feature. In the case of virtio-fs, this is enabled
|
||||
# automatically and '/dev/shm' is used as the backing folder.
|
||||
# This option will be ignored if VM templating is enabled.
|
||||
file_mem_backend = "@DEFFILEMEMBACKEND@"
|
||||
|
||||
# List of valid annotations values for the file_mem_backend annotation
|
||||
# The default if not set is empty (all annotations rejected.)
|
||||
# Your distribution recommends: @DEFVALIDFILEMEMBACKENDS@
|
||||
valid_file_mem_backends = @DEFVALIDFILEMEMBACKENDS@
|
||||
|
||||
# -pflash can add image file to VM. The arguments of it should be in format
|
||||
# of ["/path/to/flash0.img", "/path/to/flash1.img"]
|
||||
pflashes = []
|
||||
|
||||
@@ -317,17 +317,6 @@ enable_iommu_platform = false
|
||||
# Your distribution recommends: @DEFVALIDVHOSTUSERSTOREPATHS@
|
||||
valid_vhost_user_store_paths = @DEFVALIDVHOSTUSERSTOREPATHS@
|
||||
|
||||
# Enable file based guest memory support. The default is an empty string which
|
||||
# will disable this feature. In the case of virtio-fs, this is enabled
|
||||
# automatically and '/dev/shm' is used as the backing folder.
|
||||
# This option will be ignored if VM templating is enabled.
|
||||
file_mem_backend = "@DEFFILEMEMBACKEND@"
|
||||
|
||||
# List of valid annotations values for the file_mem_backend annotation
|
||||
# The default if not set is empty (all annotations rejected.)
|
||||
# Your distribution recommends: @DEFVALIDFILEMEMBACKENDS@
|
||||
valid_file_mem_backends = @DEFVALIDFILEMEMBACKENDS@
|
||||
|
||||
# -pflash can add image file to VM. The arguments of it should be in format
|
||||
# of ["/path/to/flash0.img", "/path/to/flash1.img"]
|
||||
pflashes = []
|
||||
|
||||
@@ -358,17 +358,6 @@ enable_iommu_platform = false
|
||||
# Your distribution recommends: @DEFVALIDVHOSTUSERSTOREPATHS@
|
||||
valid_vhost_user_store_paths = @DEFVALIDVHOSTUSERSTOREPATHS@
|
||||
|
||||
# Enable file based guest memory support. The default is an empty string which
|
||||
# will disable this feature. In the case of virtio-fs, this is enabled
|
||||
# automatically and '/dev/shm' is used as the backing folder.
|
||||
# This option will be ignored if VM templating is enabled.
|
||||
file_mem_backend = ""
|
||||
|
||||
# List of valid annotations values for the file_mem_backend annotation
|
||||
# The default if not set is empty (all annotations rejected.)
|
||||
# Your distribution recommends: @DEFVALIDFILEMEMBACKENDS@
|
||||
valid_file_mem_backends = @DEFVALIDFILEMEMBACKENDS@
|
||||
|
||||
# -pflash can add image file to VM. The arguments of it should be in format
|
||||
# of ["/path/to/flash0.img", "/path/to/flash1.img"]
|
||||
pflashes = []
|
||||
|
||||
@@ -335,17 +335,6 @@ enable_iommu_platform = false
|
||||
# Your distribution recommends: @DEFVALIDVHOSTUSERSTOREPATHS@
|
||||
valid_vhost_user_store_paths = @DEFVALIDVHOSTUSERSTOREPATHS@
|
||||
|
||||
# Enable file based guest memory support. The default is an empty string which
|
||||
# will disable this feature. In the case of virtio-fs, this is enabled
|
||||
# automatically and '/dev/shm' is used as the backing folder.
|
||||
# This option will be ignored if VM templating is enabled.
|
||||
file_mem_backend = "@DEFFILEMEMBACKEND@"
|
||||
|
||||
# List of valid annotations values for the file_mem_backend annotation
|
||||
# The default if not set is empty (all annotations rejected.)
|
||||
# Your distribution recommends: @DEFVALIDFILEMEMBACKENDS@
|
||||
valid_file_mem_backends = @DEFVALIDFILEMEMBACKENDS@
|
||||
|
||||
# -pflash can add image file to VM. The arguments of it should be in format
|
||||
# of ["/path/to/flash0.img", "/path/to/flash1.img"]
|
||||
pflashes = []
|
||||
|
||||
@@ -19,7 +19,7 @@ default_maxvcpus = 64
|
||||
machine_type = "q35"
|
||||
confidential_guest = true
|
||||
rootless = true
|
||||
enable_annotations = ["shared_fs","path", "ctlpath","jailer_path","enable_iothreads","default_memory","memory_slots","enable_mem_prealloc","enable_hugepages","file_mem_backend","enable_virtio_mem","enable_guest_swap","default_vcpus","virtio_fs_extra_args","block_device_driver","vhost_user_store_path","kernel","guest_hook_path","block_device_cache_noflush","virtio_fs_daemon"]
|
||||
enable_annotations = ["shared_fs","path", "ctlpath","jailer_path","enable_iothreads","default_memory","memory_slots","enable_mem_prealloc","enable_hugepages","enable_virtio_mem","enable_guest_swap","default_vcpus","virtio_fs_extra_args","block_device_driver","vhost_user_store_path","kernel","guest_hook_path","block_device_cache_noflush","virtio_fs_daemon"]
|
||||
machine_accelerators="noapic"
|
||||
default_bridges = 2
|
||||
default_memory = 128
|
||||
@@ -44,8 +44,6 @@ vhost_user_store_path = "/tmp"
|
||||
valid_vhost_user_store_paths = ["/var/kata/vhost-user-store*", "/tmp/kata?","/var/tmp","./store_path"]
|
||||
enable_iommu = true
|
||||
enable_iommu_platform = true
|
||||
file_mem_backend = "/dev/shm"
|
||||
valid_file_mem_backends = ["/dev/shm","/dev/snd","./test_file_backend_mem_root"]
|
||||
pflashes = ["/proc/mounts"]
|
||||
enable_debug = true
|
||||
msize_9p = 16384
|
||||
@@ -87,4 +85,3 @@ enable_pprof = true
|
||||
hypervisor_name = "qemu"
|
||||
agent_name = "agent0"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user