mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-03-20 07:58:55 +00:00
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:
parent
1853b350ee
commit
59b5e53c40
14
src/main.rs
14
src/main.rs
@ -25,6 +25,12 @@ fn main() {
|
|||||||
.help("Path to kernel image (vmlinux)")
|
.help("Path to kernel image (vmlinux)")
|
||||||
.takes_value(true),
|
.takes_value(true),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("cpus")
|
||||||
|
.long("cpus")
|
||||||
|
.help("Number of virtual CPUs")
|
||||||
|
.takes_value(true),
|
||||||
|
)
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
let kernel_arg = cmd_arguments
|
let kernel_arg = cmd_arguments
|
||||||
@ -34,9 +40,15 @@ fn main() {
|
|||||||
|
|
||||||
let kernel_path = kernel_arg.as_path();
|
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);
|
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();
|
vmm::boot_kernel(vm_config).unwrap();
|
||||||
}
|
}
|
||||||
|
@ -168,9 +168,10 @@ pub struct VmConfig<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> 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 {
|
Ok(VmConfig {
|
||||||
kernel_path,
|
kernel_path,
|
||||||
|
vcpu_count: vcpus,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user