mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 05:35:20 +00:00
cloud-hypervisor: Add the --memory option
You guessed it: To specify the amount of memory for the VM. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
59b5e53c40
commit
25f4063da6
15
src/main.rs
15
src/main.rs
@ -31,6 +31,12 @@ fn main() {
|
||||
.help("Number of virtual CPUs")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("memory")
|
||||
.long("memory")
|
||||
.help("Amount of RAM (in MB)")
|
||||
.takes_value(true),
|
||||
)
|
||||
.get_matches();
|
||||
|
||||
let kernel_arg = cmd_arguments
|
||||
@ -45,10 +51,15 @@ fn main() {
|
||||
vcpus = cpus.parse::<u8>().unwrap();
|
||||
}
|
||||
|
||||
println!("VM [{} vCPUS]", vcpus);
|
||||
let mut memory = DEFAULT_MEMORY;
|
||||
if let Some(mem) = cmd_arguments.value_of("memory") {
|
||||
memory = mem.parse::<u64>().unwrap();
|
||||
}
|
||||
|
||||
println!("VM [{} vCPUS {} MB of memory]", vcpus, memory);
|
||||
println!("Booting {:?}...", kernel_path);
|
||||
|
||||
let vm_config = VmConfig::new(kernel_path, vcpus).unwrap();
|
||||
let vm_config = VmConfig::new(kernel_path, vcpus, memory).unwrap();
|
||||
|
||||
vmm::boot_kernel(vm_config).unwrap();
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ use vmm_sys_util::EventFd;
|
||||
|
||||
const VCPU_RTSIG_OFFSET: i32 = 0;
|
||||
pub const DEFAULT_VCPUS: u8 = 1;
|
||||
pub const DEFAULT_MEMORY: GuestUsize = 512;
|
||||
const DEFAULT_CMDLINE: &str = "console=ttyS0 reboot=k panic=1 pci=off nomodules \
|
||||
i8042.noaux i8042.nomux i8042.nopnp i8042.dumbkbd";
|
||||
const CMDLINE_OFFSET: GuestAddress = GuestAddress(0x20000);
|
||||
@ -168,9 +169,10 @@ pub struct VmConfig<'a> {
|
||||
}
|
||||
|
||||
impl<'a> VmConfig<'a> {
|
||||
pub fn new(kernel_path: &'a Path, vcpus: u8) -> Result<Self> {
|
||||
pub fn new(kernel_path: &'a Path, vcpus: u8, memory_size: GuestUsize) -> Result<Self> {
|
||||
Ok(VmConfig {
|
||||
kernel_path,
|
||||
memory_size,
|
||||
vcpu_count: vcpus,
|
||||
..Default::default()
|
||||
})
|
||||
@ -187,8 +189,8 @@ impl<'a> Default for VmConfig<'a> {
|
||||
kernel_path: Path::new(""),
|
||||
cmdline: Some(cmdline),
|
||||
cmdline_addr: CMDLINE_OFFSET,
|
||||
memory_size: 512,
|
||||
vcpu_count: 1,
|
||||
memory_size: DEFAULT_MEMORY,
|
||||
vcpu_count: DEFAULT_VCPUS,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user