vmm: Move restore parameters into common RestoreConfig structure

The goal here is to move the restore parameters into a dedicated
structure that can be reused from the entire codebase, making the
addition or removal of a parameter easier.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2020-04-07 14:50:19 +02:00
parent 6712958f23
commit a517ca23a0
7 changed files with 63 additions and 29 deletions

View File

@@ -234,10 +234,7 @@ fn create_app<'a, 'b>(
.arg(
Arg::with_name("restore")
.long("restore")
.help(
"Restore from a VM snapshot. \
Should be a valid URL (e.g file:///foo/bar or tcp://192.168.1.10/foo)",
)
.help(config::RestoreConfig::SYNTAX)
.takes_value(true)
.min_values(1)
.group("vmm-config"),
@@ -344,12 +341,16 @@ fn start_vmm(cmd_arguments: ArgMatches) {
)
.expect("Could not create the VM");
vmm::api::vm_boot(api_evt.try_clone().unwrap(), sender).expect("Could not boot the VM");
} else if let Some(restore_url) = cmd_arguments.value_of("restore") {
} else if let Some(restore_params) = cmd_arguments.value_of("restore") {
vmm::api::vm_restore(
api_evt.try_clone().unwrap(),
api_request_sender,
Arc::new(vmm::api::VmRestoreConfig {
source_url: restore_url.to_string(),
Arc::new(match config::RestoreConfig::parse(restore_params) {
Ok(config) => config,
Err(e) => {
println!("{}", e);
process::exit(1);
}
}),
)
.expect("Could not restore the VM");