main: Require a payload to boot when any VM argument provided

If any VM argument (e.g. --disk) is provided require some payload (e.g.
--kernel or --firmware) when parsing the command line arguments.

See: #6831

Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
This commit is contained in:
Rob Bradford 2024-11-07 14:37:37 +00:00 committed by Bo Chen
parent 6e6966df8f
commit 453bc31994

View File

@ -184,9 +184,10 @@ fn create_app(default_vcpus: String, default_memory: String, default_rng: String
.author(env!("CARGO_PKG_AUTHORS")) .author(env!("CARGO_PKG_AUTHORS"))
.about("Launch a cloud-hypervisor VMM.") .about("Launch a cloud-hypervisor VMM.")
.arg_required_else_help(true) .arg_required_else_help(true)
.group(ArgGroup::new("vm-config").multiple(true)) .group(ArgGroup::new("vm-config").multiple(true).requires("vm-payload"))
.group(ArgGroup::new("vmm-config").multiple(true)) .group(ArgGroup::new("vmm-config").multiple(true))
.group(ArgGroup::new("logging").multiple(true)) .group(ArgGroup::new("logging").multiple(true))
.group(ArgGroup::new("vm-payload").multiple(true))
.arg( .arg(
Arg::new("cpus") Arg::new("cpus")
.long("cpus") .long("cpus")
@ -243,7 +244,7 @@ fn create_app(default_vcpus: String, default_memory: String, default_rng: String
.long("firmware") .long("firmware")
.help("Path to firmware that is loaded in an architectural specific way") .help("Path to firmware that is loaded in an architectural specific way")
.num_args(1) .num_args(1)
.group("vm-config"), .group("vm-payload"),
) )
.arg( .arg(
Arg::new("kernel") Arg::new("kernel")
@ -253,7 +254,7 @@ fn create_app(default_vcpus: String, default_memory: String, default_rng: String
entry point (e.g. vmlinux) or architecture equivalent", entry point (e.g. vmlinux) or architecture equivalent",
) )
.num_args(1) .num_args(1)
.group("vm-config"), .group("vm-payload"),
) )
.arg( .arg(
Arg::new("initramfs") Arg::new("initramfs")
@ -519,7 +520,7 @@ fn create_app(default_vcpus: String, default_memory: String, default_rng: String
.long("igvm") .long("igvm")
.help("Path to IGVM file to load.") .help("Path to IGVM file to load.")
.num_args(1) .num_args(1)
.group("vm-config"), .group("vm-payload"),
); );
#[cfg(feature = "sev_snp")] #[cfg(feature = "sev_snp")]
let app = app.arg( let app = app.arg(