Skip to content

Commit 3b7b0cb

Browse files
committed
Add secureboot-enforce setting in xapi.conf
This setting will be used by varstored to know wheter to allow the start of a VM that has no certificates when secureboot is enabled by writing in the xenstore in `/local/domain/<domid>/platform/secureboot-enforce`. Default: false to keep the previous behavior. See: xapi-project/varstored#19 Signed-off-by: BenjiReis <[email protected]>
1 parent 9fce1a2 commit 3b7b0cb

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

ocaml/xapi/xapi_globs.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,8 @@ let prefer_nbd_attach = ref false
998998
(** 1 MiB *)
999999
let max_observer_file_size = ref (1 lsl 20)
10001000

1001+
let secureboot_enforce = ref false
1002+
10011003
let xapi_globs_spec =
10021004
[
10031005
( "master_connection_reset_timeout"
@@ -1470,6 +1472,11 @@ let other_options =
14701472
, (fun () -> string_of_int !max_observer_file_size)
14711473
, "The maximum size of log files for saving spans"
14721474
)
1475+
; ( "secureboot-enforce"
1476+
, Arg.Set secureboot_enforce
1477+
, (fun () -> string_of_bool !secureboot_enforce)
1478+
, "Do not start a VM with no SB certificates if secureboot is set to on"
1479+
)
14731480
]
14741481

14751482
(* The options can be set with the variable xapiflags in /etc/sysconfig/xapi.

ocaml/xapi/xapi_vm.ml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ let assert_memory_constraints ~__context ~vm platformdata =
286286
*)
287287

288288
let update_platform_secureboot ~__context ~self platform =
289-
match List.assoc "secureboot" platform with
289+
let platform = match List.assoc "secureboot" platform with
290290
| exception Not_found ->
291291
platform
292292
| "auto" ->
@@ -296,6 +296,11 @@ let update_platform_secureboot ~__context ~self platform =
296296
:: List.remove_assoc "secureboot" platform
297297
| _ ->
298298
platform
299+
in
300+
if !Xapi_globs.secureboot_enforce then
301+
("secureboot-enforce", "true") :: List.remove_assoc "secureboot-enforce" platform
302+
else
303+
platform
299304

300305
let start ~__context ~vm ~start_paused ~force =
301306
let vmr = Db.VM.get_record ~__context ~self:vm in
@@ -664,9 +669,9 @@ let create ~__context ~name_label ~name_description ~power_state ~user_version
664669
~memory_static_min ~vCPUs_params ~vCPUs_at_startup ~vCPUs_max
665670
~actions_after_softreboot ~actions_after_shutdown ~actions_after_reboot
666671
~actions_after_crash ~hVM_boot_policy ~hVM_boot_params
667-
~hVM_shadow_multiplier ~suspend_VDI:_suspend_VDI ~platform ~nVRAM ~pV_kernel
668-
~pV_ramdisk ~pV_args ~pV_bootloader ~pV_bootloader_args ~pV_legacy_args
669-
~pCI_bus ~other_config ~domid:(-1L) ~domarch:""
672+
~hVM_shadow_multiplier ~suspend_VDI:_suspend_VDI ~platform:_platform ~nVRAM
673+
~pV_kernel ~pV_ramdisk ~pV_args ~pV_bootloader ~pV_bootloader_args
674+
~pV_legacy_args ~pCI_bus ~other_config ~domid:(-1L) ~domarch:""
670675
~last_boot_CPU_flags:_last_boot_CPU_flags ~is_control_domain:false ~metrics
671676
~guest_metrics:Ref.null ~last_booted_record:_last_booted_record
672677
~xenstore_data ~recommendations ~blobs:[] ~ha_restart_priority

0 commit comments

Comments
 (0)