mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-22 04:25:21 +00:00
ch-remote: Allow file descriptors to be sent along with add-net
Enable specifically for the add-net command the ability to send file descriptors along with the HTTP request. This is useful to hotplug a macvtap interface after the VMM has already been started. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
9af2968a7d
commit
da4cde70c3
@ -7,6 +7,7 @@
|
|||||||
extern crate clap;
|
extern crate clap;
|
||||||
|
|
||||||
use api_client::simple_api_command;
|
use api_client::simple_api_command;
|
||||||
|
use api_client::simple_api_command_with_fds;
|
||||||
use api_client::Error as ApiClientError;
|
use api_client::Error as ApiClientError;
|
||||||
use clap::{App, AppSettings, Arg, ArgMatches, SubCommand};
|
use clap::{App, AppSettings, Arg, ArgMatches, SubCommand};
|
||||||
use option_parser::{ByteSized, ByteSizedParseError};
|
use option_parser::{ByteSized, ByteSizedParseError};
|
||||||
@ -178,13 +179,20 @@ fn add_pmem_api_command(socket: &mut UnixStream, config: &str) -> Result<(), Err
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn add_net_api_command(socket: &mut UnixStream, config: &str) -> Result<(), Error> {
|
fn add_net_api_command(socket: &mut UnixStream, config: &str) -> Result<(), Error> {
|
||||||
let net_config = vmm::config::NetConfig::parse(config).map_err(Error::AddNetConfig)?;
|
let mut net_config = vmm::config::NetConfig::parse(config).map_err(Error::AddNetConfig)?;
|
||||||
|
|
||||||
simple_api_command(
|
// NetConfig is modified on purpose here by taking the list of file
|
||||||
|
// descriptors out. Keeping the list and send it to the server side
|
||||||
|
// process would not make any sense since the file descriptor may be
|
||||||
|
// represented with different values.
|
||||||
|
let fds = net_config.fds.take().unwrap_or_default();
|
||||||
|
|
||||||
|
simple_api_command_with_fds(
|
||||||
socket,
|
socket,
|
||||||
"PUT",
|
"PUT",
|
||||||
"add-net",
|
"add-net",
|
||||||
Some(&serde_json::to_string(&net_config).unwrap()),
|
Some(&serde_json::to_string(&net_config).unwrap()),
|
||||||
|
fds,
|
||||||
)
|
)
|
||||||
.map_err(Error::ApiClient)
|
.map_err(Error::ApiClient)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user