Skip to content

Commit

Permalink
CA-402921: Relax VIF constraint for PVS proxy
Browse files Browse the repository at this point in the history
The current constraint is that the VIF used for PVS proxy must have
device number 0. It turned out that this can be relaxed. It is
sufficient to enforce that the VIF is the one with the lowest device
number for the VM.

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
  • Loading branch information
robhoes committed Dec 18, 2024
1 parent 0472024 commit d08c6cb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions ocaml/idl/datamodel_errors.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1818,6 +1818,11 @@ let _ =
"The address specified is already in use by an existing PVS_server object"
() ;

error Api_errors.pvs_vif_must_be_first_device []
~doc:
"The VIF used by PVS proxy must be the one with the lowest device number"
() ;

error Api_errors.usb_group_contains_vusb ["vusbs"]
~doc:"The USB group contains active VUSBs and cannot be deleted." () ;
error Api_errors.usb_group_contains_pusb ["pusbs"]
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 @@ -1246,6 +1246,8 @@ let pvs_proxy_already_present = add_error "PVS_PROXY_ALREADY_PRESENT"

let pvs_server_address_in_use = add_error "PVS_SERVER_ADDRESS_IN_USE"

let pvs_vif_must_be_first_device = add_error "PVS_VIF_MUST_BE_FIRST_DEVICE"

let extension_protocol_failure = add_error "EXTENSION_PROTOCOL_FAILURE"

let usb_group_contains_vusb = add_error "USB_GROUP_CONTAINS_VUSB"
Expand Down
15 changes: 12 additions & 3 deletions ocaml/xapi/xapi_pvs_proxy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,18 @@ let create ~__context ~site ~vIF =
) ;
Helpers.assert_is_valid_ref ~__context ~name:"site" ~ref:site ;
Helpers.assert_is_valid_ref ~__context ~name:"VIF" ~ref:vIF ;
let device = Db.VIF.get_device ~__context ~self:vIF in
if device <> "0" then
raise Api_errors.(Server_error (invalid_device, [device])) ;
let device = Db.VIF.get_device ~__context ~self:vIF |> int_of_string in
let min_device =
let open Xapi_database.Db_filter_types in
let vm = Db.VIF.get_VM ~__context ~self:vIF in
Db.VIF.get_records_where ~__context
~expr:(Eq (Field "VM", Literal (Ref.string_of vm)))
|> List.fold_left
(fun m (_, {API.vIF_device= d; _}) -> min m (int_of_string d))
device
in
if device <> min_device then
raise Api_errors.(Server_error (pvs_vif_must_be_first_device, [])) ;
let pvs_proxy = Ref.make () in
let uuid = Uuidx.(to_string (make ())) in
Db.PVS_proxy.create ~__context ~ref:pvs_proxy ~uuid ~site ~vIF
Expand Down

0 comments on commit d08c6cb

Please sign in to comment.