From bd180bc3eb6e8b91c8fd2f0d25ff4a7645013caa Mon Sep 17 00:00:00 2001 From: Praveen K Paladugu Date: Thu, 1 Aug 2024 17:38:20 +0000 Subject: [PATCH] main: rename landlock_config to landlock_rules To keep the naming consistent, rename all uses of landlock_config to landlock_rules. Signed-off-by: Praveen K Paladugu --- fuzz/fuzz_targets/http_api.rs | 2 +- src/main.rs | 2 +- vmm/src/config.rs | 28 ++++++++++++++-------------- vmm/src/lib.rs | 2 +- vmm/src/vm_config.rs | 8 ++++---- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/fuzz/fuzz_targets/http_api.rs b/fuzz/fuzz_targets/http_api.rs index 553c338d5..727fbf967 100644 --- a/fuzz/fuzz_targets/http_api.rs +++ b/fuzz/fuzz_targets/http_api.rs @@ -191,7 +191,7 @@ impl RequestHandler for StubApiRequestHandler { tpm: None, preserved_fds: None, landlock_enable: false, - landlock_config: None, + landlock_rules: None, })), state: VmState::Running, memory_actual_size: 0, diff --git a/src/main.rs b/src/main.rs index 451c9985c..36e0da4c5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1066,7 +1066,7 @@ mod unit_tests { tpm: None, preserved_fds: None, landlock_enable: false, - landlock_config: None, + landlock_rules: None, }; assert_eq!(expected_vm_config, result_vm_config); diff --git a/vmm/src/config.rs b/vmm/src/config.rs index 6a9665e66..c788cb83a 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -497,7 +497,7 @@ pub struct VmParams<'a> { #[cfg(feature = "sev_snp")] pub host_data: Option<&'a str>, pub landlock_enable: bool, - pub landlock_config: Option>, + pub landlock_rules: Option>, } impl<'a> VmParams<'a> { @@ -564,7 +564,7 @@ impl<'a> VmParams<'a> { #[cfg(feature = "sev_snp")] let host_data = args.get_one::("host-data").map(|x| x as &str); let landlock_enable = args.get_flag("landlock"); - let landlock_config: Option> = args + let landlock_rules: Option> = args .get_many::("landlock-rules") .map(|x| x.map(|y| y as &str).collect()); @@ -606,7 +606,7 @@ impl<'a> VmParams<'a> { #[cfg(feature = "sev_snp")] host_data, landlock_enable, - landlock_config, + landlock_rules, } } } @@ -2725,9 +2725,9 @@ impl VmConfig { .map(|p| p.iommu_segments.is_some()) .unwrap_or_default(); - if let Some(landlock_configs) = &self.landlock_config { - for landlock_config in landlock_configs { - landlock_config.validate()?; + if let Some(landlock_rules) = &self.landlock_rules { + for landlock_rule in landlock_rules { + landlock_rule.validate()?; } } @@ -2901,10 +2901,10 @@ impl VmConfig { #[cfg(feature = "guest_debug")] let gdb = vm_params.gdb; - let mut landlock_config: Option> = None; - if let Some(ll_config) = vm_params.landlock_config { - landlock_config = Some( - ll_config + let mut landlock_rules: Option> = None; + if let Some(ll_rules) = vm_params.landlock_rules { + landlock_rules = Some( + ll_rules .iter() .map(|rule| LandlockConfig::parse(rule)) .collect::>>()?, @@ -2943,7 +2943,7 @@ impl VmConfig { tpm, preserved_fds: None, landlock_enable: vm_params.landlock_enable, - landlock_config, + landlock_rules, }; config.validate().map_err(Error::Validation)?; Ok(config) @@ -3070,7 +3070,7 @@ impl Clone for VmConfig { .as_ref() // SAFETY: FFI call with valid FDs .map(|fds| fds.iter().map(|fd| unsafe { libc::dup(*fd) }).collect()), - landlock_config: self.landlock_config.clone(), + landlock_rules: self.landlock_rules.clone(), ..*self } } @@ -3870,7 +3870,7 @@ mod tests { }, ]), landlock_enable: false, - landlock_config: None, + landlock_rules: None, }; let valid_config = RestoreConfig { @@ -4060,7 +4060,7 @@ mod tests { tpm: None, preserved_fds: None, landlock_enable: false, - landlock_config: None, + landlock_rules: None, }; assert!(valid_config.validate().is_ok()); diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs index 32e1d9e24..4f6cf40e5 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -2243,7 +2243,7 @@ mod unit_tests { tpm: None, preserved_fds: None, landlock_enable: false, - landlock_config: None, + landlock_rules: None, })) } diff --git a/vmm/src/vm_config.rs b/vmm/src/vm_config.rs index 51de9af05..3a746f7fa 100644 --- a/vmm/src/vm_config.rs +++ b/vmm/src/vm_config.rs @@ -798,7 +798,7 @@ pub struct VmConfig { pub preserved_fds: Option>, #[serde(default)] pub landlock_enable: bool, - pub landlock_config: Option>, + pub landlock_rules: Option>, } impl VmConfig { @@ -876,9 +876,9 @@ impl VmConfig { landlock.add_rule_with_access("/dev/net/tun".into(), "rw")?; } - if let Some(landlock_configs) = &self.landlock_config { - for landlock_config in landlock_configs.iter() { - landlock_config.apply_landlock(&mut landlock)?; + if let Some(landlock_rules) = &self.landlock_rules { + for landlock_rule in landlock_rules.iter() { + landlock_rule.apply_landlock(&mut landlock)?; } }