mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: api: Support multiple fds with add-net
Based on the latest code from the micro-http crate, this patch adds the support for multiple file descriptors to be sent along with the add-net request. This means we can now hotplug multiqueue network interface to the VM. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
committed by
Rob Bradford
parent
400c28fa58
commit
4e46a1bc3c
@@ -76,7 +76,7 @@ impl EndpointHandler for VmActionHandler {
|
||||
api_notifier: EventFd,
|
||||
api_sender: Sender<ApiRequest>,
|
||||
body: &Option<Body>,
|
||||
file: Option<File>,
|
||||
mut files: Vec<File>,
|
||||
) -> std::result::Result<Option<Body>, HttpError> {
|
||||
use VmAction::*;
|
||||
if let Some(body) = body {
|
||||
@@ -111,10 +111,11 @@ impl EndpointHandler for VmActionHandler {
|
||||
|
||||
AddNet(_) => {
|
||||
let mut net_cfg: NetConfig = serde_json::from_slice(body.raw())?;
|
||||
// Update network config with optional file that might have
|
||||
// Update network config with optional files that might have
|
||||
// been sent through control message.
|
||||
if let Some(file) = file {
|
||||
net_cfg.fds = Some(vec![file.into_raw_fd()]);
|
||||
if !files.is_empty() {
|
||||
let fds = files.drain(..).map(|f| f.into_raw_fd()).collect();
|
||||
net_cfg.fds = Some(fds);
|
||||
}
|
||||
vm_add_net(api_notifier, api_sender, Arc::new(net_cfg))
|
||||
.map_err(HttpError::VmAddNet)
|
||||
|
||||
Reference in New Issue
Block a user