main, vmm: Add support for multiple --disk options

Store the list of disks in a Vec<PathBuf> and then iterate over that
when creating the block devices.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford
2019-05-22 14:56:22 +01:00
parent 52790424f2
commit a09f918adc
2 changed files with 47 additions and 45 deletions

View File

@@ -35,7 +35,8 @@ fn main() {
Arg::with_name("disk")
.long("disk")
.help("Path to VM disk image")
.takes_value(true),
.takes_value(true)
.min_values(1),
)
.arg(
Arg::with_name("net")
@@ -69,11 +70,11 @@ fn main() {
.expect("Missing argument: kernel");
let kernel_path = kernel_arg.as_path();
let disk_arg = cmd_arguments
.value_of("disk")
let disk_paths: Vec<PathBuf> = cmd_arguments
.values_of("disk")
.expect("Missing arguments on disk")
.map(PathBuf::from)
.expect("Missing argument: disk");
let disk_path = disk_arg.as_path();
.collect();
let cmdline = cmd_arguments
.value_of("cmdline")
@@ -100,13 +101,13 @@ fn main() {
.unwrap_or(DEFAULT_MEMORY);
println!(
"Cloud Hypervisor Guest\n\tvCPUs: {}\n\tMemory: {} MB\n\tKernel: {:?}\n\tKernel cmdline: {}\n\tDisk: {:?}",
vcpus, memory, kernel_path, cmdline, disk_path
"Cloud Hypervisor Guest\n\tvCPUs: {}\n\tMemory: {} MB\n\tKernel: {:?}\n\tKernel cmdline: {}\n\tDisk(s): {:?}",
vcpus, memory, kernel_path, cmdline, disk_paths,
);
let vm_config = VmConfig::new(
kernel_path,
disk_path,
disk_paths,
rng_path,
cmdline,
net_params,