Skip to content

Commit e284caa

Browse files
authored
Merge pull request #336 from robhoes/1.96-lcm
CP-43468: push CPUID logic down from xapi into xenopsd
2 parents e9d1357 + f58558e commit e284caa

File tree

2 files changed

+84
-13
lines changed

2 files changed

+84
-13
lines changed

xen/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
(name xcp_xen_interface)
1616
(public_name xapi-idl.xen.interface)
1717
(modules xenops_interface)
18-
(flags (:standard -w -39))
18+
(flags (:standard -w -39-27))
1919
(libraries
2020
rpclib.core
2121
threads

xen/xenops_interface.ml

Lines changed: 83 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,53 @@ module Network = struct
197197
type ts = t list [@@deriving rpcty]
198198
end
199199

200+
module CPU_policy : sig
201+
type 'a t
202+
203+
val of_string : 'a -> string -> 'a t
204+
205+
val to_string : 'a t -> string
206+
207+
val vm : [`vm] t Rpc.Types.def
208+
209+
val host : [`host] t Rpc.Types.def
210+
211+
val typ_of : 'a -> 'a t Rpc.Types.typ
212+
end = struct
213+
type 'a t = string [@@deriving rpc]
214+
215+
let of_string _ s = s
216+
217+
let to_string s = s
218+
219+
let typ_of a =
220+
Rpc.Types.(
221+
Abstract
222+
{
223+
aname= "CPU_policy.t"
224+
; test_data= []
225+
; rpc_of= rpc_of_t ()
226+
; of_rpc= (fun x -> Ok (t_of_rpc a x))
227+
}
228+
)
229+
230+
let vm =
231+
Rpc.Types.
232+
{name= "CPU_policy.vm"; description= ["VM CPU policy"]; ty= typ_of `vm}
233+
234+
let host =
235+
Rpc.Types.
236+
{
237+
name= "CPU_policy.host"
238+
; description= ["Host CPU policy"]
239+
; ty= typ_of `host
240+
}
241+
end
242+
243+
type host_cpu_policy = [`host] CPU_policy.t
244+
245+
let typ_of_host_cpu_policy = CPU_policy.typ_of `host
246+
200247
module Pci = struct
201248
include Xcp_pci
202249

@@ -461,11 +508,11 @@ module Host = struct
461508
; model: string
462509
; stepping: string
463510
; flags: string
464-
; features: int64 array
465-
; features_pv: int64 array
466-
; features_hvm: int64 array
467-
; features_pv_host: int64 array
468-
; features_hvm_host: int64 array
511+
; features: host_cpu_policy
512+
; features_pv: host_cpu_policy
513+
; features_hvm: host_cpu_policy
514+
; features_pv_host: host_cpu_policy
515+
; features_hvm_host: host_cpu_policy
469516
}
470517
[@@deriving rpcty]
471518

@@ -581,13 +628,6 @@ module XenopsAPI (R : RPC) = struct
581628
Param.mk ~description:["The list of features"] ~name:"features"
582629
Host.guest_agent_feature_list
583630

584-
type cpu_features_array = int64 array [@@deriving rpcty]
585-
586-
let cpu_features_array_p =
587-
Param.mk
588-
~description:["An array containing the raw CPU feature flags"]
589-
~name:"features_array" cpu_features_array
590-
591631
let stat =
592632
declare "HOST.stat"
593633
["Get the state of the host"]
@@ -614,6 +654,37 @@ module XenopsAPI (R : RPC) = struct
614654
let update_guest_agent_features =
615655
declare "HOST.update_guest_agent_features" []
616656
(debug_info_p @-> feature_list_p @-> returning unit_p err)
657+
658+
let combine_cpu_policies =
659+
let policy1_p =
660+
Param.mk ~description:["CPU policy 1"] ~name:"policy1" CPU_policy.host
661+
in
662+
let policy2_p =
663+
Param.mk ~description:["CPU policy 2"] ~name:"policy2" CPU_policy.host
664+
in
665+
let policy3_p =
666+
Param.mk ~description:["Combined CPU policy"] ~name:"policy3"
667+
CPU_policy.host
668+
in
669+
declare "HOST.combine_cpu_policies"
670+
["Combine CPU policy to get a common subset"]
671+
(debug_info_p @-> policy1_p @-> policy2_p @-> returning policy3_p err)
672+
673+
let is_compatible =
674+
let vm_policy_p =
675+
Param.mk ~description:["VM CPU policy"] ~name:"vm_policy" CPU_policy.vm
676+
in
677+
let host_policy_p =
678+
Param.mk ~description:["Host CPU policy"] ~name:"host_policy"
679+
CPU_policy.host
680+
in
681+
declare "HOST.is_compatible"
682+
["Check whether a VM can live-migrate to or resume on a host"]
683+
(debug_info_p
684+
@-> vm_policy_p
685+
@-> host_policy_p
686+
@-> returning (Param.mk Types.bool) err
687+
)
617688
end
618689

619690
module VM = struct

0 commit comments

Comments
 (0)