mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
main: cli: add D-Bus API related CLI options
Introduces three new CLI options, `dbus-service-name`, `dbus-object-path` and `dbus-system-bus` to configure the DBus API. Signed-off-by: Omer Faruk Bayram <omer.faruk@sartura.hr>
This commit is contained in:
committed by
Bo Chen
parent
a92d852848
commit
7a458d85d1
@@ -20,6 +20,12 @@ use zbus::{dbus_interface, ConnectionBuilder};
|
||||
|
||||
pub type DBusApiShutdownChannels = (oneshot::Sender<()>, oneshot::Receiver<()>);
|
||||
|
||||
pub struct DBusApiOptions {
|
||||
pub service_name: String,
|
||||
pub object_path: String,
|
||||
pub system_bus: bool,
|
||||
}
|
||||
|
||||
pub struct DBusApi {
|
||||
api_notifier: EventFd,
|
||||
api_sender: futures::lock::Mutex<Sender<ApiRequest>>,
|
||||
@@ -278,8 +284,8 @@ impl DBusApi {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: add command line arguments to make this configurable
|
||||
pub fn start_dbus_thread(
|
||||
dbus_options: DBusApiOptions,
|
||||
api_notifier: EventFd,
|
||||
api_sender: Sender<ApiRequest>,
|
||||
seccomp_action: &SeccompAction,
|
||||
@@ -288,10 +294,16 @@ pub fn start_dbus_thread(
|
||||
) -> VmmResult<(thread::JoinHandle<VmmResult<()>>, DBusApiShutdownChannels)> {
|
||||
let dbus_iface = DBusApi::new(api_notifier, api_sender);
|
||||
let connection = executor::block_on(async move {
|
||||
ConnectionBuilder::session()?
|
||||
let conn_builder = if dbus_options.system_bus {
|
||||
ConnectionBuilder::system()?
|
||||
} else {
|
||||
ConnectionBuilder::session()?
|
||||
};
|
||||
|
||||
conn_builder
|
||||
.internal_executor(false)
|
||||
.name("org.cloudhypervisor.DBusApi")?
|
||||
.serve_at("/org/cloudhypervisor/DBusApi", dbus_iface)?
|
||||
.name(dbus_options.service_name)?
|
||||
.serve_at(dbus_options.object_path, dbus_iface)?
|
||||
.build()
|
||||
.await
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user