From 785c9fd5128f09cf1e6895d61bfc7b96c8218f37 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Thu, 20 Nov 2025 04:36:58 -0500 Subject: [PATCH] tools: inform user which CVM is found during validation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit For AMD, the virt-host-validate 'secure guest' check reports support for SEV, and there are then further check results printed for SEV-ES/SEV-SNP which are overly verbose and the long lines break output alignment. This uses the new ability to report details with PASS results to concisely tell the user which out of SEV/SEV-ES/SEV-SNP are found. Only a single answer is neede, as SEV-SNP implies SEV & SEV-ES, and SEV-ES implies SEV. The TDX s390x PROT-VIRT checks also identify themselves. Reviewed-by: Peter Krempa Signed-off-by: Daniel P. Berrangé --- tools/virt-host-validate-common.c | 36 ++++++++----------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-common.c index 6516d96484..344f9656e5 100644 --- a/tools/virt-host-validate-common.c +++ b/tools/virt-host-validate-common.c @@ -378,8 +378,7 @@ bool virHostKernelModuleIsLoaded(const char *module) static int -virHostValidateAMDSev(const char *hvname, - virValidateLevel level) +virHostValidateAMDSev(virValidateLevel level) { g_autofree char *mod_value = NULL; uint32_t eax, ebx; @@ -405,31 +404,14 @@ virHostValidateAMDSev(const char *hvname, return VIR_VALIDATE_FAILURE(level); } - virValidatePass(); - - virValidateCheck(hvname, "%s", - _("Checking for AMD Secure Encrypted Virtualization-Encrypted State (SEV-ES)")); - virHostCPUX86GetCPUID(0x8000001F, 0, &eax, &ebx, NULL, NULL); - if (eax & (1U << 3)) { - virValidatePass(); - } else { - virValidateFail(level, - "AMD SEV-ES is not supported"); - return VIR_VALIDATE_FAILURE(level); - } - - virValidateCheck(hvname, "%s", - _("Checking for AMD Secure Encrypted Virtualization-Secure Nested Paging (SEV-SNP)")); - - if (eax & (1U << 4)) { - virValidatePass(); - } else { - virValidateFail(level, - "AMD SEV-SNP is not supported"); - return VIR_VALIDATE_FAILURE(level); - } + if (eax & (1U << 4)) + virValidatePassDetails("SEV-SNP"); + else if (eax & (1U << 3)) + virValidatePassDetails("SEV-ES"); + else + virValidatePassDetails("SEV"); return 1; } @@ -453,7 +435,7 @@ static int virHostValidateIntelTDX(virValidateLevel level) return VIR_VALIDATE_FAILURE(level); } - virValidatePass(); + virValidatePassDetails("TDX"); return 1; } @@ -496,7 +478,7 @@ int virHostValidateSecureGuests(const char *hvname, G_N_ELEMENTS(kIBMValues), VIR_KERNEL_CMDLINE_FLAGS_SEARCH_FIRST | VIR_KERNEL_CMDLINE_FLAGS_CMP_PREFIX)) { - virValidatePass(); + virValidatePassDetails("PROT-VIRT"); return 1; } else { virValidateFail(level, -- 2.47.3