Skip to content

Commit

Permalink
CA-371529 expunge create_from_record_without_checking_licence ...
Browse files Browse the repository at this point in the history
Remove the function and use VM.create_from_record directly.

Signed-off-by: Christian Lindig <[email protected]>
  • Loading branch information
Christian Lindig authored and lindig committed Apr 30, 2024
1 parent 53dcbc0 commit ebb58a8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 25 deletions.
8 changes: 3 additions & 5 deletions ocaml/xapi/import.ml
Original file line number Diff line number Diff line change
Expand Up @@ -629,17 +629,15 @@ module VM : HandlerTools = struct
~domain_type:vm_record.API.vM_domain_type
~is_a_template:vm_record.API.vM_is_a_template
vm_record.API.vM_platform
; API.vM_suspend_VDI= Ref.null
; API.vM_power_state= `Halted
}
in
let vm =
log_reraise
("failed to create VM with name-label " ^ vm_record.API.vM_name_label)
(fun value ->
let vm =
Xapi_vm_helpers
.create_from_record_without_checking_licence_feature_for_vendor_device
~__context rpc session_id value
in
let vm = Client.VM.create_from_record ~rpc ~session_id ~value in
if config.full_restore then
Db.VM.set_uuid ~__context ~self:vm ~value:value.API.vM_uuid ;
vm
Expand Down
17 changes: 0 additions & 17 deletions ocaml/xapi/xapi_vm_helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -149,23 +149,6 @@ let update_vm_virtual_hardware_platform_version ~__context ~vm =
Db.VM.set_hardware_platform_version ~__context ~self:vm
~value:visibly_required_version

let create_from_record_without_checking_licence_feature_for_vendor_device
~__context rpc session_id vm_record =
(* vendor device is no longer licensed *)
let mk_vm r =
Client.Client.VM.create_from_record ~rpc ~session_id
~value:{r with API.vM_suspend_VDI= Ref.null; API.vM_power_state= `Halted}
in
let has_vendor_device = vm_record.API.vM_has_vendor_device in
if has_vendor_device then (
(* Avoid the licence feature check which is enforced in VM.create (and create_from_record). *)
let vm = mk_vm {vm_record with API.vM_has_vendor_device= false} in
Db.VM.set_has_vendor_device ~__context ~self:vm ~value:true ;
update_vm_virtual_hardware_platform_version ~__context ~vm ;
vm
) else
mk_vm vm_record

let destroy ~__context ~self =
(* Used to be a call to hard shutdown here, but this will be redundant *)
(* given the call to 'assert_operation_valid' *)
Expand Down
11 changes: 8 additions & 3 deletions ocaml/xapi/xapi_vm_snapshot.ml
Original file line number Diff line number Diff line change
Expand Up @@ -553,11 +553,16 @@ let create_vm_from_snapshot ~__context ~snapshot =
let snap_metadata = Helpers.vm_string_to_assoc snap_metadata in
let vm_uuid = List.assoc Db_names.uuid snap_metadata in
let snap_record = Db.VM.get_record ~__context ~self:snapshot in
let snap_record =
{
snap_record with
API.vM_suspend_VDI= Ref.null
; API.vM_power_state= `Halted
}
in
Helpers.call_api_functions ~__context (fun rpc session_id ->
let new_vm =
Xapi_vm_helpers
.create_from_record_without_checking_licence_feature_for_vendor_device
~__context rpc session_id snap_record
Client.VM.create_from_record ~rpc ~session_id ~value:snap_record
in
try
Db.VM.set_uuid ~__context ~self:new_vm ~value:vm_uuid ;
Expand Down

0 comments on commit ebb58a8

Please sign in to comment.