diff --git a/ocaml/idl/datamodel_errors.ml b/ocaml/idl/datamodel_errors.ml index 6d1107855f0..890c3bdd9b5 100644 --- a/ocaml/idl/datamodel_errors.ml +++ b/ocaml/idl/datamodel_errors.ml @@ -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: diff --git a/ocaml/xapi-consts/api_errors.ml b/ocaml/xapi-consts/api_errors.ml index 9d5851fbbe8..a278c00ebba 100644 --- a/ocaml/xapi-consts/api_errors.ml +++ b/ocaml/xapi-consts/api_errors.ml @@ -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" diff --git a/ocaml/xapi/message_forwarding.ml b/ocaml/xapi/message_forwarding.ml index 0e60aff0555..406b7d67b0f 100644 --- a/ocaml/xapi/message_forwarding.ml +++ b/ocaml/xapi/message_forwarding.ml @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/ocaml/xapi/xapi_globs.ml b/ocaml/xapi/xapi_globs.ml index 638896e0a1e..de61e63878e 100644 --- a/ocaml/xapi/xapi_globs.ml +++ b/ocaml/xapi/xapi_globs.ml @@ -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 @@ -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) diff --git a/ocaml/xapi/xapi_vgpu_type.ml b/ocaml/xapi/xapi_vgpu_type.ml index dc01aabd509..530507c714d 100644 --- a/ocaml/xapi/xapi_vgpu_type.ml +++ b/ocaml/xapi/xapi_vgpu_type.ml @@ -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 @@ -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 @@ -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)) diff --git a/ocaml/xapi/xapi_vm_helpers.ml b/ocaml/xapi/xapi_vm_helpers.ml index 65216c6d72b..d5512651bc2 100644 --- a/ocaml/xapi/xapi_vm_helpers.ml +++ b/ocaml/xapi/xapi_vm_helpers.ml @@ -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. @@ -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 ; @@ -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 ; diff --git a/ocaml/xapi/xapi_vm_migrate.ml b/ocaml/xapi/xapi_vm_migrate.ml index abbf9adb30a..f7fd9b3caa1 100644 --- a/ocaml/xapi/xapi_vm_migrate.ml +++ b/ocaml/xapi/xapi_vm_migrate.ml @@ -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 =