mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-05 21:15:45 +00:00
main: Only try and parse VM options on VM boot path
As the VmConfig::Parse() also does validation work it only make sense to parse the VM options on the VM boot path only. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
aaf382eee2
commit
11dd609fa5
42
src/main.rs
42
src/main.rs
@ -273,31 +273,10 @@ fn create_app<'a, 'b>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn start_vmm(cmd_arguments: ArgMatches) {
|
fn start_vmm(cmd_arguments: ArgMatches) {
|
||||||
let vm_params = config::VmParams::from_arg_matches(&cmd_arguments);
|
|
||||||
let vm_config = match config::VmConfig::parse(vm_params) {
|
|
||||||
Ok(config) => config,
|
|
||||||
Err(e) => {
|
|
||||||
println!("{}", e);
|
|
||||||
process::exit(1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let api_socket_path = cmd_arguments
|
let api_socket_path = cmd_arguments
|
||||||
.value_of("api-socket")
|
.value_of("api-socket")
|
||||||
.expect("Missing argument: api-socket");
|
.expect("Missing argument: api-socket");
|
||||||
|
|
||||||
println!(
|
|
||||||
"Cloud Hypervisor Guest\n\tAPI server: {}\n\tvCPUs: {}\n\tMemory: {} MB\n\tKernel: \
|
|
||||||
{:?}\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,
|
|
||||||
);
|
|
||||||
|
|
||||||
let (api_request_sender, api_request_receiver) = channel();
|
let (api_request_sender, api_request_receiver) = channel();
|
||||||
let api_evt = EventFd::new(EFD_NONBLOCK).expect("Cannot create API EventFd");
|
let api_evt = EventFd::new(EFD_NONBLOCK).expect("Cannot create API EventFd");
|
||||||
|
|
||||||
@ -334,6 +313,27 @@ fn start_vmm(cmd_arguments: ArgMatches) {
|
|||||||
// Can't test for "vm-config" group as some have default values. The kernel
|
// Can't test for "vm-config" group as some have default values. The kernel
|
||||||
// is the only required option for booting the VM.
|
// is the only required option for booting the VM.
|
||||||
if cmd_arguments.is_present("kernel") {
|
if cmd_arguments.is_present("kernel") {
|
||||||
|
let vm_params = config::VmParams::from_arg_matches(&cmd_arguments);
|
||||||
|
let vm_config = match config::VmConfig::parse(vm_params) {
|
||||||
|
Ok(config) => config,
|
||||||
|
Err(e) => {
|
||||||
|
println!("{}", e);
|
||||||
|
process::exit(1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"Cloud Hypervisor Guest\n\tAPI server: {}\n\tvCPUs: {}\n\tMemory: {} MB\n\tKernel: \
|
||||||
|
{:?}\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,
|
||||||
|
);
|
||||||
|
|
||||||
// Create and boot the VM based off the VM config we just built.
|
// Create and boot the VM based off the VM config we just built.
|
||||||
let sender = api_request_sender.clone();
|
let sender = api_request_sender.clone();
|
||||||
vmm::api::vm_create(
|
vmm::api::vm_create(
|
||||||
|
Loading…
Reference in New Issue
Block a user