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:
Sebastien Boeuf
2019-05-06 12:15:44 -07:00
committed by Samuel Ortiz
parent b67e0b3dad
commit 1270d09301
2 changed files with 30 additions and 6 deletions

View File

@@ -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();
}