]> xenbits.xen.org Git - xenclient/toolstack.git/commitdiff
Emit a notification when VM wakes from S3
authorTomasz Wroblewski <tomasz.wroblewski@citrix.com>
Tue, 5 Jan 2010 14:36:30 +0000 (14:36 +0000)
committerTomasz Wroblewski <tomasz.wroblewski@citrix.com>
Tue, 5 Jan 2010 14:36:57 +0000 (14:36 +0000)
xenvm/xenvm.ml

index 694a207e56ec1bd396be1f4d63cbc4ad08ed9896..f8766cb40671f9848c716a9e9549fa9675f5f746 100644 (file)
@@ -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