main, vmm: add --initramfs cli option

currently unused, the initramfs argument is added to the cli,
and stored in vmm::config:VmConfig as an Option(InitramfsConfig(PathBuf))

Signed-off-by: Damjan Georgievski <gdamjan@gmail.com>
This commit is contained in:
Damjan Georgievski 2020-03-15 18:51:17 +01:00 committed by Sebastien Boeuf
parent 0ce7de3ef5
commit 4db252b418
2 changed files with 27 additions and 1 deletions

View File

@ -113,6 +113,13 @@ fn create_app<'a, 'b>(
.takes_value(true)
.group("vm-config"),
)
.arg(
Arg::with_name("initramfs")
.long("initramfs")
.help("Path to initramfs image")
.takes_value(true)
.group("vm-config"),
)
.arg(
Arg::with_name("cmdline")
.long("cmdline")
@ -273,11 +280,12 @@ fn start_vmm(cmd_arguments: ArgMatches) {
println!(
"Cloud Hypervisor Guest\n\tAPI server: {}\n\tvCPUs: {}\n\tMemory: {} MB\n\tKernel: \
{:?}\n\tKernel cmdline: {}\n\tDisk(s): {:?}",
{:?}\n\tInitramfs: {:?}\n\tKernel cmdline: {}\n\tDisk(s): {:?}",
api_socket_path,
vm_config.cpus.boot_vcpus,
vm_config.memory.size >> 20,
vm_config.kernel,
vm_config.initramfs,
vm_config.cmdline.args.as_str(),
vm_config.disks,
);
@ -477,6 +485,7 @@ mod unit_tests {
hotplug_size: None,
},
kernel: None,
initramfs: None,
cmdline: CmdlineConfig {
args: String::from(""),
},

View File

@ -116,6 +116,7 @@ pub struct VmParams<'a> {
pub cpus: &'a str,
pub memory: &'a str,
pub kernel: Option<&'a str>,
pub initramfs: Option<&'a str>,
pub cmdline: Option<&'a str>,
pub disks: Option<Vec<&'a str>>,
pub net: Option<Vec<&'a str>>,
@ -137,6 +138,7 @@ impl<'a> VmParams<'a> {
let serial = args.value_of("serial").unwrap();
let kernel = args.value_of("kernel");
let initramfs = args.value_of("initramfs");
let cmdline = args.value_of("cmdline");
let disks: Option<Vec<&str>> = args.values_of("disk").map(|x| x.collect());
@ -151,6 +153,7 @@ impl<'a> VmParams<'a> {
cpus,
memory,
kernel,
initramfs,
cmdline,
disks,
net,
@ -348,6 +351,11 @@ pub struct KernelConfig {
pub path: PathBuf,
}
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub struct InitramfsConfig {
pub path: PathBuf,
}
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
pub struct CmdlineConfig {
pub args: String,
@ -1031,6 +1039,7 @@ pub struct VmConfig {
#[serde(default)]
pub memory: MemoryConfig,
pub kernel: Option<KernelConfig>,
pub initramfs: Option<InitramfsConfig>,
#[serde(default)]
pub cmdline: CmdlineConfig,
pub disks: Option<Vec<DiskConfig>>,
@ -1152,10 +1161,18 @@ impl VmConfig {
});
}
let mut initramfs: Option<InitramfsConfig> = None;
if let Some(k) = vm_params.initramfs {
initramfs = Some(InitramfsConfig {
path: PathBuf::from(k),
});
}
Ok(VmConfig {
cpus: CpusConfig::parse(vm_params.cpus)?,
memory: MemoryConfig::parse(vm_params.memory)?,
kernel,
initramfs,
cmdline: CmdlineConfig::parse(vm_params.cmdline)?,
disks,
net,