mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-01 17:35:19 +00:00
main, vmm: Add option to pass firmware parameter in payload
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
763ea7da42
commit
8ec5a248cd
20
src/main.rs
20
src/main.rs
@ -192,11 +192,18 @@ fn create_app<'a>(
|
||||
.min_values(1)
|
||||
.group("vm-config"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("firmware")
|
||||
.long("firmware")
|
||||
.help("Path to firmware that is loaded in an architectural specific way")
|
||||
.takes_value(true)
|
||||
.group("vm-config"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("kernel")
|
||||
.long("kernel")
|
||||
.help(
|
||||
"Path to loaded kernel. This may be a kernel or firmware that supports a PVH \
|
||||
"Path to kernel to load. This may be a kernel or firmware that supports a PVH \
|
||||
entry point (e.g. vmlinux) or architecture equivalent",
|
||||
)
|
||||
.takes_value(true)
|
||||
@ -567,16 +574,15 @@ fn start_vmm(cmd_arguments: ArgMatches) -> Result<Option<String>, Error> {
|
||||
)
|
||||
.map_err(Error::StartVmmThread)?;
|
||||
|
||||
let payload_present =
|
||||
cmd_arguments.is_present("kernel") || cmd_arguments.is_present("firmware");
|
||||
|
||||
// Can't test for "vm-config" group as some have default values. The kernel (or tdx if enabled)
|
||||
// is the only required option for booting the VM.
|
||||
#[cfg(feature = "tdx")]
|
||||
let tdx_or_kernel_present =
|
||||
cmd_arguments.is_present("kernel") || cmd_arguments.is_present("tdx");
|
||||
let payload_present = payload_present || cmd_arguments.is_present("tdx");
|
||||
|
||||
#[cfg(not(feature = "tdx"))]
|
||||
let tdx_or_kernel_present = cmd_arguments.is_present("kernel");
|
||||
|
||||
if tdx_or_kernel_present {
|
||||
if payload_present {
|
||||
let vm_params = config::VmParams::from_arg_matches(&cmd_arguments);
|
||||
let vm_config = config::VmConfig::parse(vm_params).map_err(Error::ParsingConfig)?;
|
||||
|
||||
|
@ -343,6 +343,7 @@ pub struct VmParams<'a> {
|
||||
pub cpus: &'a str,
|
||||
pub memory: &'a str,
|
||||
pub memory_zones: Option<Vec<&'a str>>,
|
||||
pub firmware: Option<&'a str>,
|
||||
pub kernel: Option<&'a str>,
|
||||
pub initramfs: Option<&'a str>,
|
||||
pub cmdline: Option<&'a str>,
|
||||
@ -377,11 +378,10 @@ impl<'a> VmParams<'a> {
|
||||
let memory_zones: Option<Vec<&str>> = args.values_of("memory-zone").map(|x| x.collect());
|
||||
let rng = args.value_of("rng").unwrap();
|
||||
let serial = args.value_of("serial").unwrap();
|
||||
|
||||
let firmware = args.value_of("firmware");
|
||||
let kernel = args.value_of("kernel");
|
||||
let initramfs = args.value_of("initramfs");
|
||||
let cmdline = args.value_of("cmdline");
|
||||
|
||||
let disks: Option<Vec<&str>> = args.values_of("disk").map(|x| x.collect());
|
||||
let net: Option<Vec<&str>> = args.values_of("net").map(|x| x.collect());
|
||||
let console = args.value_of("console").unwrap();
|
||||
@ -405,6 +405,7 @@ impl<'a> VmParams<'a> {
|
||||
cpus,
|
||||
memory,
|
||||
memory_zones,
|
||||
firmware,
|
||||
kernel,
|
||||
initramfs,
|
||||
cmdline,
|
||||
@ -2250,6 +2251,8 @@ impl RestoreConfig {
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
|
||||
pub struct PayloadConfig {
|
||||
#[serde(default)]
|
||||
pub firmware: Option<PathBuf>,
|
||||
#[serde(default)]
|
||||
pub kernel: Option<PathBuf>,
|
||||
#[serde(default)]
|
||||
@ -2334,6 +2337,7 @@ impl VmConfig {
|
||||
Some(self.cmdline.args.drain(..).collect())
|
||||
},
|
||||
initramfs: self.initramfs.take().map(|i| i.path),
|
||||
..Default::default()
|
||||
})
|
||||
}
|
||||
|
||||
@ -2671,11 +2675,12 @@ impl VmConfig {
|
||||
numa = Some(numa_config_list);
|
||||
}
|
||||
|
||||
let payload = if vm_params.kernel.is_some() {
|
||||
let payload = if vm_params.kernel.is_some() || vm_params.firmware.is_some() {
|
||||
Some(PayloadConfig {
|
||||
kernel: vm_params.kernel.map(PathBuf::from),
|
||||
initramfs: vm_params.initramfs.map(PathBuf::from),
|
||||
cmdline: vm_params.cmdline.map(|s| s.to_string()),
|
||||
firmware: vm_params.firmware.map(PathBuf::from),
|
||||
})
|
||||
} else {
|
||||
None
|
||||
|
Loading…
x
Reference in New Issue
Block a user