cloud-hypervisor: Add the --cpus option

You guessed it: To specify the number of vcpus.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
Samuel Ortiz 2019-03-11 17:36:27 +01:00
parent 1853b350ee
commit 59b5e53c40
2 changed files with 15 additions and 2 deletions

View File

@ -25,6 +25,12 @@ fn main() {
.help("Path to kernel image (vmlinux)")
.takes_value(true),
)
.arg(
Arg::with_name("cpus")
.long("cpus")
.help("Number of virtual CPUs")
.takes_value(true),
)
.get_matches();
let kernel_arg = cmd_arguments
@ -34,9 +40,15 @@ fn main() {
let kernel_path = kernel_arg.as_path();
let mut vcpus = DEFAULT_VCPUS;
if let Some(cpus) = cmd_arguments.value_of("cpus") {
vcpus = cpus.parse::<u8>().unwrap();
}
println!("VM [{} vCPUS]", vcpus);
println!("Booting {:?}...", kernel_path);
let vm_config = VmConfig::new(kernel_path).unwrap();
let vm_config = VmConfig::new(kernel_path, vcpus).unwrap();
vmm::boot_kernel(vm_config).unwrap();
}

View File

@ -168,9 +168,10 @@ pub struct VmConfig<'a> {
}
impl<'a> VmConfig<'a> {
pub fn new(kernel_path: &'a Path) -> Result<Self> {
pub fn new(kernel_path: &'a Path, vcpus: u8) -> Result<Self> {
Ok(VmConfig {
kernel_path,
vcpu_count: vcpus,
..Default::default()
})
}