mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: http: graceful shutdown of the http api thread
This commit ensures that the HttpApi thread flushes all the responses before the application shuts down. Without this step, in case of a VmmShutdown request the application might terminate before the thread sends a response. Fixes: #6247 Signed-off-by: Alexandru Matei <alexandru.matei@uipath.com>
This commit is contained in:
committed by
Rob Bradford
parent
3f2ca5375e
commit
1091494320
@@ -20,6 +20,7 @@ use std::sync::{Arc, Mutex};
|
||||
use thiserror::Error;
|
||||
#[cfg(feature = "dbus_api")]
|
||||
use vmm::api::dbus::{dbus_api_graceful_shutdown, DBusApiOptions};
|
||||
use vmm::api::http::http_api_graceful_shutdown;
|
||||
use vmm::api::ApiAction;
|
||||
use vmm::config;
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
@@ -82,6 +83,8 @@ enum Error {
|
||||
LogFileCreation(std::io::Error),
|
||||
#[error("Error setting up logger: {0}")]
|
||||
LoggerSetup(log::SetLoggerError),
|
||||
#[error("Failed to gracefully shutdown http api: {0}")]
|
||||
HttpApiShutdown(#[source] vmm::Error),
|
||||
}
|
||||
|
||||
struct Logger {
|
||||
@@ -760,6 +763,10 @@ fn start_vmm(cmd_arguments: ArgMatches) -> Result<Option<String>, Error> {
|
||||
.map_err(Error::ThreadJoin)?
|
||||
.map_err(Error::VmmThread)?;
|
||||
|
||||
if let Some(api_handle) = vmm_thread_handle.http_api_handle {
|
||||
http_api_graceful_shutdown(api_handle).map_err(Error::HttpApiShutdown)?
|
||||
}
|
||||
|
||||
#[cfg(feature = "dbus_api")]
|
||||
if let Some(chs) = vmm_thread_handle.dbus_shutdown_chs {
|
||||
dbus_api_graceful_shutdown(chs);
|
||||
|
||||
Reference in New Issue
Block a user