@@ -28,6 +28,20 @@ module Rrdd = Rrd_client.Client
2828open Xenops_interface
2929open Xapi_xenops_queue
3030
31+ let check_power_state_is ~__context ~self ~expected =
32+ if expected <> `Running then
33+ Xapi_vm_lifecycle. assert_final_power_state_is ~__context ~self ~expected
34+ else
35+ (* CA-233915: only warn about unexpected power state - the check
36+ * is too naive to make it an assertion
37+ *)
38+ let actual = Db.VM. get_power_state ~__context ~self in
39+ if actual <> expected then
40+ warn " Potential problem: VM %s in power state '%s' when expecting '%s'"
41+ (Db.VM. get_uuid ~__context ~self )
42+ (Record_util. power_to_string expected)
43+ (Record_util. power_to_string actual)
44+
3145let event_wait queue_name dbg ?from p =
3246 let finished = ref false in
3347 let event_id = ref from in
@@ -2292,7 +2306,7 @@ let unpause ~__context ~self =
22922306 let module Client = (val make_client queue_name : XENOPS ) in
22932307 Client.VM. unpause dbg id |> sync_with_task __context queue_name;
22942308 Events_from_xenopsd. wait queue_name dbg id () ;
2295- Xapi_vm_lifecycle. assert_final_power_state_is ~__context ~self ~expected: `Running
2309+ check_power_state_is ~__context ~self ~expected: `Running
22962310 )
22972311
22982312let request_rdp ~__context ~self enabled =
@@ -2452,7 +2466,7 @@ let start ~__context ~self paused force =
24522466
24532467 set_resident_on ~__context ~self ;
24542468 (* set_resident_on syncs both xenopsd and with the xapi event mechanism *)
2455- Xapi_vm_lifecycle. assert_final_power_state_is ~__context ~self ~expected: (if paused then `Paused else `Running )
2469+ check_power_state_is ~__context ~self ~expected: (if paused then `Paused else `Running )
24562470 with e ->
24572471 error " Caught exception starting VM: %s" (string_of_exn e);
24582472 set_resident_on ~__context ~self ;
@@ -2499,7 +2513,7 @@ let reboot ~__context ~self timeout =
24992513 (fun () ->
25002514 Events_from_xenopsd. wait queue_name dbg id () )
25012515 in
2502- Xapi_vm_lifecycle. assert_final_power_state_is ~__context ~self ~expected: `Running
2516+ check_power_state_is ~__context ~self ~expected: `Running
25032517 )
25042518
25052519let shutdown ~__context ~self timeout =
@@ -2627,7 +2641,7 @@ let resume ~__context ~self ~start_paused ~force =
26272641 (fun rpc session_id ->
26282642 XenAPI.VDI. destroy rpc session_id vdi
26292643 );
2630- Xapi_vm_lifecycle. assert_final_power_state_is ~__context ~self ~expected: (if start_paused then `Paused else `Running )
2644+ check_power_state_is ~__context ~self ~expected: (if start_paused then `Paused else `Running )
26312645 )
26322646
26332647let s3suspend ~__context ~self =
0 commit comments