Skip to content

CA-404693 prohibit selecting driver variant if h/w not present #6243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 21, 2025
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
3 changes: 3 additions & 0 deletions ocaml/idl/datamodel_errors.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2010,6 +2010,9 @@ let _ =

error Api_errors.too_many_groups [] ~doc:"VM can only belong to one group." () ;

error Api_errors.host_driver_no_hardware ["driver variant"]
~doc:"No hardware present for this host driver variant" () ;

message
(fst Api_messages.ha_pool_overcommitted)
~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 @@ -1403,3 +1403,5 @@ let telemetry_next_collection_too_late =
let illegal_in_fips_mode = add_error "ILLEGAL_IN_FIPS_MODE"

let too_many_groups = add_error "TOO_MANY_GROUPS"

let host_driver_no_hardware = add_error "HOST_DRIVER_NO_HARDWARE"
7 changes: 7 additions & 0 deletions ocaml/xapi/xapi_host_driver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ module Tool = Xapi_host_driver_tool
let invalid_value field value =
raise Api_errors.(Server_error (invalid_value, [field; value]))

let no_hardware driver_variant =
raise Api_errors.(Server_error (host_driver_no_hardware, [driver_variant]))

module Variant = struct
let create ~__context ~name ~version ~driver ~hw_present ~priority ~dev_status
=
Expand Down Expand Up @@ -68,6 +71,8 @@ module Variant = struct
let drv = Db.Driver_variant.get_driver ~__context ~self in
let d = Db.Host_driver.get_record ~__context ~self:drv in
let v = Db.Driver_variant.get_record ~__context ~self in
if v.API.driver_variant_hardware_present = false then
no_hardware (Ref.string_of self) ;
let stdout =
Tool.call ["select"; d.API.host_driver_name; v.API.driver_variant_name]
in
Expand Down Expand Up @@ -133,6 +138,8 @@ let select ~__context ~self ~variant =
D.debug "%s selecting driver %s variant %s" __FUNCTION__ drv var ;
let d = Db.Host_driver.get_record ~__context ~self in
let v = Db.Driver_variant.get_record ~__context ~self:variant in
if v.API.driver_variant_hardware_present = false then
no_hardware (Ref.string_of variant) ;
let stdout =
Tool.call ["select"; d.API.host_driver_name; v.API.driver_variant_name]
in
Expand Down
Loading