mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
cloud-hypervisor: Add --disk option to provide VM rootfs
Based on the new virtio-blk support, this commit allows any user to specify a --disk option in order to select the rootfs it wants to use for the VM. For now it assumes the partition 3 /dev/vd3 is the one where we can find the rootfs. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
committed by
Samuel Ortiz
parent
b67e0b3dad
commit
1270d09301
15
src/main.rs
15
src/main.rs
@@ -25,6 +25,12 @@ fn main() {
|
||||
.help("Path to kernel image (vmlinux)")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("disk")
|
||||
.long("disk")
|
||||
.help("Path to VM disk image")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("cpus")
|
||||
.long("cpus")
|
||||
@@ -43,9 +49,14 @@ fn main() {
|
||||
.value_of("kernel")
|
||||
.map(PathBuf::from)
|
||||
.expect("Missing argument: kernel");
|
||||
|
||||
let kernel_path = kernel_arg.as_path();
|
||||
|
||||
let disk_arg = cmd_arguments
|
||||
.value_of("disk")
|
||||
.map(PathBuf::from)
|
||||
.expect("Missing argument: disk");
|
||||
let disk_path = disk_arg.as_path();
|
||||
|
||||
let mut vcpus = DEFAULT_VCPUS;
|
||||
if let Some(cpus) = cmd_arguments.value_of("cpus") {
|
||||
vcpus = cpus.parse::<u8>().unwrap();
|
||||
@@ -59,7 +70,7 @@ fn main() {
|
||||
println!("VM [{} vCPUS {} MB of memory]", vcpus, memory);
|
||||
println!("Booting {:?}...", kernel_path);
|
||||
|
||||
let vm_config = VmConfig::new(kernel_path, vcpus, memory).unwrap();
|
||||
let vm_config = VmConfig::new(kernel_path, disk_path, vcpus, memory).unwrap();
|
||||
|
||||
vmm::boot_kernel(vm_config).unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user