Skip to content

Commit e8506b1

Browse files
authored
CP-311165 XSI-1958 rely on Linux guest to announce control features (#6864)
We want to rely on a Linux guest kernel to announce supported control features like suspend. In the unlikely case that a guest Linux kernel does not support this, provide a flag to re-enable previous behavior: the toolstack assumes a set of supported features. Linux kernel 3.0 and above announce features. The flag is false by default, as such introducing the new behaviour. This closes a window for a data race that caused XSI-1958: the toolstack announced control features before the Linux guest kernel was ready and announced them a moment later. A request coming in before the kernel was ready caused the request to be missed by the kernel. Previous behavior and timing is below: observe that dom0 announces the features before domain 7. Some details are omitted. 2026-01-27T10:22:04 dt034 oxd: DOM0 write /l/d/7/control/feature-suspend 1 2026-01-27T10:22:04 dt034 oxd: DOM0 write /l/d/7/control/feature-poweroff 1 2026-01-27T10:22:04 dt034 oxd: DOM0 write /l/d/7/control/feature-reboot 1 2026-01-27T10:22:04 dt034 oxd: DOM0 write /l/d/7/control/feature-vcpu-hotplug 1 2026-01-27T10:22:06 dt034 oxd: DOM7 write control/feature-poweroff 1 2026-01-27T10:22:06 dt034 oxd: DOM7 write control/feature-reboot 1 2026-01-27T10:22:06 dt034 oxd: DOM7 write control/feature-suspend 1 2026-01-27T10:22:10 dt034 oxd: DOM7 write control/feature-balloon 1
2 parents 3cd9646 + 7adae02 commit e8506b1

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

ocaml/xenopsd/lib/xenopsd.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ let vm_suspend_timeout = ref 1200.
8181

8282
let vm_suspend_ack_timeout = ref 30.
8383

84+
let linux_assume_ctrl_features = ref false
85+
8486
let oxenstored_conf = ref "/etc/xen/oxenstored.conf"
8587

8688
let for_each_line path f =
@@ -324,6 +326,13 @@ let options =
324326
, (fun () -> string_of_bool !Xenops_server.xenopsd_vbd_plug_unplug_legacy)
325327
, "False if we want to split the plug atomic into attach/activate"
326328
)
329+
; ( "linux-assume-control-features"
330+
, Arg.Bool (fun b -> linux_assume_ctrl_features := b)
331+
, (fun () -> string_of_bool !linux_assume_ctrl_features)
332+
, "To support old Linux guest kernels, assume the kernel supports certain \
333+
control features without announcing them. Linux kernels 4.9 and later \
334+
announce support in xenstore."
335+
)
327336
; ( "vm-suspend-timeout"
328337
, Arg.Set_float vm_suspend_timeout
329338
, (fun () -> string_of_float !vm_suspend_timeout)

ocaml/xenopsd/xc/device.ml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2980,6 +2980,16 @@ module Backend = struct
29802980
)
29812981
in
29822982
let xen_platform_pv_driver_info pv_info =
2983+
(* we would like to keep the assumptions about supported
2984+
features small and rather have the Linux kernel or a guest agent
2985+
announce the actually supported featuresi. See commit message *)
2986+
let features =
2987+
match !Xenopsd.linux_assume_ctrl_features with
2988+
| true ->
2989+
["suspend"; "poweroff"; "reboot"; "vcpu-hotplug"]
2990+
| false ->
2991+
["vcpu-hotplug"]
2992+
in
29832993
with_xs (fun xs ->
29842994
let is_hvm_linux {product_num; build_num} =
29852995
let _XEN_IOPORT_LINUX_PRODNUM = 3 in
@@ -2992,9 +3002,7 @@ module Backend = struct
29923002
(Printf.sprintf "/local/domain/%d/%s%s" domid prefix x)
29933003
"1"
29943004
in
2995-
List.iter
2996-
(write_local_domain "control/feature-")
2997-
["suspend"; "poweroff"; "reboot"; "vcpu-hotplug"] ;
3005+
List.iter (write_local_domain "control/feature-") features ;
29983006
List.iter (write_local_domain "data/") ["updated"]
29993007
)
30003008
)

ocaml/xenopsd/xenopsd.conf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,11 @@ disable-logging-for=http tracing tracing_export
122122

123123
# Timeout in seconds for a VM to acknowledge a suspend request
124124
# vm-suspend-ack-timeout=30
125+
#
126+
127+
# A Linux guest kernel 4.9+ announces the control features it supports in
128+
# xenstore. If it does not, xenopsd has to assume it supports a range of
129+
# operations. The default "false" is to rely on guest kernels to announce
130+
# support. Use "true" to assume support even when unannounced.
131+
# linux-assume-control-features = false
132+

0 commit comments

Comments
 (0)