mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
ch-remote: Add --snapshot option
Introduce the snapshot wrapper to ch-remote. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
committed by
Rob Bradford
parent
fe2d884605
commit
35c0ea6c25
@@ -249,6 +249,19 @@ fn add_net_api_command(socket: &mut UnixStream, config: &str) -> Result<(), Erro
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn snapshot_api_command(socket: &mut UnixStream, url: &str) -> Result<(), Error> {
|
||||||
|
let snapshot_config = vmm::api::VmSnapshotConfig {
|
||||||
|
destination_url: String::from(url),
|
||||||
|
};
|
||||||
|
|
||||||
|
simple_api_command(
|
||||||
|
socket,
|
||||||
|
"PUT",
|
||||||
|
"snapshot",
|
||||||
|
Some(&serde_json::to_string(&snapshot_config).unwrap()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fn do_command(matches: &ArgMatches) -> Result<(), Error> {
|
fn do_command(matches: &ArgMatches) -> Result<(), Error> {
|
||||||
let mut socket =
|
let mut socket =
|
||||||
UnixStream::connect(matches.value_of("api-socket").unwrap()).map_err(Error::Socket)?;
|
UnixStream::connect(matches.value_of("api-socket").unwrap()).map_err(Error::Socket)?;
|
||||||
@@ -306,6 +319,14 @@ fn do_command(matches: &ArgMatches) -> Result<(), Error> {
|
|||||||
.value_of("net_config")
|
.value_of("net_config")
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
),
|
),
|
||||||
|
Some("snapshot") => snapshot_api_command(
|
||||||
|
&mut socket,
|
||||||
|
matches
|
||||||
|
.subcommand_matches("snapshot")
|
||||||
|
.unwrap()
|
||||||
|
.value_of("snapshot_config")
|
||||||
|
.unwrap(),
|
||||||
|
),
|
||||||
Some(c) => simple_api_command(&mut socket, "PUT", c, None),
|
Some(c) => simple_api_command(&mut socket, "PUT", c, None),
|
||||||
None => unreachable!(),
|
None => unreachable!(),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user