mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 21:55:20 +00:00
ch-remote: Add support for hotplugging persistent memory
Call the new HTTP API for hotplugging persistent memory using the same syntax as coldplug. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
44aef8f438
commit
0b0510108d
@ -24,6 +24,7 @@ enum Error {
|
|||||||
InvalidMemorySize(std::num::ParseIntError),
|
InvalidMemorySize(std::num::ParseIntError),
|
||||||
AddDeviceConfig(vmm::config::Error),
|
AddDeviceConfig(vmm::config::Error),
|
||||||
AddDiskConfig(vmm::config::Error),
|
AddDiskConfig(vmm::config::Error),
|
||||||
|
AddPmemConfig(vmm::config::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
@ -225,6 +226,17 @@ fn add_disk_api_command(socket: &mut UnixStream, config: &str) -> Result<(), Err
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn add_pmem_api_command(socket: &mut UnixStream, config: &str) -> Result<(), Error> {
|
||||||
|
let pmem_config = vmm::config::PmemConfig::parse(config).map_err(Error::AddPmemConfig)?;
|
||||||
|
|
||||||
|
simple_api_command(
|
||||||
|
socket,
|
||||||
|
"PUT",
|
||||||
|
"add-pmem",
|
||||||
|
Some(&serde_json::to_string(&pmem_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)?;
|
||||||
@ -266,6 +278,14 @@ fn do_command(matches: &ArgMatches) -> Result<(), Error> {
|
|||||||
.value_of("disk_config")
|
.value_of("disk_config")
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
),
|
),
|
||||||
|
Some("add-pmem") => add_pmem_api_command(
|
||||||
|
&mut socket,
|
||||||
|
matches
|
||||||
|
.subcommand_matches("add-pmem")
|
||||||
|
.unwrap()
|
||||||
|
.value_of("pmem_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!(),
|
||||||
}
|
}
|
||||||
@ -302,6 +322,15 @@ fn main() {
|
|||||||
.help(vmm::config::DiskConfig::SYNTAX),
|
.help(vmm::config::DiskConfig::SYNTAX),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
.subcommand(
|
||||||
|
SubCommand::with_name("add-pmem")
|
||||||
|
.about("Add persistent memory device")
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("pmem_config")
|
||||||
|
.index(1)
|
||||||
|
.help(vmm::config::PmemConfig::SYNTAX),
|
||||||
|
),
|
||||||
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
SubCommand::with_name("remove-device")
|
SubCommand::with_name("remove-device")
|
||||||
.about("Remove VFIO device")
|
.about("Remove VFIO device")
|
||||||
|
Loading…
Reference in New Issue
Block a user