mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-22 11:22:26 +00:00
vmm: Create the api socket fd to pass to the http server
Instead of using the http server's method to have it create the fd (causing the http thread to need to support the socket, bind and listen syscalls). Create the socket fd in the vmm thread and use the http server's new method supporting passing in this fd for the api socket. Signed-off-by: William Douglas <william.douglas@intel.com>
This commit is contained in:
parent
51a93bc635
commit
b8779ddc9e
@ -11,7 +11,8 @@ use micro_http::{Body, HttpServer, MediaType, Method, Request, Response, StatusC
|
||||
use seccomp::{SeccompAction, SeccompFilter};
|
||||
use serde_json::Error as SerdeError;
|
||||
use std::collections::HashMap;
|
||||
use std::os::unix::io::RawFd;
|
||||
use std::os::unix::io::{IntoRawFd, RawFd};
|
||||
use std::os::unix::net::UnixListener;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::mpsc::Sender;
|
||||
use std::sync::Arc;
|
||||
@ -305,7 +306,9 @@ pub fn start_http_path_thread(
|
||||
) -> Result<thread::JoinHandle<Result<()>>> {
|
||||
std::fs::remove_file(path).unwrap_or_default();
|
||||
let socket_path = PathBuf::from(path);
|
||||
let server = HttpServer::new(socket_path).map_err(Error::CreateApiServer)?;
|
||||
let socket_fd = UnixListener::bind(socket_path).map_err(Error::CreateApiServerSocket)?;
|
||||
let server =
|
||||
HttpServer::new_from_fd(socket_fd.into_raw_fd()).map_err(Error::CreateApiServer)?;
|
||||
start_http_thread(server, api_notifier, api_sender, seccomp_action)
|
||||
}
|
||||
|
||||
|
@ -144,6 +144,10 @@ pub enum Error {
|
||||
/// Error creating API server
|
||||
#[error("Error creating API server {0:?}")]
|
||||
CreateApiServer(micro_http::ServerError),
|
||||
|
||||
/// Error binding API server socket
|
||||
#[error("Error creation API server's socket {0:?}")]
|
||||
CreateApiServerSocket(#[source] io::Error),
|
||||
}
|
||||
pub type Result<T> = result::Result<T, Error>;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user