mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-07-16 06:07:15 +00:00
bin: ch-remote: Add support for receive/send migration commands
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
7ac764518c
commit
523029449e
@ -230,6 +230,32 @@ fn restore_api_command(socket: &mut UnixStream, config: &str) -> Result<(), Erro
|
|||||||
.map_err(Error::ApiClient)
|
.map_err(Error::ApiClient)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn receive_migration_api_command(socket: &mut UnixStream, url: &str) -> Result<(), Error> {
|
||||||
|
let receive_migration_data = vmm::api::VmReceiveMigrationData {
|
||||||
|
receiver_url: url.to_owned(),
|
||||||
|
};
|
||||||
|
simple_api_command(
|
||||||
|
socket,
|
||||||
|
"PUT",
|
||||||
|
"receive-migration",
|
||||||
|
Some(&serde_json::to_string(&receive_migration_data).unwrap()),
|
||||||
|
)
|
||||||
|
.map_err(Error::ApiClient)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn send_migration_api_command(socket: &mut UnixStream, url: &str) -> Result<(), Error> {
|
||||||
|
let send_migration_data = vmm::api::VmSendMigrationData {
|
||||||
|
destination_url: url.to_owned(),
|
||||||
|
};
|
||||||
|
simple_api_command(
|
||||||
|
socket,
|
||||||
|
"PUT",
|
||||||
|
"send-migration",
|
||||||
|
Some(&serde_json::to_string(&send_migration_data).unwrap()),
|
||||||
|
)
|
||||||
|
.map_err(Error::ApiClient)
|
||||||
|
}
|
||||||
|
|
||||||
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::Connect)?;
|
UnixStream::connect(matches.value_of("api-socket").unwrap()).map_err(Error::Connect)?;
|
||||||
@ -341,6 +367,22 @@ fn do_command(matches: &ArgMatches) -> Result<(), Error> {
|
|||||||
.value_of("restore_config")
|
.value_of("restore_config")
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
),
|
),
|
||||||
|
Some("send-migration") => send_migration_api_command(
|
||||||
|
&mut socket,
|
||||||
|
matches
|
||||||
|
.subcommand_matches("send-migration")
|
||||||
|
.unwrap()
|
||||||
|
.value_of("send_migration_config")
|
||||||
|
.unwrap(),
|
||||||
|
),
|
||||||
|
Some("receive-migration") => receive_migration_api_command(
|
||||||
|
&mut socket,
|
||||||
|
matches
|
||||||
|
.subcommand_matches("receive-migration")
|
||||||
|
.unwrap()
|
||||||
|
.value_of("receive_migration_config")
|
||||||
|
.unwrap(),
|
||||||
|
),
|
||||||
Some(c) => simple_api_command(&mut socket, "PUT", c, None).map_err(Error::ApiClient),
|
Some(c) => simple_api_command(&mut socket, "PUT", c, None).map_err(Error::ApiClient),
|
||||||
None => unreachable!(),
|
None => unreachable!(),
|
||||||
}
|
}
|
||||||
@ -484,6 +526,24 @@ fn main() {
|
|||||||
.index(1)
|
.index(1)
|
||||||
.help(vmm::config::RestoreConfig::SYNTAX),
|
.help(vmm::config::RestoreConfig::SYNTAX),
|
||||||
),
|
),
|
||||||
|
)
|
||||||
|
.subcommand(
|
||||||
|
SubCommand::with_name("send-migration")
|
||||||
|
.about("Initiate a VM migration")
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("send_migration_config")
|
||||||
|
.index(1)
|
||||||
|
.help("<destination_url>"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.subcommand(
|
||||||
|
SubCommand::with_name("receive-migration")
|
||||||
|
.about("Receive a VM migration")
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("receive_migration_config")
|
||||||
|
.index(1)
|
||||||
|
.help("<receiver_url>"),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
let matches = app.get_matches();
|
let matches = app.get_matches();
|
||||||
|
Loading…
Reference in New Issue
Block a user