mirror of
https://github.com/mirage/qubes-mirage-firewall.git
synced 2025-01-30 08:03:32 -05:00
Don't wait for GUI before attaching client VMs
If the firewall is restarted while AppVMs are connected, qubesd tries to reconnect them before starting the GUI agent. However, the firewall was waiting for the GUI agent to connect before handling the connections. This led to a 10s delay on restart for each client VM. Reported by xaki23.
This commit is contained in:
parent
b123abb1d3
commit
d849a09a25
13
unikernel.ml
13
unikernel.ml
@ -38,7 +38,11 @@ module Main (Clock : Mirage_clock_lwt.MCLOCK) = struct
|
|||||||
let watch_gui gui =
|
let watch_gui gui =
|
||||||
Lwt.async (fun () ->
|
Lwt.async (fun () ->
|
||||||
Lwt.try_bind
|
Lwt.try_bind
|
||||||
(fun () -> GUI.listen gui)
|
(fun () ->
|
||||||
|
gui >>= fun gui ->
|
||||||
|
Log.info (fun f -> f "GUI agent connected");
|
||||||
|
GUI.listen gui
|
||||||
|
)
|
||||||
(fun `Cant_happen -> assert false)
|
(fun `Cant_happen -> assert false)
|
||||||
(fun ex ->
|
(fun ex ->
|
||||||
Log.warn (fun f -> f "GUI thread failed: %s" (Printexc.to_string ex));
|
Log.warn (fun f -> f "GUI thread failed: %s" (Printexc.to_string ex));
|
||||||
@ -51,21 +55,18 @@ module Main (Clock : Mirage_clock_lwt.MCLOCK) = struct
|
|||||||
let start_time = Clock.elapsed_ns clock in
|
let start_time = Clock.elapsed_ns clock in
|
||||||
(* Start qrexec agent, GUI agent and QubesDB agent in parallel *)
|
(* Start qrexec agent, GUI agent and QubesDB agent in parallel *)
|
||||||
let qrexec = RExec.connect ~domid:0 () in
|
let qrexec = RExec.connect ~domid:0 () in
|
||||||
let gui = GUI.connect ~domid:0 () in
|
GUI.connect ~domid:0 () |> watch_gui;
|
||||||
let qubesDB = DB.connect ~domid:0 () in
|
let qubesDB = DB.connect ~domid:0 () in
|
||||||
(* Wait for clients to connect *)
|
(* Wait for clients to connect *)
|
||||||
qrexec >>= fun qrexec ->
|
qrexec >>= fun qrexec ->
|
||||||
let agent_listener = RExec.listen qrexec Command.handler in
|
let agent_listener = RExec.listen qrexec Command.handler in
|
||||||
gui >>= fun gui ->
|
|
||||||
watch_gui gui;
|
|
||||||
qubesDB >>= fun qubesDB ->
|
qubesDB >>= fun qubesDB ->
|
||||||
let startup_time =
|
let startup_time =
|
||||||
let (-) = Int64.sub in
|
let (-) = Int64.sub in
|
||||||
let time_in_ns = Clock.elapsed_ns clock - start_time in
|
let time_in_ns = Clock.elapsed_ns clock - start_time in
|
||||||
Int64.to_float time_in_ns /. 1e9
|
Int64.to_float time_in_ns /. 1e9
|
||||||
in
|
in
|
||||||
Log.info (fun f -> f "Qubes agents connected in %.3f s (CPU time used since boot: %.3f s)"
|
Log.info (fun f -> f "QubesDB and qrexec agents connected in %.3f s" startup_time);
|
||||||
startup_time (Sys.time ()));
|
|
||||||
(* Watch for shutdown requests from Qubes *)
|
(* Watch for shutdown requests from Qubes *)
|
||||||
let shutdown_rq =
|
let shutdown_rq =
|
||||||
OS.Lifecycle.await_shutdown_request () >>= fun (`Poweroff | `Reboot) ->
|
OS.Lifecycle.await_shutdown_request () >>= fun (`Poweroff | `Reboot) ->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user