main: Support VM restore from the command line

Through the new CLI --restore option.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
Samuel Ortiz 2020-02-26 01:01:05 +01:00 committed by Rob Bradford
parent 8f300bed83
commit fe2d884605

View File

@ -231,6 +231,17 @@ fn create_app<'a, 'b>(
.default_value(&api_server_path)
.group("vmm-config"),
)
.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)",
)
.takes_value(true)
.min_values(1)
.group("vmm-config"),
)
.arg(
Arg::with_name("net-backend")
.long("net-backend")
@ -333,6 +344,15 @@ 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-from") {
vmm::api::vm_restore(
api_evt.try_clone().unwrap(),
api_request_sender,
Arc::new(vmm::api::VmRestoreConfig {
source_url: restore_url.to_string(),
}),
)
.expect("Could not restore the VM");
}
match vmm_thread.join() {