Skip to content
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
10 changes: 10 additions & 0 deletions ocaml/idl/datamodel.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7460,6 +7460,16 @@ module VM_metrics = struct
"current_domain_type"
"The current domain type of the VM (for running,suspended, or \
paused VMs). The last-known domain type for halted VMs."
; field ~qualifier:StaticRO ~ty:Bool ~default_value:(Some (VBool false))
~lifecycle:[] "numa_optimised" "If the VM is optimised for NUMA"
; field ~qualifier:StaticRO ~ty:Int ~default_value:(Some (VInt 0L))
~lifecycle:[] "numa_nodes"
"number of NUMA nodes of the host the VM is using"
; field ~qualifier:DynamicRO
~ty:(Map (Int, Int))
~default_value:(Some (VMap [])) ~lifecycle:[] "numa_node_memory"
"mapping a NUMA node (int) to an amount of memory (bytes) in that \
node."
]
()
end
Expand Down
2 changes: 1 addition & 1 deletion ocaml/idl/datamodel_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ open Datamodel_roles
to leave a gap for potential hotfixes needing to increment the schema version.*)
let schema_major_vsn = 5

let schema_minor_vsn = 791
let schema_minor_vsn = 792

(* Historical schema versions just in case this is useful later *)
let rio_schema_major_vsn = 5
Expand Down
6 changes: 6 additions & 0 deletions ocaml/idl/datamodel_lifecycle.ml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ let prototyped_of_field = function
Some "25.15.0"
| "VM_guest_metrics", "netbios_name" ->
Some "24.28.0"
| "VM_metrics", "numa_node_memory" ->
Some "25.35.0"
| "VM_metrics", "numa_nodes" ->
Some "25.35.0"
| "VM_metrics", "numa_optimised" ->
Some "25.35.0"
| "VM", "groups" ->
Some "24.19.1"
| "VM", "pending_guidances_full" ->
Expand Down
2 changes: 1 addition & 1 deletion ocaml/idl/schematest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let hash x = Digest.string x |> Digest.to_hex
(* BEWARE: if this changes, check that schema has been bumped accordingly in
ocaml/idl/datamodel_common.ml, usually schema_minor_vsn *)

let last_known_schema_hash = "3b20f4304cfaaa7b6213af91ae632e64"
let last_known_schema_hash = "0a101facfb33717de6ad4cc4d220cd1a"

let current_schema_hash : string =
let open Datamodel_types in
Expand Down
25 changes: 25 additions & 0 deletions ocaml/xapi-cli-server/records.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2156,6 +2156,31 @@ let vm_record rpc session_id vm =
)
~get_map:(fun () -> (x ()).API.vM_platform)
()
; make_field ~name:"numa-optimised"
~get:(fun () ->
Option.fold ~none:"false"
~some:(fun m -> string_of_bool m.API.vM_metrics_numa_optimised)
(xm ())
)
()
; make_field ~name:"numa-nodes"
~get:(fun () ->
Option.fold ~none:"0"
~some:(fun m -> Int64.to_string m.API.vM_metrics_numa_nodes)
(xm ())
)
()
; make_field ~name:"numa-node-memory"
~get:(fun () ->
Option.fold ~none:"[]"
~some:(fun m ->
map_and_concat
(fun (x, y) -> Printf.sprintf "%Li: %Li" x y)
m.API.vM_metrics_numa_node_memory
)
(xm ())
)
()
; make_field ~name:"allowed-operations"
~get:(fun () ->
map_and_concat Record_util.vm_operation_to_string
Expand Down
3 changes: 3 additions & 0 deletions ocaml/xapi-idl/xen/xenops_types.ml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ module Vm = struct
; nested_virt: bool (** true means VM uses nested virtualisation *)
; domain_type: domain_type
; featureset: string
; numa_optimised: bool
; numa_nodes: int (* count *)
; numa_node_memory: (int * int64) list (* node * bytes *)
}
[@@deriving rpcty, sexp]
end
1 change: 1 addition & 0 deletions ocaml/xapi/create_misc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ and create_domain_zero_metrics_record ~__context ~domain_zero_metrics_ref
~vCPUs_flags:[] ~state:[] ~start_time:Date.epoch ~install_time:Date.epoch
~last_updated:Date.epoch ~other_config:[] ~hvm:false ~nomigrate:false
~nested_virt:false ~current_domain_type:Xapi_globs.domain_zero_domain_type
~numa_optimised:false ~numa_nodes:0L ~numa_node_memory:[]

and update_domain_zero_record ~__context ~domain_zero_ref (host_info : host_info)
: unit =
Expand Down
3 changes: 2 additions & 1 deletion ocaml/xapi/dbsync_master.ml
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ let ensure_vm_metrics_records_exist __context =
~vCPUs_flags:[] ~start_time:Clock.Date.epoch
~install_time:Clock.Date.epoch ~state:[]
~last_updated:Clock.Date.epoch ~other_config:[] ~hvm:false
~nested_virt:false ~nomigrate:false ~current_domain_type:`unspecified ;
~nested_virt:false ~nomigrate:false ~current_domain_type:`unspecified
~numa_optimised:false ~numa_nodes:0L ~numa_node_memory:[] ;
Db.VM.set_metrics ~__context ~self:vm ~value:m
)
)
Expand Down
5 changes: 4 additions & 1 deletion ocaml/xapi/import.ml
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,10 @@ module Metrics : HandlerTools = struct
~hvm:vmm_record.API.vM_metrics_hvm
~nested_virt:vmm_record.API.vM_metrics_nested_virt
~nomigrate:vmm_record.API.vM_metrics_nomigrate
~current_domain_type:vmm_record.API.vM_metrics_current_domain_type ;
~current_domain_type:vmm_record.API.vM_metrics_current_domain_type
~numa_optimised:vmm_record.API.vM_metrics_numa_optimised
~numa_nodes:vmm_record.API.vM_metrics_numa_nodes
~numa_node_memory:vmm_record.API.vM_metrics_numa_node_memory ;
state.table <- (x.cls, x.id, Ref.string_of vmm) :: state.table
end

Expand Down
3 changes: 2 additions & 1 deletion ocaml/xapi/xapi_vm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,8 @@ let create ~__context ~name_label ~name_description ~power_state ~user_version
~memory_actual:0L ~vCPUs_number:0L ~vCPUs_utilisation ~vCPUs_CPU:[]
~vCPUs_params:[] ~vCPUs_flags:[] ~state:[] ~start_time:Date.epoch
~install_time:Date.epoch ~last_updated:Date.epoch ~other_config:[]
~hvm:false ~nested_virt:false ~nomigrate:false ~current_domain_type ;
~hvm:false ~nested_virt:false ~nomigrate:false ~current_domain_type
~numa_optimised:false ~numa_nodes:0L ~numa_node_memory:[] ;
let domain_type =
if domain_type = `unspecified then
derive_domain_type ~hVM_boot_policy
Expand Down
15 changes: 15 additions & 0 deletions ocaml/xapi/xapi_vm_helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,21 @@ let copy_metrics ~__context ~vm =
(Option.fold ~none:`unspecified
~some:(fun x -> x.Db_actions.vM_metrics_current_domain_type)
m
)
~numa_optimised:
(Option.fold ~none:false
~some:(fun x -> x.Db_actions.vM_metrics_numa_optimised)
m
)
~numa_nodes:
(Option.fold ~none:0L
~some:(fun x -> x.Db_actions.vM_metrics_numa_nodes)
m
)
~numa_node_memory:
(Option.fold ~none:[]
~some:(fun x -> x.Db_actions.vM_metrics_numa_node_memory)
m
) ;
metrics

Expand Down
34 changes: 34 additions & 0 deletions ocaml/xapi/xapi_xenops.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2474,6 +2474,40 @@ let update_vm_internal ~__context ~id ~self ~previous ~info ~localhost =
error "Caught %s: while updating VM %s last_boot_CPU_flags"
(Printexc.to_string e) id
) ;
different
(fun x -> x.Vm.numa_optimised)
Fun.id
(fun opt ->
let metrics = Db.VM.get_metrics ~__context ~self in
debug "Updating VM %s NUMA optimised=%b" id opt ;
Db.VM_metrics.set_numa_optimised ~__context ~self:metrics ~value:opt
) ;
different
(fun x -> x.Vm.numa_nodes)
Fun.id
(fun n ->
let metrics = Db.VM.get_metrics ~__context ~self in
debug "Updating VM %s NUMA nodes=%d" id n ;
Db.VM_metrics.set_numa_nodes ~__context ~self:metrics
~value:(Int64.of_int n)
) ;
different
(fun x -> x.Vm.numa_node_memory)
Fun.id
(fun assoc ->
let mib n = Int64.shift_left n 20 in
let assignment =
List.map
(fun (node, mem) -> Printf.sprintf "%d:%LdMiB" node (mib mem))
assoc
|> String.concat " "
in
let metrics = Db.VM.get_metrics ~__context ~self in
debug "Updating VM %s NUMA assignment [%s]" id assignment ;
Db.VM_metrics.set_numa_node_memory ~__context ~self:metrics
~value:(List.map (fun (x, y) -> (Int64.of_int x, y)) assoc)
) ;

Xenops_cache.update_vm id info ;
if !should_update_allowed_operations then
Helpers.call_api_functions ~__context (fun rpc session_id ->
Expand Down
3 changes: 3 additions & 0 deletions ocaml/xenopsd/lib/xenops_utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,9 @@ let halted_vm =
; nested_virt= false
; domain_type= Vm.Domain_undefined
; featureset= ""
; numa_optimised= false
; numa_nodes= 0
; numa_node_memory= []
}

let unplugged_pci = {Pci.plugged= false}
Expand Down
3 changes: 3 additions & 0 deletions ocaml/xenopsd/xc/xenops_server_xen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2972,6 +2972,9 @@ module VM = struct
| Some x ->
List.assoc "featureset" x.VmExtra.persistent.platformdata
)
; numa_optimised= false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the place where we would pick up the actual values from Xen.

; numa_nodes= 0
; numa_node_memory= []
}
)

Expand Down
Loading