From 59c1f0b59b9e9e8f8c7c87708a8e65a1691a21c1 Mon Sep 17 00:00:00 2001 From: Hyounggyu Choi Date: Fri, 28 Feb 2025 15:36:58 +0100 Subject: [PATCH] runtime-rs: Suppress kernel parameters for IBM SE For IBM SE, the following kernel parameters are not required: - Basic parameters (reboot and systemd-related) - Rootfs parameters This commit suppresses these parameters when IBM SE is configured. Signed-off-by: Hyounggyu Choi --- .../crates/hypervisor/src/kernel_param.rs | 5 +++++ .../hypervisor/src/qemu/cmdline_generator.rs | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/runtime-rs/crates/hypervisor/src/kernel_param.rs b/src/runtime-rs/crates/hypervisor/src/kernel_param.rs index 5f97a8067d..0677c9977e 100644 --- a/src/runtime-rs/crates/hypervisor/src/kernel_param.rs +++ b/src/runtime-rs/crates/hypervisor/src/kernel_param.rs @@ -123,6 +123,11 @@ impl KernelParams { self.params.push(new_param); } + pub(crate) fn remove_all_by_key(&mut self, key: String) { + // Remove all params with the given key from the vector + self.params.retain(|param| param.key != key); + } + pub(crate) fn from_string(params_string: &str) -> Self { let mut params = vec![]; diff --git a/src/runtime-rs/crates/hypervisor/src/qemu/cmdline_generator.rs b/src/runtime-rs/crates/hypervisor/src/qemu/cmdline_generator.rs index 4695da4a0b..a307db70e3 100644 --- a/src/runtime-rs/crates/hypervisor/src/qemu/cmdline_generator.rs +++ b/src/runtime-rs/crates/hypervisor/src/qemu/cmdline_generator.rs @@ -2142,6 +2142,21 @@ impl<'a> QemuCmdLine<'a> { self.machine .set_confidential_guest_support("pv0") .set_nvdimm(false); + + self.kernel.params.remove_all_by_key("reboot".to_string()); + self.kernel + .params + .remove_all_by_key("systemd.unit".to_string()); + self.kernel + .params + .remove_all_by_key("systemd.mask".to_string()); + self.kernel.params.remove_all_by_key("root".to_string()); + self.kernel + .params + .remove_all_by_key("rootflags".to_string()); + self.kernel + .params + .remove_all_by_key("rootfstype".to_string()); } pub fn add_sev_protection_device(&mut self, cbitpos: u32, firmware: &str) {