mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
ch-remote: Add support for add-vdpa
Adding the wrapping layer to be able to hotplug a vDPA device from the ch-remote tool. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
@@ -28,6 +28,7 @@ enum Error {
|
|||||||
AddPmemConfig(vmm::config::Error),
|
AddPmemConfig(vmm::config::Error),
|
||||||
AddNetConfig(vmm::config::Error),
|
AddNetConfig(vmm::config::Error),
|
||||||
AddUserDeviceConfig(vmm::config::Error),
|
AddUserDeviceConfig(vmm::config::Error),
|
||||||
|
AddVdpaConfig(vmm::config::Error),
|
||||||
AddVsockConfig(vmm::config::Error),
|
AddVsockConfig(vmm::config::Error),
|
||||||
Restore(vmm::config::Error),
|
Restore(vmm::config::Error),
|
||||||
}
|
}
|
||||||
@@ -47,6 +48,7 @@ impl fmt::Display for Error {
|
|||||||
AddPmemConfig(e) => write!(f, "Error parsing persistent memory syntax: {}", e),
|
AddPmemConfig(e) => write!(f, "Error parsing persistent memory syntax: {}", e),
|
||||||
AddNetConfig(e) => write!(f, "Error parsing network syntax: {}", e),
|
AddNetConfig(e) => write!(f, "Error parsing network syntax: {}", e),
|
||||||
AddUserDeviceConfig(e) => write!(f, "Error parsing user device syntax: {}", e),
|
AddUserDeviceConfig(e) => write!(f, "Error parsing user device syntax: {}", e),
|
||||||
|
AddVdpaConfig(e) => write!(f, "Error parsing vDPA device syntax: {}", e),
|
||||||
AddVsockConfig(e) => write!(f, "Error parsing vsock syntax: {}", e),
|
AddVsockConfig(e) => write!(f, "Error parsing vsock syntax: {}", e),
|
||||||
Restore(e) => write!(f, "Error parsing restore syntax: {}", e),
|
Restore(e) => write!(f, "Error parsing restore syntax: {}", e),
|
||||||
}
|
}
|
||||||
@@ -212,6 +214,18 @@ fn add_net_api_command(socket: &mut UnixStream, config: &str) -> Result<(), Erro
|
|||||||
.map_err(Error::ApiClient)
|
.map_err(Error::ApiClient)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn add_vdpa_api_command(socket: &mut UnixStream, config: &str) -> Result<(), Error> {
|
||||||
|
let vdpa_config = vmm::config::VdpaConfig::parse(config).map_err(Error::AddVdpaConfig)?;
|
||||||
|
|
||||||
|
simple_api_command(
|
||||||
|
socket,
|
||||||
|
"PUT",
|
||||||
|
"add-vdpa",
|
||||||
|
Some(&serde_json::to_string(&vdpa_config).unwrap()),
|
||||||
|
)
|
||||||
|
.map_err(Error::ApiClient)
|
||||||
|
}
|
||||||
|
|
||||||
fn add_vsock_api_command(socket: &mut UnixStream, config: &str) -> Result<(), Error> {
|
fn add_vsock_api_command(socket: &mut UnixStream, config: &str) -> Result<(), Error> {
|
||||||
let vsock_config = vmm::config::VsockConfig::parse(config).map_err(Error::AddVsockConfig)?;
|
let vsock_config = vmm::config::VsockConfig::parse(config).map_err(Error::AddVsockConfig)?;
|
||||||
|
|
||||||
@@ -376,6 +390,14 @@ fn do_command(matches: &ArgMatches) -> Result<(), Error> {
|
|||||||
.value_of("device_config")
|
.value_of("device_config")
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
),
|
),
|
||||||
|
Some("add-vdpa") => add_vdpa_api_command(
|
||||||
|
&mut socket,
|
||||||
|
matches
|
||||||
|
.subcommand_matches("add-vdpa")
|
||||||
|
.unwrap()
|
||||||
|
.value_of("vdpa_config")
|
||||||
|
.unwrap(),
|
||||||
|
),
|
||||||
Some("add-vsock") => add_vsock_api_command(
|
Some("add-vsock") => add_vsock_api_command(
|
||||||
&mut socket,
|
&mut socket,
|
||||||
matches
|
matches
|
||||||
@@ -486,6 +508,13 @@ fn main() {
|
|||||||
.help(vmm::config::UserDeviceConfig::SYNTAX),
|
.help(vmm::config::UserDeviceConfig::SYNTAX),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
.subcommand(
|
||||||
|
Command::new("add-vdpa").about("Add vDPA device").arg(
|
||||||
|
Arg::new("vdpa_config")
|
||||||
|
.index(1)
|
||||||
|
.help(vmm::config::VdpaConfig::SYNTAX),
|
||||||
|
),
|
||||||
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
Command::new("add-vsock").about("Add vsock device").arg(
|
Command::new("add-vsock").about("Add vsock device").arg(
|
||||||
Arg::new("vsock_config")
|
Arg::new("vsock_config")
|
||||||
|
|||||||
Reference in New Issue
Block a user