From 4becc093b5a4c219c81e6c51be698b1a26a897d2 Mon Sep 17 00:00:00 2001 From: Rob Hoes Date: Tue, 18 Mar 2025 14:57:55 +0000 Subject: [PATCH 1/2] Update datamodel_lifecycle.ml Signed-off-by: Rob Hoes --- ocaml/idl/datamodel_lifecycle.ml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ocaml/idl/datamodel_lifecycle.ml b/ocaml/idl/datamodel_lifecycle.ml index d21cad211e3..c842edcd5bf 100644 --- a/ocaml/idl/datamodel_lifecycle.ml +++ b/ocaml/idl/datamodel_lifecycle.ml @@ -206,9 +206,9 @@ let prototyped_of_message = function | "VTPM", "create" -> Some "22.26.0" | "host", "disable_ssh" -> - Some "25.12.0-next" + Some "25.13.0" | "host", "enable_ssh" -> - Some "25.12.0-next" + Some "25.13.0" | "host", "emergency_clear_mandatory_guidance" -> Some "24.10.0" | "host", "apply_recommended_guidances" -> @@ -228,9 +228,9 @@ let prototyped_of_message = function | "VM", "set_groups" -> Some "24.19.1" | "pool", "disable_ssh" -> - Some "25.12.0-next" + Some "25.13.0" | "pool", "enable_ssh" -> - Some "25.12.0-next" + Some "25.13.0" | "pool", "get_guest_secureboot_readiness" -> Some "24.17.0" | "pool", "set_ext_auth_cache_expiry" -> From 3608e9d68d039ecd292961d1166b1848ec50332d Mon Sep 17 00:00:00 2001 From: Rob Hoes Date: Tue, 18 Mar 2025 15:08:45 +0000 Subject: [PATCH 2/2] CA-408339: Respect xenopsd's NUMA-placement-policy default Xenopsd has an experimental feature that aims to optimise NUMA placement. This used to be configured by adding `numa-placement=true` to the file /etc/xenopsd.conf, which tells xenopsd to enable the feature. Later, an actual API was added to configure this: `host.set_numa_affinity_policy`. The expectation was that, while this new API should be preferred, the old xenopsd.conf option would still work for backwards compatibility reasons. This is particularly important for hosts that are upgraded to the new version. Unfortunately, while code exists in xenopsd to read and use the config option when it starts up, when xapi starts up immediately after xenopsd, it always overrides the NUMA config based its own DB field. The field type actually has a "default" option, but this gets translated to "any" (= no NUMA). By default, this means means that the experimental feature is disabled, no matter what the config file says, and can only be enabled through the API. The fix is for xapi to not assign a default value itself, but let xenopsd decide on the default policy. And xenopsd uses its config file to do so, as before. Signed-off-by: Rob Hoes --- ocaml/xapi-idl/xen/xenops_interface.ml | 4 +++- ocaml/xapi/xapi_xenops.ml | 6 +++--- ocaml/xenopsd/lib/xenops_server.ml | 15 ++++++++++++++- ocaml/xenopsd/xc/xenops_server_xen.ml | 5 ++++- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/ocaml/xapi-idl/xen/xenops_interface.ml b/ocaml/xapi-idl/xen/xenops_interface.ml index 083c345f149..68ef01b29c9 100644 --- a/ocaml/xapi-idl/xen/xenops_interface.ml +++ b/ocaml/xapi-idl/xen/xenops_interface.ml @@ -501,6 +501,8 @@ module Host = struct (** best effort placement on the smallest number of NUMA nodes where possible *) [@@deriving rpcty] + type numa_affinity_policy_opt = numa_affinity_policy option [@@deriving rpcty] + type guest_agent_feature_list = guest_agent_feature list [@@deriving rpcty] end @@ -657,7 +659,7 @@ module XenopsAPI (R : RPC) = struct let numa_affinity_policy_p = Param.mk ~description:["Host NUMA affinity policy"] - ~name:"numa_affinity_policy" Host.numa_affinity_policy + ~name:"numa_affinity_policy" Host.numa_affinity_policy_opt in declare "HOST.set_numa_affinity_policy" ["Sets the host's NUMA aware VM scheduling policy"] diff --git a/ocaml/xapi/xapi_xenops.ml b/ocaml/xapi/xapi_xenops.ml index 11e7f7c941f..77039e5fe3b 100644 --- a/ocaml/xapi/xapi_xenops.ml +++ b/ocaml/xapi/xapi_xenops.ml @@ -3098,11 +3098,11 @@ let set_numa_affinity_policy ~__context ~value = let open Xenops_interface.Host in match value with | `any -> - Any + Some Any | `best_effort -> - Best_effort + Some Best_effort | `default_policy -> - Any + None in Client.HOST.set_numa_affinity_policy dbg value diff --git a/ocaml/xenopsd/lib/xenops_server.ml b/ocaml/xenopsd/lib/xenops_server.ml index 350227aa028..5325a8b29ba 100644 --- a/ocaml/xenopsd/lib/xenops_server.ml +++ b/ocaml/xenopsd/lib/xenops_server.ml @@ -3398,8 +3398,13 @@ module VIF = struct () end +let default_numa_affinity_policy = ref Xenops_interface.Host.Any + let numa_placement = ref Xenops_interface.Host.Any +let string_of_numa_affinity_policy = + Xenops_interface.Host.(function Any -> "any" | Best_effort -> "best-effort") + module HOST = struct let stat _ dbg = Debug.with_thread_associated dbg @@ -3413,7 +3418,15 @@ module HOST = struct let set_numa_affinity_policy _ dbg = Debug.with_thread_associated dbg @@ fun policy -> debug "HOST.set_numa_affinity_policy" ; - numa_placement := policy + match policy with + | None -> + info "Enforcing default NUMA affinity policy (%s)" + (string_of_numa_affinity_policy !default_numa_affinity_policy) ; + numa_placement := !default_numa_affinity_policy + | Some p -> + info "Enforcing '%s' NUMA affinity policy" + (string_of_numa_affinity_policy p) ; + numa_placement := p let get_console_data _ dbg = Debug.with_thread_associated dbg diff --git a/ocaml/xenopsd/xc/xenops_server_xen.ml b/ocaml/xenopsd/xc/xenops_server_xen.ml index db54f18293d..6c6dd067ef7 100644 --- a/ocaml/xenopsd/xc/xenops_server_xen.ml +++ b/ocaml/xenopsd/xc/xenops_server_xen.ml @@ -5148,8 +5148,11 @@ let init () = {Xs_protocol.ACL.owner= 0; other= Xs_protocol.ACL.READ; acl= []} ) ; Device.Backend.init () ; - Xenops_server.numa_placement := + Xenops_server.default_numa_affinity_policy := if !Xenopsd.numa_placement_compat then Best_effort else Any ; + info "Default NUMA affinity policy is '%s'" + Xenops_server.(string_of_numa_affinity_policy !default_numa_affinity_policy) ; + Xenops_server.numa_placement := !Xenops_server.default_numa_affinity_policy ; Domain.numa_init () ; debug "xenstore is responding to requests" ; let () = Watcher.create_watcher_thread () in