File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed
Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -221,6 +221,16 @@ let unpause ~__context ~vm =
221221let set_xenstore_data ~__context ~self ~value =
222222 Xapi_xenops. set_xenstore_data ~__context ~self value
223223
224+ (* CP-18860: check memory limits if using nested_virt on start *)
225+ let assert_memory_constraints ~__context ~vm platformdata =
226+ if Vm_platform. is_true ~key: " nested-virt" ~platformdata ~default: false
227+ then
228+ begin
229+ let module C = Xapi_vm_memory_constraints. Vm_memory_constraints in
230+ let c = C. get ~__context ~vm_ref: vm in
231+ C. assert_valid_and_pinned_at_static_max c
232+ end
233+
224234(* Note: it is important that we use the pool-internal API call, VM.atomic_set_resident_on, to set resident_on and clear
225235 scheduled_to_be_resident_on atomically. This prevents concurrent API calls on the master from accounting for the
226236 same VM twice during memory calculations to determine whether a given VM can start on a particular host..
@@ -234,6 +244,9 @@ let start ~__context ~vm ~start_paused ~force =
234244 debug " Setting ha_always_run on vm=%s as true during VM.start" (Ref. string_of vm)
235245 end ;
236246
247+ if not force then
248+ assert_memory_constraints ~__context ~vm vmr.API. vM_platform;
249+
237250 (* Check to see if we're using any restricted platform kvs. This raises
238251 an exception if so *)
239252 Vm_platform. check_restricted_flags ~__context vmr.API. vM_platform;
Original file line number Diff line number Diff line change @@ -735,15 +735,6 @@ module MD = struct
735735 let pci_msitranslate =
736736 if vm.API. vM_VGPUs <> [] then false else pci_msitranslate in
737737
738- (* CP-18860: check memory limits if using nested_virt *)
739- if Vm_platform. is_true ~key: " nested-virt" ~platformdata ~default: false
740- then
741- begin
742- let module C = Xapi_vm_memory_constraints. Vm_memory_constraints in
743- let c = C. get ~__context ~vm_ref: vmref in
744- C. assert_valid_and_pinned_at_static_max c
745- end ;
746-
747738 {
748739 id = vm.API. vM_uuid;
749740 name = vm.API. vM_name_label;
You can’t perform that action at this time.
0 commit comments