Skip to content

Commit 88b607f

Browse files
committed
CP-14790: VM helper creates VM without licence check
New function in Xapi_vm_helpers: create_from_record_without_checking_licence_feature_for_vendor_device Signed-off-by: Thomas Sanders <[email protected]>
1 parent fd486c4 commit 88b607f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ocaml/xapi/xapi_vm_helpers.ml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@ let set_is_a_template ~__context ~self ~value =
7777
end;
7878
Db.VM.set_is_a_template ~__context ~self ~value
7979

80+
let create_from_record_without_checking_licence_feature_for_vendor_device ~__context rpc session_id vm_record =
81+
let mk_vm r = Client.Client.VM.create_from_record rpc session_id r in
82+
let auto_update_drivers = vm_record.API.vM_auto_update_drivers in
83+
if auto_update_drivers && not (Pool_features.is_enabled ~__context Features.PCI_device_for_auto_update)
84+
then (
85+
(* Avoid the licence feature check which is enforced in VM.create (and create_from_record). *)
86+
let vm = mk_vm {vm_record with API.vM_auto_update_drivers = false} in
87+
Db.VM.set_auto_update_drivers ~__context ~self:vm ~value:true;
88+
vm
89+
) else mk_vm vm_record
90+
8091
let create ~__context ~name_label ~name_description
8192
~user_version ~is_a_template
8293
~affinity

0 commit comments

Comments
 (0)