MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / start_dbus_thread

Function start_dbus_thread

vmm/src/api/dbus/mod.rs:323–410  ·  view source on GitHub ↗
(
    dbus_options: DBusApiOptions,
    api_notifier: EventFd,
    api_sender: Sender<ApiRequest>,
    seccomp_action: &SeccompAction,
    exit_evt: EventFd,
    hypervisor_type: HypervisorType,
)

Source from the content-addressed store, hash-verified

321}
322
323pub fn start_dbus_thread(
324 dbus_options: DBusApiOptions,
325 api_notifier: EventFd,
326 api_sender: Sender<ApiRequest>,
327 seccomp_action: &SeccompAction,
328 exit_evt: EventFd,
329 hypervisor_type: HypervisorType,
330) -> VmmResult<(thread::JoinHandle<VmmResult<()>>, DBusApiShutdownChannels)> {
331 let dbus_iface = DBusApi::new(api_notifier, api_sender);
332 let (connection, iface_ref) = executor::block_on(async move {
333 let conn_builder = if dbus_options.system_bus {
334 Builder::system()?
335 } else {
336 Builder::session()?
337 };
338
339 let conn = conn_builder
340 .internal_executor(false)
341 .name(dbus_options.service_name)?
342 .serve_at(dbus_options.object_path.as_str(), dbus_iface)?
343 .build()
344 .await?;
345
346 let iface_ref = conn
347 .object_server()
348 .interface::<_, DBusApi>(dbus_options.object_path)
349 .await?;
350
351 Ok((conn, iface_ref))
352 })
353 .map_err(VmmError::CreateDBusSession)?;
354
355 let (send_shutdown, recv_shutdown) = oneshot::channel::<()>();
356 let (send_done, recv_done) = oneshot::channel::<()>();
357
358 // Retrieve seccomp filter for API thread
359 let api_seccomp_filter = get_seccomp_filter(seccomp_action, Thread::DBusApi, hypervisor_type)
360 .map_err(VmmError::CreateSeccompFilter)?;
361
362 let thread_join_handle = thread::Builder::new()
363 .name("dbus-thread".to_string())
364 .spawn(move || {
365 // Apply seccomp filter for API thread.
366 if !api_seccomp_filter.is_empty() {
367 apply_filter(&api_seccomp_filter)
368 .map_err(VmmError::ApplySeccompFilter)
369 .map_err(|e| {
370 error!("Error applying seccomp filter: {e:?}");
371 exit_evt.write(1).ok();
372 e
373 })?;
374 }
375
376 std::panic::catch_unwind(AssertUnwindSafe(move || {
377 executor::block_on(async move {
378 let recv_shutdown = recv_shutdown.fuse();
379 let executor_tick = futures::future::Fuse::terminated();
380 futures::pin_mut!(recv_shutdown, executor_tick);

Callers 1

start_vmm_threadFunction · 0.85

Calls 7

newFunction · 0.85
spawnMethod · 0.80
okMethod · 0.80
setMethod · 0.80
get_seccomp_filterFunction · 0.50
is_emptyMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected