mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-02 11:35:46 +00:00
vmm: http: Error out earlier if we can't create API server
This removes a panic inside the API thread. Fixes: #2395 Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
78f9ddc6be
commit
9440304183
@ -261,6 +261,7 @@ pub fn start_http_thread(
|
|||||||
) -> Result<thread::JoinHandle<Result<()>>> {
|
) -> Result<thread::JoinHandle<Result<()>>> {
|
||||||
std::fs::remove_file(path).unwrap_or_default();
|
std::fs::remove_file(path).unwrap_or_default();
|
||||||
let socket_path = PathBuf::from(path);
|
let socket_path = PathBuf::from(path);
|
||||||
|
let mut server = HttpServer::new(socket_path).map_err(Error::CreatingAPIServer)?;
|
||||||
|
|
||||||
// Retrieve seccomp filter for API thread
|
// Retrieve seccomp filter for API thread
|
||||||
let api_seccomp_filter =
|
let api_seccomp_filter =
|
||||||
@ -272,7 +273,6 @@ pub fn start_http_thread(
|
|||||||
// Apply seccomp filter for API thread.
|
// Apply seccomp filter for API thread.
|
||||||
SeccompFilter::apply(api_seccomp_filter).map_err(Error::ApplySeccompFilter)?;
|
SeccompFilter::apply(api_seccomp_filter).map_err(Error::ApplySeccompFilter)?;
|
||||||
|
|
||||||
let mut server = HttpServer::new(socket_path).unwrap();
|
|
||||||
server.start_server().unwrap();
|
server.start_server().unwrap();
|
||||||
loop {
|
loop {
|
||||||
match server.requests() {
|
match server.requests() {
|
||||||
|
@ -140,6 +140,10 @@ pub enum Error {
|
|||||||
/// Error activating virtio devices
|
/// Error activating virtio devices
|
||||||
#[error("Error activating virtio devices: {0:?}")]
|
#[error("Error activating virtio devices: {0:?}")]
|
||||||
ActivateVirtioDevices(VmError),
|
ActivateVirtioDevices(VmError),
|
||||||
|
|
||||||
|
/// Error creating API server
|
||||||
|
#[error("Error creating API server {0:?}")]
|
||||||
|
CreatingAPIServer(micro_http::ServerError),
|
||||||
}
|
}
|
||||||
pub type Result<T> = result::Result<T, Error>;
|
pub type Result<T> = result::Result<T, Error>;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user