ch-remote: Add --restore option

Introduce restore wrapper to ch-remote.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2020-04-02 11:20:02 +02:00 committed by Rob Bradford
parent 35c0ea6c25
commit 859a96181f

View File

@ -262,6 +262,19 @@ 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),
};
simple_api_command(
socket,
"PUT",
"restore",
Some(&serde_json::to_string(&restore_config).unwrap()),
)
}
fn do_command(matches: &ArgMatches) -> Result<(), Error> {
let mut socket =
UnixStream::connect(matches.value_of("api-socket").unwrap()).map_err(Error::Socket)?;
@ -327,6 +340,14 @@ fn do_command(matches: &ArgMatches) -> Result<(), Error> {
.value_of("snapshot_config")
.unwrap(),
),
Some("restore") => restore_api_command(
&mut socket,
matches
.subcommand_matches("restore")
.unwrap()
.value_of("restore_config")
.unwrap(),
),
Some(c) => simple_api_command(&mut socket, "PUT", c, None),
None => unreachable!(),
}