main: Add kernel command line support

In order to let the user choose which kernel parameters to append, the
kernel boot parameters can be now specified from the command line.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2019-05-06 13:24:57 -07:00
committed by Samuel Ortiz
parent 1270d09301
commit 112418d928
2 changed files with 21 additions and 24 deletions

View File

@@ -25,6 +25,12 @@ fn main() {
.help("Path to kernel image (vmlinux)")
.takes_value(true),
)
.arg(
Arg::with_name("cmdline")
.long("cmdline")
.help("Kernel command line")
.takes_value(true),
)
.arg(
Arg::with_name("disk")
.long("disk")
@@ -51,6 +57,11 @@ fn main() {
.expect("Missing argument: kernel");
let kernel_path = kernel_arg.as_path();
let cmdline = cmd_arguments
.value_of("cmdline")
.map(std::string::ToString::to_string)
.expect("Missing argument: cmdline");
let disk_arg = cmd_arguments
.value_of("disk")
.map(PathBuf::from)
@@ -70,7 +81,7 @@ fn main() {
println!("VM [{} vCPUS {} MB of memory]", vcpus, memory);
println!("Booting {:?}...", kernel_path);
let vm_config = VmConfig::new(kernel_path, disk_path, vcpus, memory).unwrap();
let vm_config = VmConfig::new(kernel_path, disk_path, cmdline, vcpus, memory).unwrap();
vmm::boot_kernel(vm_config).unwrap();
}