Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ocaml/idl/datamodel_errors.ml
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@ let _ =
error Api_errors.vgpu_type_not_supported
["type"; "supported_types"]
~doc:"VGPU type is not one of the PGPU's supported types." () ;
error Api_errors.vgpu_type_no_longer_supported ["type"]
~doc:"VGPU type is no longer supported" () ;
error Api_errors.vgpu_type_not_compatible_with_running_type
["pgpu"; "type"; "running_type"]
~doc:
Expand Down
2 changes: 2 additions & 0 deletions ocaml/xapi-consts/api_errors.ml
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,8 @@ let vgpu_type_not_enabled = "VGPU_TYPE_NOT_ENABLED"

let vgpu_type_not_supported = "VGPU_TYPE_NOT_SUPPORTED"

let vgpu_type_no_longer_supported = "VGPU_TYPE_NO_LONGER_SUPPORTED"

let vgpu_type_not_compatible_with_running_type =
"VGPU_TYPE_NOT_COMPATIBLE_WITH_RUNNING_TYPE"

Expand Down
4 changes: 4 additions & 0 deletions ocaml/xapi/message_forwarding.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,7 @@ functor
let allocate_vm_to_host ~__context ~vm ~host ~snapshot ?host_op () =
info "Reserve resources for VM %s on host %s" (Ref.string_of vm)
(Ref.string_of host) ;
Xapi_vm_helpers.assert_no_legacy_hardware ~__context ~vm ;
( match host_op with
| Some x ->
let task_id = Ref.string_of (Context.get_task_id __context) in
Expand Down Expand Up @@ -1768,6 +1769,7 @@ functor

let start ~__context ~vm ~start_paused ~force =
info "VM.start: VM = '%s'" (vm_uuid ~__context vm) ;
Xapi_vm_helpers.assert_no_legacy_hardware ~__context ~vm ;
let local_fn = Local.VM.start ~vm ~start_paused ~force in
let host =
with_vm_operation ~__context ~self:vm ~doc:"VM.start" ~op:`start
Expand Down Expand Up @@ -2274,6 +2276,7 @@ functor
(* Like start.. resume on any suitable host *)
let resume ~__context ~vm ~start_paused ~force =
info "VM.resume: VM = '%s'" (vm_uuid ~__context vm) ;
Xapi_vm_helpers.assert_no_legacy_hardware ~__context ~vm ;
let local_fn = Local.VM.resume ~vm ~start_paused ~force in
let host =
with_vm_operation ~__context ~self:vm ~doc:"VM.resume" ~op:`resume
Expand Down Expand Up @@ -2314,6 +2317,7 @@ functor
info "VM.resume_on: VM = '%s'; host = '%s'" (vm_uuid ~__context vm)
(host_uuid ~__context host) ;
let local_fn = Local.VM.resume_on ~vm ~host ~start_paused ~force in
Xapi_vm_helpers.assert_no_legacy_hardware ~__context ~vm ;
with_vm_operation ~__context ~self:vm ~doc:"VM.resume_on" ~op:`resume_on
(fun () ->
with_vbds_marked ~__context ~vm ~doc:"VM.resume_on" ~op:`attach
Expand Down
8 changes: 8 additions & 0 deletions ocaml/xapi/xapi_globs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ let xapi_extensions_root = ref "/etc/xapi.d/extensions"

let host_operations_miami = [`evacuate; `provision]

(* Whether still support intel gvt-g vGPU *)
let gvt_g_supported = ref true

let rpu_allowed_vm_operations =
[
`assert_operation_valid
Expand Down Expand Up @@ -1226,6 +1229,11 @@ let other_options =
, (fun () -> !gvt_g_whitelist)
, "path to the GVT-g whitelist file"
)
; ( "gvt-g-supported"
, Arg.Set gvt_g_supported
, (fun () -> string_of_bool !gvt_g_supported)
, "indicates that this server still support intel gvt_g vGPU"
)
; ( "mxgpu-whitelist"
, Arg.Set_string mxgpu_whitelist
, (fun () -> !mxgpu_whitelist)
Expand Down
15 changes: 13 additions & 2 deletions ocaml/xapi/xapi_vgpu_type.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

let finally = Xapi_stdext_pervasives.Pervasiveext.finally

module D = Debug.Make (struct let name = "xapi" end)
module D = Debug.Make (struct let name = "xapi_vgpu_type" end)

open D

Expand Down Expand Up @@ -1069,7 +1069,7 @@ let find_or_create_supported_types ~__context ~pci =
match vendor_id with
| x when x = Nvidia.vendor_id ->
Nvidia.find_or_create_supported_types
| x when x = Intel.vendor_id ->
| x when x = Intel.vendor_id && !Xapi_globs.gvt_g_supported ->
Intel.find_or_create_supported_types
| x when x = AMD.vendor_id ->
AMD.find_or_create_supported_types
Expand All @@ -1090,3 +1090,14 @@ let requires_passthrough ~__context ~self =
None

(* Does not require any passthrough *)

let assert_not_legacy ~__context ~self =
let legacy =
(not !Xapi_globs.gvt_g_supported)
&& Db.VGPU_type.get_implementation ~__context ~self = `gvt_g
in
if legacy then
let vendor = Db.VGPU_type.get_vendor_name ~__context ~self in
let model = Db.VGPU_type.get_model_name ~__context ~self in
let msg = [Printf.sprintf "%s: %s" vendor model] in
raise Api_errors.(Server_error (vgpu_type_no_longer_supported, msg))
10 changes: 10 additions & 0 deletions ocaml/xapi/xapi_vm_helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,14 @@ let assert_enough_pcpus ~__context ~self ~host ?remote () =
(host_not_enough_pcpus, List.map Int64.to_string [vcpus; pcpus])
)

let assert_no_legacy_vgpu ~__context ~vm =
Db.VM.get_VGPUs ~__context ~self:vm
|> List.map (fun self -> Db.VGPU.get_type ~__context ~self)
|> List.iter (fun self -> Xapi_vgpu_type.assert_not_legacy ~__context ~self)

let assert_no_legacy_hardware ~__context ~vm =
assert_no_legacy_vgpu ~__context ~vm

(** Checks to see if a VM can boot on a particular host, throws an error if not.
* Criteria:
- The host must support the VM's required Virtual Hardware Platform version.
Expand All @@ -692,6 +700,7 @@ let assert_can_boot_here ~__context ~self ~host ~snapshot ~do_cpuid_check
?(do_sr_check = true) ?(do_memory_check = true) () =
debug "Checking whether VM %s can run on host %s" (Ref.string_of self)
(Ref.string_of host) ;
assert_no_legacy_hardware ~__context ~vm:self ;
validate_basic_parameters ~__context ~self ~snapshot ;
assert_host_is_live ~__context ~host ;
assert_matches_control_domain_affinity ~__context ~self ~host ;
Expand All @@ -716,6 +725,7 @@ let assert_can_boot_here ~__context ~self ~host ~snapshot ~do_cpuid_check
if vm_needs_iommu ~__context ~self then
assert_host_has_iommu ~__context ~host ;
(* Assumption: a VM can have only one vGPU *)
assert_no_legacy_vgpu ~__context ~vm:self ;
if has_non_allocated_vgpus ~__context ~self then
assert_gpus_available ~__context ~self ~host ;
assert_usbs_available ~__context ~self ~host ;
Expand Down
1 change: 1 addition & 0 deletions ocaml/xapi/xapi_vm_migrate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,7 @@ let migration_type ~__context ~remote =

let assert_can_migrate ~__context ~vm ~dest ~live:_ ~vdi_map ~vif_map ~options
~vgpu_map =
Xapi_vm_helpers.assert_no_legacy_hardware ~__context ~vm ;
assert_licensed_storage_motion ~__context ;
let remote = remote_of_dest ~__context dest in
let force =
Expand Down