Skip to content

Commit ca64708

Browse files
authored
xapi_vm_lifecycle: Only consult data-cant-suspend-reason and feature-suspend for live VMs (#7047)
Otherwise, a shutdown VM that had `data/cant_suspend_reason` populated during its runtime will not be migratable with `VM_NON_SUSPENDABLE` error. Additionally uses `Xapi_vm_lifecycle_helpers.is_live` (which checks for both `Paused` and `Running`) instead of a check for `Running` to determine if the VM is live. The following matrix of cases was tested: * [x] Test on migratable Windows (shouldn't block suspend) → OK * [x] Test on Windows with a non-migratable device (should block suspend as VM lacks feature) → OK * [x] Test on migratable Linux with XenServer tools (shouldn't block) → OK * [x] Test on migratable Linux with XCP-ng tools (shouldn't block) → OK * [x] Test on Linux with a non-migratable device (should block) → OK * [x] Test nopv Windows/Linux without unmigratable devices with manual `feature-suspend` xenstore entry forced (shouldn't block, should resume correctly) * [x] Windows BIOS → OK * [x] Linux BIOS → OK * [x] Test VDI migration on VM that had cant_suspend_reason populated but was shut down (shouldn't block VDI migration) → OK Fixes: c895469 ("xapi_vm_lifecycle: Disallow suspend when cant_suspend_reason is present")
2 parents fd19748 + 3d4d26b commit ca64708

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

ocaml/xapi/xapi_vm_lifecycle.ml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,10 @@ let has_definitely_booted_pv ~vmmr =
193193
* (which is advisory only) and false (more permissive) when we are potentially about
194194
* to perform an operation. This makes a difference for ops that require the guest to
195195
* react helpfully. *)
196-
let check_op_for_feature ~__context ~vmr:_ ~vmmr ~vmgmr ~power_state ~op ~ref
197-
~strict =
196+
let check_op_for_feature ~__context ~vmr:_ ~vmmr ~vmgmr ~op ~ref ~strict =
197+
let is_live = Xapi_vm_lifecycle_helpers.is_live ~__context ~self:ref in
198198
let implicit_support =
199-
power_state <> `Running
199+
(not is_live)
200200
(* PV guests offer support implicitly *)
201201
|| has_definitely_booted_pv ~vmmr
202202
|| Xapi_pv_driver_version.(has_pv_drivers (of_guest_metrics vmgmr))
@@ -205,7 +205,7 @@ let check_op_for_feature ~__context ~vmr:_ ~vmmr ~vmgmr ~power_state ~op ~ref
205205
let some_err e = Some (e, [Ref.string_of ref]) in
206206
let lack_feature feature = not (has_feature ~vmgmr ~feature) in
207207
match op with
208-
| `suspend | `checkpoint | `pool_migrate | `migrate_send -> (
208+
| (`suspend | `checkpoint | `pool_migrate | `migrate_send) when is_live -> (
209209
match get_feature ~vmgmr ~feature:"data-cant-suspend-reason" with
210210
| Some reason ->
211211
Some (Api_errors.vm_non_suspendable, [Ref.string_of ref; reason])
@@ -610,8 +610,7 @@ let check_operation_error ~__context ~ref =
610610
(* check for any HVM guest feature needed by the op *)
611611
let current_error =
612612
check current_error (fun () ->
613-
check_op_for_feature ~__context ~vmr ~vmmr ~vmgmr ~power_state ~op
614-
~ref ~strict
613+
check_op_for_feature ~__context ~vmr ~vmmr ~vmgmr ~op ~ref ~strict
615614
)
616615
in
617616
(* VSS support has been removed *)

0 commit comments

Comments
 (0)