Skip to content

Commit ca5110c

Browse files
committed
CA-202419: Plumb 'strict' flag down to HVM feature check
Signed-off-by: Euan Harris <[email protected]>
1 parent ce0a39d commit ca5110c

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

ocaml/xapi/export.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ open Client
417417

418418
let lock_vm ~__context ~vm ~task_id op =
419419
(* Note slight race here because we haven't got the master lock *)
420-
Xapi_vm_lifecycle.assert_operation_valid ~__context ~self:vm ~op;
420+
Xapi_vm_lifecycle.assert_operation_valid ~__context ~self:vm ~op ~strict:true;
421421
(* ... small race lives here ... *)
422422
Db.VM.add_to_current_operations ~__context ~self:vm ~key:task_id ~value:op;
423423
Xapi_vm_lifecycle.update_allowed_operations ~__context ~self:vm

ocaml/xapi/message_forwarding.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1583,7 +1583,7 @@ module Forward = functor(Local: Custom_actions.CUSTOM_ACTIONS) -> struct
15831583
let force = try bool_of_string (List.assoc "force" options) with _ -> false in
15841584
if not force then Cpuid_helpers.assert_vm_is_compatible ~__context ~vm ~host ();
15851585

1586-
with_vm_operation ~__context ~self:vm ~doc:"VM.pool_migrate" ~op:`pool_migrate
1586+
with_vm_operation ~__context ~self:vm ~doc:"VM.pool_migrate" ~op:`pool_migrate ~strict:(not force)
15871587
(fun () ->
15881588
(* Make sure the target has enough memory to receive the VM *)
15891589
let snapshot = Helpers.get_boot_record ~__context ~self:vm in

ocaml/xapi/xapi_vm.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ open D
3434

3535
exception InvalidOperation of string
3636

37-
let assert_operation_valid = Xapi_vm_lifecycle.assert_operation_valid
37+
let assert_operation_valid = Xapi_vm_lifecycle.assert_operation_valid ~strict:true
3838

3939
let update_allowed_operations ~__context ~self =
4040
Helpers.log_exn_continue "updating allowed operations of VBDs/VIFs/VDIs in VM.update_allowed_operations"

ocaml/xapi/xapi_vm_helpers.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,11 +983,11 @@ let vm_fresh_genid ~__context ~self =
983983

984984
(** Add to the VM's current operations, call a function and then remove from the
985985
current operations. Ensure the allowed_operations are kept up to date. *)
986-
let with_vm_operation ~__context ~self ~doc ~op ?policy f =
986+
let with_vm_operation ~__context ~self ~doc ~op ?(strict=true) ?policy f =
987987
let task_id = Ref.string_of (Context.get_task_id __context) in
988988
Helpers.retry_with_global_lock ~__context ~doc ?policy
989989
(fun () ->
990-
Xapi_vm_lifecycle.assert_operation_valid ~__context ~self ~op;
990+
Xapi_vm_lifecycle.assert_operation_valid ~__context ~self ~op ~strict;
991991
Db.VM.add_to_current_operations ~__context ~self ~key:task_id ~value:op;
992992
Xapi_vm_lifecycle.update_allowed_operations ~__context ~self);
993993
(* Then do the action with the lock released *)

ocaml/xapi/xapi_vm_lifecycle.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,8 @@ let get_operation_error ~__context ~self ~op ~strict =
412412
let all, gm, clone_suspended_vm_enabled, vdis_reset_and_caching = get_info ~__context ~self in
413413
check_operation_error __context all gm self clone_suspended_vm_enabled vdis_reset_and_caching op strict
414414

415-
let assert_operation_valid ~__context ~self ~op =
416-
match get_operation_error ~__context ~self ~op ~strict:true with
415+
let assert_operation_valid ~__context ~self ~op ~strict =
416+
match get_operation_error ~__context ~self ~op ~strict with
417417
| None -> ()
418418
| Some (a,b) -> raise (Api_errors.Server_error (a,b))
419419

0 commit comments

Comments
 (0)