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

@@ -26,6 +26,7 @@ enum Error {
AddDiskConfig(vmm::config::Error),
AddPmemConfig(vmm::config::Error),
AddNetConfig(vmm::config::Error),
Restore(vmm::config::Error),
}
#[derive(Clone, Copy, Debug)]
@@ -262,10 +263,8 @@ fn snapshot_api_command(socket: &mut UnixStream, url: &str) -> Result<(), Error>
)
}
fn restore_api_command(socket: &mut UnixStream, url: &str) -> Result<(), Error> {
let restore_config = vmm::api::VmRestoreConfig {
source_url: String::from(url),
};
fn restore_api_command(socket: &mut UnixStream, config: &str) -> Result<(), Error> {
let restore_config = vmm::config::RestoreConfig::parse(config).map_err(Error::Restore)?;
simple_api_command(
socket,
@@ -445,7 +444,7 @@ fn main() {
.arg(
Arg::with_name("restore_config")
.index(1)
.help("<source_url>"),
.help(vmm::config::RestoreConfig::SYNTAX),
),
);