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
+15
-3
@@ -25,6 +25,8 @@ use crate::migration::{recv_vm_config, recv_vm_state};
|
||||
use crate::seccomp_filters::{get_seccomp_filter, Thread};
|
||||
use crate::vm::{Error as VmError, Vm, VmState};
|
||||
use anyhow::anyhow;
|
||||
#[cfg(feature = "dbus_api")]
|
||||
use api::dbus::DBusApiShutdownChannels;
|
||||
use libc::{tcsetattr, termios, EFD_NONBLOCK, SIGINT, SIGTERM, TCSANOW};
|
||||
use memory_manager::MemoryManagerSnapshotData;
|
||||
use pci::PciBdf;
|
||||
@@ -301,7 +303,7 @@ pub fn start_vmm_thread(
|
||||
exit_event: EventFd,
|
||||
seccomp_action: &SeccompAction,
|
||||
hypervisor: Arc<dyn hypervisor::Hypervisor>,
|
||||
) -> Result<thread::JoinHandle<Result<()>>> {
|
||||
) -> Result<VmmThreadHandle> {
|
||||
#[cfg(feature = "guest_debug")]
|
||||
let gdb_hw_breakpoints = hypervisor.get_guest_debug_hw_bps();
|
||||
#[cfg(feature = "guest_debug")]
|
||||
@@ -355,7 +357,7 @@ pub fn start_vmm_thread(
|
||||
// The VMM thread is started, we can start the dbus thread
|
||||
// and start serving HTTP requests
|
||||
#[cfg(feature = "dbus_api")]
|
||||
api::start_dbus_thread(
|
||||
let (_, dbus_shutdown_chs) = api::start_dbus_thread(
|
||||
api_event_clone.try_clone().map_err(Error::EventFdClone)?,
|
||||
api_sender.clone(),
|
||||
seccomp_action,
|
||||
@@ -397,7 +399,11 @@ pub fn start_vmm_thread(
|
||||
.map_err(Error::GdbThreadSpawn)?;
|
||||
}
|
||||
|
||||
Ok(thread)
|
||||
Ok(VmmThreadHandle {
|
||||
thread_handle: thread,
|
||||
#[cfg(feature = "dbus_api")]
|
||||
dbus_shutdown_chs,
|
||||
})
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
@@ -423,6 +429,12 @@ impl VmmVersionInfo {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct VmmThreadHandle {
|
||||
pub thread_handle: thread::JoinHandle<Result<()>>,
|
||||
#[cfg(feature = "dbus_api")]
|
||||
pub dbus_shutdown_chs: DBusApiShutdownChannels,
|
||||
}
|
||||
|
||||
pub struct Vmm {
|
||||
epoll: EpollContext,
|
||||
exit_evt: EventFd,
|
||||
|
||||
Reference in New Issue
Block a user