Skip to content

Feature UEFI expiry: Implement VM.secureboot_certificates_state tracking#7015

Open
stephenchengCloud wants to merge 4 commits intoxapi-project:feature/uefi_expiryfrom
stephenchengCloud:private/stephenche/CP-311908
Open

Feature UEFI expiry: Implement VM.secureboot_certificates_state tracking#7015
stephenchengCloud wants to merge 4 commits intoxapi-project:feature/uefi_expiryfrom
stephenchengCloud:private/stephenche/CP-311908

Conversation

@stephenchengCloud
Copy link
Copy Markdown
Collaborator

Background

Microsoft Secure Boot certificates from 2011 are reaching end-of-life, and legacy VMs may still contain only the old certificate set. This PR implements the xapi side of the out-of-band mechanism to track and update per-VM UEFI Secure Boot variables safely, as described in the design doc.

Changes

Sorry for the large PR, but the changes form a single feature.
The two main commits are:

1. CP-311907: Add VM.secureboot_certificates_state field

Add a new DynamicRO field to track Secure Boot certificate status per VM. The field indicates whether UEFI Secure Boot certificates need updating.

  • Invoke varstore-nvram-certcheck to determine certificate state from the NVRAM EFI-variables blob
  • On DB upgrade: compute state for existing UEFI Secure Boot VMs, skipping control domains and default templates
  • On import: compute state for VMs imported from older pools that lack the field
  • On clone/snapshot: copy the state to the new VM

2. CP-311908: Add versioned update parameter to VM.set_NVRAM_EFI_variables

Add a versioned update parameter (enum: yes/no/unspecified) so varstored can report whether certificates were changed during an NVRAM write. This avoids invoking the certcheck binary on every NVRAM write.

  • update=yes: certificates were updated → set state to ok
  • update=no: certificates not changed → preserve current state
  • update=unspecified (default for legacy v1 callers): run certcheck to determine state
  • Register set_NVRAM_v2 RPC in xapi-guard, mapping the string parameter to the enum

Testing

Tested the following scenarios with the updated varstored:

  • State transitions: okupdate_availableupdate_on_bootok verified correct
  • VM reboot with certificate update: varstored sends update=yes, state transitions to ok
  • VM reboot without certificate update: varstored sends update=no, state is preserved
  • Cross-host live migration (old host → new host, new host → new host): secureboot_certificates_state is correctly preserved

Stephen Cheng and others added 4 commits April 16, 2026 10:09
Add a new DynamicRO field to track Secure Boot certificate status per VM.
The field indicates whether UEFI Secure Boot certificates need updating.

- Define enum (ok, update_available, update_on_boot) and field in datamodel
- Check certificate state via varstore-nvram-certcheck on import and
  DB upgrade for UEFI Secure Boot VMs
- Skip control domains, default templates, and non-Secure Boot VMs
  in the DB upgrade rule

Signed-off-by: Stephen Cheng <stephen.cheng@citrix.com>
…eter

Add a new versioned parameter 'update' to VM.set_NVRAM_EFI_variables,
allowing varstored to indicate whether Secure Boot certificates were
changed during an NVRAM write. This enables xapi to maintain the
VM.secureboot_certificates_state field accurately.

The 'update' parameter is an enum with three values:
- 'yes': certificates were updated, set state to 'ok'
- 'no': certificates unchanged, keep current state as-is
- 'unspecified': (default for v1 callers) run certcheck to determine state

Signed-off-by: Stephen Cheng <stephen.cheng@citrix.com>
Signed-off-by: Chunjie Zhu <chunjie.zhu@cloud.com>
Signed-off-by: Stephen Cheng <stephen.cheng@citrix.com>
Comment thread ocaml/idl/datamodel_vm.ml
; {
param_type=
Enum
( "update_status"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I understand these 3 are actually the actions (action) to be performed:

  1. set_state_ok
  2. noop
  3. check_state

)
(fun () -> Xapi_stdext_unix.Unixext.unlink_safe tmp_path)
in
match result with
Copy link
Copy Markdown
Member

@minglumlu minglumlu Apr 16, 2026

Choose a reason for hiding this comment

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

We could just let the Forkhelpers exceptions handled within function check_secureboot_certificates_state so that we could expect a clean output type of this function, like using result.

in
match result with
| "update_required" ->
`update_available
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

May be better to make it explicit that this function will never return update_on_boot by using an explicit typing annotation or a variant instead of polymorphic variant.

@psafont
Copy link
Copy Markdown
Member

psafont commented Apr 16, 2026

On import: compute state for VMs imported from older pools that lack the field
On clone/snapshot: copy the state to the new VM

I'm not convinced that copying the field is the right thing to do, I've commented in the design about the possibility of the field becoming stale after a VM has been exported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants