From 7b8e0f2291d18f633603e9d780e271ef4b7095f8 Mon Sep 17 00:00:00 2001 From: Pau Ruiz Safont Date: Wed, 7 Sep 2022 15:22:23 +0100 Subject: [PATCH] CP-40672: set platform/tpm_version xenstore key on vm construction This allows hvmloader to load the correct acpi table for guests using tpm, while retaining the previous acpi table for existing guests Signed-off-by: Pau Ruiz Safont --- ocaml/xapi/vm_platform.ml | 2 ++ ocaml/xapi/xapi_xenops.ml | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/ocaml/xapi/vm_platform.ml b/ocaml/xapi/vm_platform.ml index e87efae2825..bfa2378dde6 100644 --- a/ocaml/xapi/vm_platform.ml +++ b/ocaml/xapi/vm_platform.ml @@ -63,6 +63,8 @@ let nested_virt = "nested-virt" let vcpu_unrestricted = "vcpu-unrestricted" +let tpm_version = "tpm_version" + (* The default value of device model should be set as 'qemu-trad', 'qemu-upstream-compat', 'qemu-upstream' according to QEMU-upstream feature release stages *) let fallback_device_model_stage_1 = "qemu-trad" diff --git a/ocaml/xapi/xapi_xenops.ml b/ocaml/xapi/xapi_xenops.ml index 72cf25a8b46..d79f77538b7 100644 --- a/ocaml/xapi/xapi_xenops.ml +++ b/ocaml/xapi/xapi_xenops.ml @@ -1261,6 +1261,15 @@ module MD = struct else platformdata in + (* Add TPM version 2 iff there's a tpm attached to the VM, this allows + hvmloader to load the TPM 2.0 ACPI table while maintaing the current + ACPI table for other guests *) + let platformdata = + if vm.API.vM_VTPMs <> [] || bool vm.API.vM_platform false "vtpm" then + (Vm_platform.tpm_version, "2") :: platformdata + else + platformdata + in let pci_msitranslate = true in (* default setting *) (* CA-55754: allow VM.other_config:msitranslate to override the bus-wide setting *)