mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
tests: Add platform argument support to kernel cmdline builder
Introduce default_kernel_cmdline_with_platform() in GuestCommand that accepts an optional platform parameter. For confidential VMs, the platform arg is prepended to sev_snp=on. For regular VMs, it is passed via --platform if provided. Retain default_kernel_cmdline() as a convenience wrapper that calls the new method with None, preserving backward compatibility. This enables tests to pass additional platform configuration such as num_pci_segments alongside the default kernel and cmdline setup. Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
6f8776ac50
commit
2aa92bf4b4
@@ -1694,7 +1694,7 @@ impl<'a> GuestCommand<'a> {
|
|||||||
self.args(["--net", self.guest.default_net_string().as_str()])
|
self.args(["--net", self.guest.default_net_string().as_str()])
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_kernel_cmdline(&mut self) -> &mut Self {
|
pub fn default_kernel_cmdline_with_platform(&mut self, platform: Option<&str>) -> &mut Self {
|
||||||
if self.guest.vm_type == GuestVmType::Confidential {
|
if self.guest.vm_type == GuestVmType::Confidential {
|
||||||
let console_str = if let Some(c) = &self.guest.console_type {
|
let console_str = if let Some(c) = &self.guest.console_type {
|
||||||
c.as_str()
|
c.as_str()
|
||||||
@@ -1709,17 +1709,34 @@ impl<'a> GuestCommand<'a> {
|
|||||||
]);
|
]);
|
||||||
self.command
|
self.command
|
||||||
.args(["--host-data", generate_host_data().as_str()]);
|
.args(["--host-data", generate_host_data().as_str()]);
|
||||||
self.command.args(["--platform", "sev_snp=on"]);
|
self.command.args([
|
||||||
|
"--platform",
|
||||||
|
&format!(
|
||||||
|
"{}sev_snp=on",
|
||||||
|
if let Some(p) = platform {
|
||||||
|
format!("{p},")
|
||||||
|
} else {
|
||||||
|
String::new()
|
||||||
|
}
|
||||||
|
),
|
||||||
|
]);
|
||||||
} else if let Some(kernel) = &self.guest.kernel_path {
|
} else if let Some(kernel) = &self.guest.kernel_path {
|
||||||
self.command.args(["--kernel", kernel.as_str()]);
|
self.command.args(["--kernel", kernel.as_str()]);
|
||||||
if let Some(cmdline) = &self.guest.kernel_cmdline {
|
if let Some(cmdline) = &self.guest.kernel_cmdline {
|
||||||
self.command.args(["--cmdline", cmdline]);
|
self.command.args(["--cmdline", cmdline]);
|
||||||
}
|
}
|
||||||
|
if let Some(platform_arg) = platform {
|
||||||
|
self.command.args(["--platform", platform_arg]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn default_kernel_cmdline(&mut self) -> &mut Self {
|
||||||
|
self.default_kernel_cmdline_with_platform(None)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn default_cpus(&mut self) -> &mut Self {
|
pub fn default_cpus(&mut self) -> &mut Self {
|
||||||
self.args(["--cpus", self.guest.default_cpus_string().as_str()])
|
self.args(["--cpus", self.guest.default_cpus_string().as_str()])
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user