From 59b5e53c40ece7ec03868bf82f2c620a3eac8390 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 11 Mar 2019 17:36:27 +0100 Subject: [PATCH] cloud-hypervisor: Add the --cpus option You guessed it: To specify the number of vcpus. Signed-off-by: Samuel Ortiz --- src/main.rs | 14 +++++++++++++- vmm/src/vm.rs | 3 ++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 86d02afa5..576ac2313 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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::().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(); } diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 810c90670..34142da53 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -168,9 +168,10 @@ pub struct VmConfig<'a> { } impl<'a> VmConfig<'a> { - pub fn new(kernel_path: &'a Path) -> Result { + pub fn new(kernel_path: &'a Path, vcpus: u8) -> Result { Ok(VmConfig { kernel_path, + vcpu_count: vcpus, ..Default::default() }) }