From 7ea5a80dc143cd218e83e9976c7cbe77c84e384b Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Tue, 8 Jun 2021 09:21:27 +0200 Subject: [PATCH] virt-host-validate: Turn failure to read /proc/cmdline into an error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When validating secure guests support on s390(x) we may read /proc/cmdline and look for "prot_virt" argument. Reading the kernel command line is done via virFileReadValueString() which may fail. In such case caller won't see any error message. But we can produce the same warning/error as if "prot_virt" argument wasn't found. Not only this lets users know about the problem, it also terminates the "Checking for ...." line correctly. Signed-off-by: Michal Privoznik Reviewed-by: Ján Tomko Reviewed-by: Fabiano Fidêncio --- tools/virt-host-validate-common.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-common.c index c0cee43409..4482690b4b 100644 --- a/tools/virt-host-validate-common.c +++ b/tools/virt-host-validate-common.c @@ -470,14 +470,12 @@ int virHostValidateSecureGuests(const char *hvname, return 0; } - if (virFileReadValueString(&cmdline, "/proc/cmdline") < 0) - return VIR_HOST_VALIDATE_FAILURE(level); - /* we're prefix matching rather than equality matching here, because * kernel would treat even something like prot_virt='yFOO' as * enabled */ - if (virKernelCmdlineMatchParam(cmdline, "prot_virt", kIBMValues, + if (virFileReadValueString(&cmdline, "/proc/cmdline") >= 0 && + virKernelCmdlineMatchParam(cmdline, "prot_virt", kIBMValues, G_N_ELEMENTS(kIBMValues), VIR_KERNEL_CMDLINE_FLAGS_SEARCH_FIRST | VIR_KERNEL_CMDLINE_FLAGS_CMP_PREFIX)) {