mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: dbus: graceful shutdown of the DBusApi thread
This commit adds support for graceful shutdown of the DBusApi thread using `futures::channel::oneshot` channels. By using oneshot channels, we ensure that the thread has enough time to send a response to the `VmmShutdown` method call before it is terminated. Without this step, the thread may be terminated before it can send a response, resulting in an error message on the client side stating that the message recipient disconnected from the message bus without providing a reply. Also changes the default values for DBus service name, object path and interface name. Signed-off-by: Omer Faruk Bayram <omer.faruk@sartura.hr>
This commit is contained in:
committed by
Bo Chen
parent
c016a0d4d3
commit
f00df25d40
10
src/main.rs
10
src/main.rs
@@ -18,6 +18,8 @@ use std::os::unix::io::{FromRawFd, RawFd};
|
||||
use std::sync::mpsc::channel;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use thiserror::Error;
|
||||
#[cfg(feature = "dbus_api")]
|
||||
use vmm::api::dbus::dbus_api_graceful_shutdown;
|
||||
use vmm::config;
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
use vmm_sys_util::signal::block_signal;
|
||||
@@ -513,7 +515,7 @@ fn start_vmm(toplevel: TopLevel) -> Result<Option<String>, Error> {
|
||||
|
||||
let exit_evt = EventFd::new(EFD_NONBLOCK).map_err(Error::CreateExitEventFd)?;
|
||||
|
||||
let vmm_thread = vmm::start_vmm_thread(
|
||||
let vmm_thread_handle = vmm::start_vmm_thread(
|
||||
vmm::VmmVersionInfo::new(env!("BUILD_VERSION"), env!("CARGO_PKG_VERSION")),
|
||||
&api_socket_path,
|
||||
api_socket_fd,
|
||||
@@ -568,11 +570,15 @@ fn start_vmm(toplevel: TopLevel) -> Result<Option<String>, Error> {
|
||||
}
|
||||
}
|
||||
|
||||
vmm_thread
|
||||
vmm_thread_handle
|
||||
.thread_handle
|
||||
.join()
|
||||
.map_err(Error::ThreadJoin)?
|
||||
.map_err(Error::VmmThread)?;
|
||||
|
||||
#[cfg(feature = "dbus_api")]
|
||||
dbus_api_graceful_shutdown(vmm_thread_handle.dbus_shutdown_chs);
|
||||
|
||||
r.map(|_| api_socket_path)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user