main: Enable the api-socket to be passed as an fd

To avoid race issues where the api-socket may not be created by the
time a cloud-hypervisor caller is ready to look for it, enable the
caller to pass the api-socket fd directly.

Avoid breaking current callers by allowing the --api-socket path to be
passed as it is now in addition to through the path argument.

Signed-off-by: William Douglas <william.r.douglas@gmail.com>
This commit is contained in:
William Douglas
2021-04-09 23:46:55 +00:00
parent 375382cb08
commit 767b4f0e59
4 changed files with 75 additions and 22 deletions
+6 -2
View File
@@ -247,9 +247,11 @@ impl Serialize for PciDeviceInfo {
}
}
#[allow(clippy::too_many_arguments)]
pub fn start_vmm_thread(
vmm_version: String,
http_path: &Option<String>,
http_fd: Option<RawFd>,
api_event: EventFd,
api_sender: Sender<ApiRequest>,
api_receiver: Receiver<ApiRequest>,
@@ -280,9 +282,11 @@ pub fn start_vmm_thread(
})
.map_err(Error::VmmThreadSpawn)?;
// The VMM thread is started, we can start serving HTTP requests
if let Some(http_path) = http_path {
// The VMM thread is started, we can start serving HTTP requests
api::start_http_thread(http_path, http_api_event, api_sender, seccomp_action)?;
api::start_http_path_thread(http_path, http_api_event, api_sender, seccomp_action)?;
} else if let Some(http_fd) = http_fd {
api::start_http_fd_thread(http_fd, http_api_event, api_sender, seccomp_action)?;
}
Ok(thread)
}