From 3d2c7f7d23909c9f49d4de9202c62ac440b559f7 Mon Sep 17 00:00:00 2001 From: Tomasz Wroblewski Date: Tue, 5 Jan 2010 14:36:30 +0000 Subject: [PATCH] Emit a notification when VM wakes from S3 --- xenvm/xenvm.ml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/xenvm/xenvm.ml b/xenvm/xenvm.ml index 694a207..f8766cb 100644 --- a/xenvm/xenvm.ml +++ b/xenvm/xenvm.ml @@ -251,6 +251,29 @@ let reread_config state path = let cfg = Config.of_file state.vm_uuid (fun errors -> ()) path in state.vm_next_cfg <- Some cfg +(* Monitor acpi state and notify when it changes from S3 to S0. + * Other cases are already signalled from qemu *) +let monitor_acpi state = + let rec poll acpi_state = + let s' = match state.vm_lifestate with + | VmShutdown -> 5 + | _ -> + with_xc (fun xc -> + let s' = Xc.domain_get_acpi_s_state xc state.vm_domid in + match (acpi_state,s') with + | (3,0) -> + Vmact.notify state Xenvmlib.code_vmtrigger [ "power-state"; "0" ]; + s' + | _ -> s' + ) + in + Thread.delay 1.; + poll s' + in + if state.vm_cfg.hvm then ( + poll 0 + ) + let monitor_vm state = let xs = Xs.daemon_open () in let callback_introduce ctx id = @@ -385,7 +408,6 @@ let monitor_vm state = | _ -> () ) in - while true do try Xal.loop ~callback_introduce ~callback_release ~callback_devices @@ -812,6 +834,7 @@ let monitor_rpc_dbus state = *) let monitor socket state = thread_create monitor_vm state; + thread_create monitor_acpi state; if state.vm_monitors.monitor_use_json then thread_create (monitor_rpc_json socket) state; if state.vm_monitors.monitor_use_dbus then -- 2.39.5