@@ -49,7 +49,7 @@ let ensure_domain_type_is_specified ~__context ~self =
4949 if Db.VM. get_domain_type ~__context ~self = `unspecified then
5050 Db.VM. get_HVM_boot_policy ~__context ~self
5151 |> fun hbp -> derive_domain_type ~h VM_boot_policy:hbp
52- |> fun value -> Db.VM. set_domain_type ~__context ~self ~value
52+ |> fun value -> Db.VM. set_domain_type ~__context ~self ~value
5353
5454let derive_hvm_boot_policy ~domain_type =
5555 if domain_type = `hvm then
@@ -239,17 +239,17 @@ let validate_basic_parameters ~__context ~self ~snapshot:x =
239239let assert_vm_supports_quiesce_snapshot ~__context ~self =
240240 let vmr = Db.VM. get_record_internal ~__context ~self in
241241 if List. exists ( fun vbd ->
242- try
243- let vdi = Db.VBD. get_VDI ~__context ~self: vbd in
244- let sm_config = Db.VDI. get_sm_config ~__context ~self: vdi in
245- Xapi_vm_lifecycle. assoc_opt " on_boot" sm_config = Some " reset"
246- with _ -> false
247- ) vmr.Db_actions. vM_VBDs then
242+ try
243+ let vdi = Db.VBD. get_VDI ~__context ~self: vbd in
244+ let sm_config = Db.VDI. get_sm_config ~__context ~self: vdi in
245+ Xapi_vm_lifecycle. assoc_opt " on_boot" sm_config = Some " reset"
246+ with _ -> false
247+ ) vmr.Db_actions. vM_VBDs then
248248 raise (Api_errors. Server_error (Api_errors. vdi_on_boot_mode_incompatible_with_operation, [ ] ));
249249
250250 let vmgmr = Xapi_vm_lifecycle. maybe_get_guest_metrics ~__context ~ref: (vmr.Db_actions. vM_guest_metrics) in
251251 if not ((Xapi_vm_lifecycle. has_feature ~vmgmr ~feature: " feature-snapshot" ) ||
252- (Xapi_vm_lifecycle. has_feature ~vmgmr ~feature: " feature-quiesce" )) then
252+ (Xapi_vm_lifecycle. has_feature ~vmgmr ~feature: " feature-quiesce" )) then
253253 raise (Api_errors. Server_error (Api_errors. vm_snapshot_with_quiesce_not_supported, [ Ref. string_of self ]))
254254
255255let assert_hardware_platform_support ~__context ~vm ~host =
@@ -361,27 +361,27 @@ let assert_gpus_available ~__context ~self ~host =
361361 let vgpus = Db.VM. get_VGPUs ~__context ~self in
362362 let open Vgpuops in
363363 let vgpurs = List. map (Vgpuops. vgpu_of_ref ~__context) vgpus in
364- try
365- ignore (List. fold_left (fun pre_allocate_list vgpu -> Vgpuops. allocate_vgpu_to_gpu ~dry_run: true ~pre_allocate_list ~__context self host vgpu) [] vgpurs)
366- with _ -> raise (Api_errors. Server_error (Api_errors. vm_requires_gpu, [
367- Ref. string_of self;
368- String. concat " ;" (List. map Ref. string_of vgpus)
369- ]))
364+ try
365+ ignore (List. fold_left (fun pre_allocate_list vgpu -> Vgpuops. allocate_vgpu_to_gpu ~dry_run: true ~pre_allocate_list ~__context self host vgpu) [] vgpurs)
366+ with _ -> raise (Api_errors. Server_error (Api_errors. vm_requires_gpu, [
367+ Ref. string_of self;
368+ String. concat " ;" (List. map Ref. string_of vgpus)
369+ ]))
370370
371371
372372let assert_usbs_available ~__context ~self ~host =
373373 Db.VM. get_VUSBs ~__context ~self
374374 |> List. iter (fun vusb ->
375- try
376- let usb_group = Db.VUSB. get_USB_group ~__context ~self: vusb in
377- let pusb = List. hd (Db.USB_group. get_PUSBs ~__context ~self: usb_group) in
378- let usb_host = Db.PUSB. get_host ~__context ~self: pusb in
379- assert (usb_host = host)
380- with _ -> raise (Api_errors. Server_error (Api_errors. operation_not_allowed,
381- [Printf. sprintf " VUSB %s is not available on Host %s"
382- (Ref. string_of vusb)
383- (Ref. string_of host)
384- ]))
375+ try
376+ let usb_group = Db.VUSB. get_USB_group ~__context ~self: vusb in
377+ let pusb = List. hd (Db.USB_group. get_PUSBs ~__context ~self: usb_group) in
378+ let usb_host = Db.PUSB. get_host ~__context ~self: pusb in
379+ assert (usb_host = host)
380+ with _ -> raise (Api_errors. Server_error (Api_errors. operation_not_allowed,
381+ [Printf. sprintf " VUSB %s is not available on Host %s"
382+ (Ref. string_of vusb)
383+ (Ref. string_of host)
384+ ]))
385385 )
386386
387387(* 1.To avoid redundant checks,for each VF if it was reserved, then it's no need to check remaining capacity again.
@@ -398,9 +398,9 @@ let assert_netsriov_available ~__context ~self ~host =
398398 let required, pif = List. assoc network acc in
399399 (network,(required + 1 ,pif)) :: (List. remove_assoc network acc)
400400 with Not_found ->
401- match Xapi_network_sriov_helpers. get_local_underlying_pif ~__context ~network ~host with
402- | Some pif -> (network,(1 ,pif)) :: acc
403- | None -> acc
401+ match Xapi_network_sriov_helpers. get_local_underlying_pif ~__context ~network ~host with
402+ | Some pif -> (network,(1 ,pif)) :: acc
403+ | None -> acc
404404 end
405405 ) [] (Db.VM. get_VIFs ~__context ~self )
406406 in
@@ -442,9 +442,9 @@ let assert_enough_memory_available ~__context ~self ~host ~snapshot =
442442let assert_matches_control_domain_affinity ~__context ~self ~host =
443443 if Db.VM. get_is_control_domain ~__context ~self then
444444 match Db.VM. get_affinity ~__context ~self with
445- | x when x = Ref. null || x = host -> ()
446- | _ -> raise (Api_errors. Server_error (Api_errors. operation_not_allowed,
447- [" Cannot boot a control domain on a host different from its affinity" ]))
445+ | x when x = Ref. null || x = host -> ()
446+ | _ -> raise (Api_errors. Server_error (Api_errors. operation_not_allowed,
447+ [" Cannot boot a control domain on a host different from its affinity" ]))
448448
449449let assert_enough_pcpus ~__context ~self ~host ?remote () =
450450 let vcpus = Db.VM. get_VCPUs_max ~__context ~self in
@@ -457,13 +457,13 @@ let assert_enough_pcpus ~__context ~self ~host ?remote () =
457457 let platformdata = Db.VM. get_platform ~__context ~self in
458458 if Vm_platform. (is_true ~key: vcpu_unrestricted ~platformdata ~default: false ) then
459459 warn " Allowing VM %s to run on host %s, even though #vCPUs > #pCPUs (%Ld > %Ld), \
460- because platform:vcpu-unrestricted is set"
460+ because platform:vcpu-unrestricted is set"
461461 (Ref. string_of self) (Ref. string_of host) vcpus pcpus
462462 else
463463 raise Api_errors. (Server_error (
464- host_not_enough_pcpus,
465- List. map Int64. to_string [vcpus; pcpus]
466- ))
464+ host_not_enough_pcpus,
465+ List. map Int64. to_string [vcpus; pcpus]
466+ ))
467467
468468(* * Checks to see if a VM can boot on a particular host, throws an error if not.
469469 * Criteria:
@@ -508,9 +508,9 @@ let assert_can_boot_here ~__context ~self ~host ~snapshot ?(do_sr_check=true) ?(
508508 assert_usbs_available ~__context ~self ~host ;
509509 assert_netsriov_available ~__context ~self ~host ;
510510 begin match Helpers. domain_type ~__context ~self with
511- | `hvm | `pv_in_pvh ->
512- assert_host_supports_hvm ~__context ~self ~host
513- | `pv -> ()
511+ | `hvm | `pv_in_pvh ->
512+ assert_host_supports_hvm ~__context ~self ~host
513+ | `pv -> ()
514514 end ;
515515 if do_memory_check then
516516 assert_enough_memory_available ~__context ~self ~host ~snapshot ;
@@ -633,8 +633,8 @@ let vm_can_run_on_host ~__context ~vm ~snapshot ~do_memory_check host =
633633 try let _ = List. find (fun s -> snd s = `evacuate ) (Db.Host. get_current_operations ~__context ~self: host) in false with _ -> true
634634 in
635635 try host_has_proper_version ()
636- && (is_control_domain || host_enabled () ) (* CA-233580: allow control domains to start on a disabled host*)
637- && host_live () && host_can_run_vm () && host_evacuate_in_progress
636+ && (is_control_domain || host_enabled () ) (* CA-233580: allow control domains to start on a disabled host*)
637+ && host_live () && host_can_run_vm () && host_evacuate_in_progress
638638 with _ -> false
639639
640640
@@ -716,7 +716,7 @@ let choose_host_for_vm_no_wlb ~__context ~vm ~snapshot =
716716 | `VGPU vgpu -> group_hosts_by_best_pgpu ~__context vgpu
717717 | `Netsriov network ->
718718 let host_group = Xapi_network_sriov_helpers. group_hosts_by_best_sriov ~__context ~network
719- |> List. map (fun g -> List. map (fun (h ,_ )-> h) g)
719+ |> List. map (fun g -> List. map (fun (h ,_ )-> h) g)
720720 in
721721 if host_group <> [] then host_group
722722 else raise (Api_errors. Server_error (Api_errors. network_sriov_insufficient_capacity, [Ref. string_of network]))
@@ -771,9 +771,9 @@ let choose_host_for_vm ~__context ~vm ~snapshot =
771771 | [" WLB" ; " 0.0" ; rec_id; zero_reason] ->
772772 filter_and_convert tl
773773 | [" WLB" ; stars; rec_id] ->
774- let st = try float_of_string stars with Failure _ -> raise Float_of_string_failure
775- in
776- (h, st, rec_id) :: filter_and_convert tl
774+ let st = try float_of_string stars with Failure _ -> raise Float_of_string_failure
775+ in
776+ (h, st, rec_id) :: filter_and_convert tl
777777 | _ -> filter_and_convert tl
778778 end
779779 | [] -> []
@@ -1075,20 +1075,20 @@ let assert_valid_bios_strings ~__context ~value =
10751075 (* Validate size of value provided is within bios_string_limit_size and not empty *)
10761076 (* Validate value chars are printable ASCII characters *)
10771077 value |> List. iter (fun (k , v ) ->
1078- if not (List. mem k Xapi_globs. settable_vm_bios_string_keys) then
1079- raise (Api_errors. Server_error (Api_errors. invalid_value, [k; " Unknown key" ]));
1080- match String. length v with
1081- | 0 -> raise (Api_errors. Server_error (Api_errors. invalid_value, [k; " Value provided is empty" ]))
1082- | len when len > Xapi_globs. bios_string_limit_size ->
1083- let err = Printf. sprintf " %s has length more than %d characters" v Xapi_globs. bios_string_limit_size in
1084- raise (Api_errors. Server_error (Api_errors. invalid_value, [k; err]))
1085- | _ ->
1086- String. iter
1087- (fun c ->
1088- if c < (Char. chr 32 ) || c > = (Char. chr 127 ) then
1089- raise (Api_errors. Server_error (Api_errors. invalid_value, [k; v ^ " has non-printable ASCII characters" ]))
1090- ) v
1091- )
1078+ if not (List. mem k Xapi_globs. settable_vm_bios_string_keys) then
1079+ raise (Api_errors. Server_error (Api_errors. invalid_value, [k; " Unknown key" ]));
1080+ match String. length v with
1081+ | 0 -> raise (Api_errors. Server_error (Api_errors. invalid_value, [k; " Value provided is empty" ]))
1082+ | len when len > Xapi_globs. bios_string_limit_size ->
1083+ let err = Printf. sprintf " %s has length more than %d characters" v Xapi_globs. bios_string_limit_size in
1084+ raise (Api_errors. Server_error (Api_errors. invalid_value, [k; err]))
1085+ | _ ->
1086+ String. iter
1087+ (fun c ->
1088+ if c < (Char. chr 32 ) || c > = (Char. chr 127 ) then
1089+ raise (Api_errors. Server_error (Api_errors. invalid_value, [k; v ^ " has non-printable ASCII characters" ]))
1090+ ) v
1091+ )
10921092
10931093let copy_bios_strings ~__context ~vm ~host =
10941094 (* only allow to fill in BIOS strings if they are not yet set *)
@@ -1153,9 +1153,9 @@ let ensure_device_model_profile_present ~__context ~domain_type ~is_a_template ?
11531153 let trad = Vm_platform. (device_model, fallback_device_model_stage_1) in
11541154 if is_a_template then platform
11551155 else
1156- if not needs_qemu || List. mem_assoc Vm_platform. device_model platform then
1157- (* upgrade existing Device Model entry *)
1158- platform |> List. map (fun entry -> if entry = trad then default else entry)
1159- else (* only add device-model to an HVM VM platform if it is not already there *)
1160- default :: platform
1156+ if not needs_qemu || List. mem_assoc Vm_platform. device_model platform then
1157+ (* upgrade existing Device Model entry *)
1158+ platform |> List. map (fun entry -> if entry = trad then default else entry)
1159+ else (* only add device-model to an HVM VM platform if it is not already there *)
1160+ default :: platform
11611161
0 commit comments