From nobody Mon Apr 29 18:38:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1623141929; cv=none; d=zohomail.com; s=zohoarc; b=DjKJXd38iKtwYvYNE37AKqBy6vaV/DaXdXYi+ClTq/9JuHU94dd8rsaGxmP4rCNs5JpUMtSvUZJIUu3NURe6SLa6r4RWLOA3BItHCGERyYM7CqZgAJbhbbm4lKIAQ/o3VlHmjUSXcwAu4eAmQ0xRJK/asYA8UxV7ER+5gJV/ENA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623141929; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6URgwviM2K32ZHh3E6gTzSXht9io6FQg2fss/x/2KBE=; b=ARjR7FPlzHGpQTr0XvkoyA3Z00Ed6QpKvFFarax7L60V/ms1msXIP8OmYrQyyV1Lcega9uVVmwDcwDwjRkFGiBs1ITFrxJMDnhvBRj8RiwMJlmsdyv9/YKtcLHBiS6MQt6ZuidD4fOvnXFNtEFmFLpskjHGdFJHLERr3tOD4/vw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1623141929567258.87202024467456; Tue, 8 Jun 2021 01:45:29 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-77-QG_U6Li8OmSUbAWqPTCGpw-1; Tue, 08 Jun 2021 04:45:25 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AB52164149; Tue, 8 Jun 2021 08:45:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8537460C04; Tue, 8 Jun 2021 08:45:19 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 01BB244A5B; Tue, 8 Jun 2021 08:45:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1588jHTK007043 for ; Tue, 8 Jun 2021 04:45:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 04D755D75A; Tue, 8 Jun 2021 08:45:17 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.90]) by smtp.corp.redhat.com (Postfix) with ESMTP id 784AE5D736 for ; Tue, 8 Jun 2021 08:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623141928; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=6URgwviM2K32ZHh3E6gTzSXht9io6FQg2fss/x/2KBE=; b=gKBiVJo+GYMjf3VgZi5NOcc/sa9nbQNf/nXD3o0jdHTZHb2FdewEAmkgaM7CG+ICXMDgqC TIXLCPjOPrNw7FpjxDykzDF3A2g8OfRkjytPY8yRptzhKjU/CXEq29/uZi9uJuUCfMseAM ZuH+CPwjPpvdQBrh3pQdjZwbdv9M9Zo= X-MC-Unique: QG_U6Li8OmSUbAWqPTCGpw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/5] virt-host-validate: Initialize the error object Date: Tue, 8 Jun 2021 10:45:06 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Several libvirt functions are called from virt-host-validate. Some of these functions do report an error on failure. But reporting an error is coupled with freeing previous error (by calling virResetError()). But we've never called virErrorInitialize() and thus resetting error object frees some random pointer. Signed-off-by: Michal Privoznik Reviewed-by: Fabiano Fid=C3=AAncio Reviewed-by: J=C3=A1n Tomko --- tools/virt-host-validate.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/virt-host-validate.c b/tools/virt-host-validate.c index c119d649ce..806d61bc8e 100644 --- a/tools/virt-host-validate.c +++ b/tools/virt-host-validate.c @@ -27,6 +27,7 @@ #include =20 #include "internal.h" +#include "virerror.h" #include "virgettext.h" =20 #include "virt-host-validate-common.h" @@ -83,8 +84,11 @@ main(int argc, char **argv) bool quiet =3D false; bool usedHvname =3D false; =20 - if (virGettextInitialize() < 0) + if (virGettextInitialize() < 0 || + virErrorInitialize() < 0) { + fprintf(stderr, _("%s: initialization failed\n"), argv[0]); return EXIT_FAILURE; + } =20 while ((c =3D getopt_long(argc, argv, "hvq", argOptions, NULL)) !=3D -= 1) { switch (c) { --=20 2.31.1 From nobody Mon Apr 29 18:38:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1623141928; cv=none; d=zohomail.com; s=zohoarc; b=COblTF9v+Xw16FRK5CiTbLEiqlRSd6ZMQoEynIeSHo7WprYkKt3z6nIZOUYZ9qRIFzn8KhCGgvMGsC2/hGea9tM6y3Pb/IInC0LDECmciS6dYenxwFg2m4bSiPV92Yp6Wtw9NT/RxU8SmO3zt7CyiOTqAu9Nnv5cc4jgVIU5SjA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623141928; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RNRwH+H+lhZnwqANM+8MkEZ+88wdGjsIAUP+xo1XTzA=; b=mR/r17kUX2m3yA74yR0IPVUdjbubvHXIeeqZr6hmQzC6W6ipiCghrW3t7E5sI6LitL5ZV5O+huN0ZKESDSnnkxvJJvUz/C1Lpl+sjKkGFur6+xYbqTH2Ko+xua2W4/bYOIosJARYaDpfDnFFVi0CECLuKR9GNQm1H5gbVKflK+U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1623141928862625.611680439682; Tue, 8 Jun 2021 01:45:28 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-518-PZxNLYW1NaSuXLbqL_R4RQ-1; Tue, 08 Jun 2021 04:45:24 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B818F107ACCD; Tue, 8 Jun 2021 08:45:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 936865D9DE; Tue, 8 Jun 2021 08:45:19 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2B1311801265; Tue, 8 Jun 2021 08:45:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1588jHIw007048 for ; Tue, 8 Jun 2021 04:45:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id CF1C55D736; Tue, 8 Jun 2021 08:45:17 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.90]) by smtp.corp.redhat.com (Postfix) with ESMTP id 516B75D75A for ; Tue, 8 Jun 2021 08:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623141925; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=RNRwH+H+lhZnwqANM+8MkEZ+88wdGjsIAUP+xo1XTzA=; b=Z/wOV2/lIxwY8hvSr9gF0HAeNYeC6KvXKtV8ev+yVc/gYzjbGMZ9vkZ5xYeIl9tepWCLdp enY+22o71AeZaZXAo2pEDaBEUkXBKdhx2U7wyZB/q02S52o97NATKHgxcKmOrsXZf4pY+Y zkJnnZ4rCmMrHUJu6gG8gOy9HFp+NRQ= X-MC-Unique: PZxNLYW1NaSuXLbqL_R4RQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/5] virt-host-validate: Report an error if failed to detect CGroups Date: Tue, 8 Jun 2021 10:45:07 +0200 Message-Id: <2a2114d6ac6118f5276d45b69b3ba5f65c0c0f62.1623141866.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" As a part of its checks, virt-host-validate calls virCgroupNew() to detect CGroup controllers which are then printed out. However, virCgroupNew() can fail (with appropriate error message set). Let's print an error onto stderr if that happens. Signed-off-by: Michal Privoznik Reviewed-by: Fabiano Fid=C3=AAncio Reviewed-by: J=C3=A1n Tomko --- tools/virt-host-validate-common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-c= ommon.c index 9412bb7514..c0cee43409 100644 --- a/tools/virt-host-validate-common.c +++ b/tools/virt-host-validate-common.c @@ -290,8 +290,11 @@ int virHostValidateCGroupControllers(const char *hvnam= e, int ret =3D 0; size_t i; =20 - if (virCgroupNew("/", -1, &group) < 0) + if (virCgroupNew("/", -1, &group) < 0) { + fprintf(stderr, "Unable to initialize cgroups: %s\n", + virGetLastErrorMessage()); return VIR_HOST_VALIDATE_FAILURE(level); + } =20 for (i =3D 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { int flag =3D 1 << i; --=20 2.31.1 From nobody Mon Apr 29 18:38:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1623141935; cv=none; d=zohomail.com; s=zohoarc; b=VzYAeSCG1Lx/lxNDMwXo7a4k7kA8UCzS1EO0MOEYQxfrgoNJ45kjJBDzi95dTMMKaNQc6mSKH+eUDBhjflgjJXk/42DK99CXc1gWzTg6b0wOKirCwuHaoP2roX2ILg6HAjtfy7AuS4gaXI8fNjpxZ22hhBDt03UU9OiTY6bnsoQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623141935; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=03x20sJ7o33jRz0M+FPVquWHf0yeqE6iiz69E4f+icI=; b=P1eHX//A3kxZCdpx1LzxeX9TRnF4bTWfoEQjvbvZWvACyetF7HpHcGeLU82GobYFlxYouGFbQPdtAOtQF63YD1lU+hy/8R5PY3h+E68VtVQDIX/r3WRf4Kfh/bmuuopjK6jMBAyJ/nYMDnIoLPmd8dySDdfq+5fTggYZQliVkUQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1623141935128520.1635218542527; Tue, 8 Jun 2021 01:45:35 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-164-Imi1RkOzPH6-Ty7ptVzMDw-1; Tue, 08 Jun 2021 04:45:32 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A711C106BB24; Tue, 8 Jun 2021 08:45:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 864AF60C04; Tue, 8 Jun 2021 08:45:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4DC3944A5F; Tue, 8 Jun 2021 08:45:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1588jIj7007053 for ; Tue, 8 Jun 2021 04:45:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id AF1005D736; Tue, 8 Jun 2021 08:45:18 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.90]) by smtp.corp.redhat.com (Postfix) with ESMTP id 31FF35D75A for ; Tue, 8 Jun 2021 08:45:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623141934; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=03x20sJ7o33jRz0M+FPVquWHf0yeqE6iiz69E4f+icI=; b=hrVnyM9buuYvkGsrX1OB9dSJ/yArhsilYPOUxUOa5DA92FiLldJ0LN+GHU81BIc88LCjUZ ha+Zm5b72BC94JHsYYj2yZp61/Z5hKV3PkrrB9UmlBbrqZAZlXT1Fh1XgbBaszygMe3WgL wbtTezhVYtg6/bGPNzb3LjXLxSgzuz4= X-MC-Unique: Imi1RkOzPH6-Ty7ptVzMDw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/5] virt-host-validate: Turn failure to read /proc/cmdline into an error Date: Tue, 8 Jun 2021 10:45:08 +0200 Message-Id: <2b1b8d32de547d1591c769215c02ca531a080eb8.1623141866.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 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: Fabiano Fid=C3=AAncio Reviewed-by: J=C3=A1n Tomko --- 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-c= ommon.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; } =20 - if (virFileReadValueString(&cmdline, "/proc/cmdline") < 0) - return VIR_HOST_VALIDATE_FAILURE(level); - /* we're prefix matching rather than equality matching here, b= ecause * kernel would treat even something like prot_virt=3D'yFOO' as * enabled */ - if (virKernelCmdlineMatchParam(cmdline, "prot_virt", kIBMValue= s, + if (virFileReadValueString(&cmdline, "/proc/cmdline") >=3D 0 && + virKernelCmdlineMatchParam(cmdline, "prot_virt", kIBMValue= s, G_N_ELEMENTS(kIBMValues), VIR_KERNEL_CMDLINE_FLAGS_SEARCH= _FIRST | VIR_KERNEL_CMDLINE_FLAGS_CMP_PR= EFIX)) { --=20 2.31.1 From nobody Mon Apr 29 18:38:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1623141937; cv=none; d=zohomail.com; s=zohoarc; b=eRvl4fu0levWHcc9QCp3jm8ks/wNsL69sVezETWYmmfxDKagwa2LMYN8y9mzx6y8/bh23NY7hVLKRvZpu5kLkJVoobP/c9ulzuarsGVGDzb9cdigX4YL0gwqvroIqB7X5h9Sk5tIy3IgZmF+EZh0npezYolxQg2VU6u932bxhO4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623141937; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=on6anguM57NoZaGmOJynOanhFCEmZfPdNhH6/xmYGok=; b=Q1o+XWXuXm4U40Os3HvPafC0IZTJccIZsQzTNM0i+K6is3auslXLYXsybR87db0l6dKwyQDjzH9EJVTSjAwqphc9EhSkmy3+//O5ihqYVrbzm+//CH0ingSw4fafSGisCxUrepTSHIWkV3qn84MTgVntLk7DxFmH2gfJPP1DNjA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1623141937267824.1957563254732; Tue, 8 Jun 2021 01:45:37 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-552-SGpykKgSOgG3EFvFxH-jyg-1; Tue, 08 Jun 2021 04:45:34 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 96B45106BB29; Tue, 8 Jun 2021 08:45:29 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 72DEF5D9E3; Tue, 8 Jun 2021 08:45:29 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 13F2F1801267; Tue, 8 Jun 2021 08:45:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1588jJct007059 for ; Tue, 8 Jun 2021 04:45:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 89D125D75A; Tue, 8 Jun 2021 08:45:19 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.90]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0CE2B5D736 for ; Tue, 8 Jun 2021 08:45:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623141936; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=on6anguM57NoZaGmOJynOanhFCEmZfPdNhH6/xmYGok=; b=IFJ1Q9Kg/v5mnR6TZX9Jv4cUccvQ5KIYyDvJZGtV391fXnI+xwLKO6PYkNmLB69VhxaLpj aGIK0MENGI8J09pchvNTgD+bXeEBVgRNQmvjgVUh5hJHL0MbXcjy0vEF4I1xv3RZglkSaA hKMKFUR3Tc5YvvIEBihoZEYHGuB4Xns= X-MC-Unique: SGpykKgSOgG3EFvFxH-jyg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/5] virt-host-validate: Call VIR_HOST_VALIDATE_FAILURE() more frequently Date: Tue, 8 Jun 2021 10:45:09 +0200 Message-Id: <19f14bfbf8180a49e5894ffb2bc127e78ceaaf18.1623141866.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Ideally, every virHostMsgFail() would be coupled with VIR_HOST_VALIDATE_FAILURE() so that the failure is correctly propagated to the caller. However, in virHostValidateSecureGuests() we are either ignoring @level and returning 0 directly (no error), or not returning at all, relying on 'return 0' at the end of the function. Neither of these help propagate failure correctly. Signed-off-by: Michal Privoznik Reviewed-by: Fabiano Fid=C3=AAncio Reviewed-by: J=C3=A1n Tomko --- tools/virt-host-validate-common.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-c= ommon.c index 4482690b4b..9ec4e6f00b 100644 --- a/tools/virt-host-validate-common.c +++ b/tools/virt-host-validate-common.c @@ -467,7 +467,7 @@ int virHostValidateSecureGuests(const char *hvname, if (!virFileIsDir("/sys/firmware/uv")) { virHostMsgFail(level, "IBM Secure Execution not supported = by " "the currently used kernel"); - return 0; + return VIR_HOST_VALIDATE_FAILURE(level); } =20 /* we're prefix matching rather than equality matching here, b= ecause @@ -486,16 +486,18 @@ int virHostValidateSecureGuests(const char *hvname, "IBM Secure Execution appears to be disable= d " "in kernel. Add prot_virt=3D1 to kernel cmd= line " "arguments"); + return VIR_HOST_VALIDATE_FAILURE(level); } } else { virHostMsgFail(level, "Hardware or firmware does not provide " "support for IBM Secure Execution"); + return VIR_HOST_VALIDATE_FAILURE(level); } } else if (hasAMDSev) { if (virFileReadValueString(&mod_value, "/sys/module/kvm_amd/parame= ters/sev") < 0) { virHostMsgFail(level, "AMD Secure Encrypted Virtualization not= " "supported by the currently used kernel"= ); - return 0; + return VIR_HOST_VALIDATE_FAILURE(level); } =20 if (mod_value[0] !=3D '1') { @@ -503,7 +505,7 @@ int virHostValidateSecureGuests(const char *hvname, "AMD Secure Encrypted Virtualization appears to= be " "disabled in kernel. Add kvm_amd.sev=3D1 " "to the kernel cmdline arguments"); - return 0; + return VIR_HOST_VALIDATE_FAILURE(level); } =20 if (virFileExists("/dev/sev")) { @@ -513,6 +515,7 @@ int virHostValidateSecureGuests(const char *hvname, virHostMsgFail(level, "AMD Secure Encrypted Virtualization appears to= be " "disabled in firemare."); + return VIR_HOST_VALIDATE_FAILURE(level); } } else { virHostMsgFail(level, --=20 2.31.1 From nobody Mon Apr 29 18:38:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1623141939; cv=none; d=zohomail.com; s=zohoarc; b=Mg4PSB3GXyyOu5fBoai7LuCJ3DHUcaVpD5KPpE5eMOGY+DP8g5MI/nXX5R2JboWFWMBjDpIprej23QkORUnXu6HXp/M6+uof/vvY3/tQZc5aMSLgp44jILT9PS9qSmC17aqrqW0FxoRJYkCjwmFa8pilqYBUCJy6bI3M+vqsTQE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623141939; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fGoKm0G8LyX7QfZnH9GsKH3QxUyX7ucYdINzQ01EkOE=; b=AkJ1/CMZbVHa8JG3f60JYOriLXsLUnf98+i0ykYgZvB45Gddowi27wHZ71tteKLhLCtqDAF6ENHcxVSzbgg3IgpLEQ7Q3jt7AB8DJl5PhgxkrgY8jAOhLUknfCG9BnHuA/TpNYIqiuAAiQnzMfjpmfLj+cZy5WlUeRpL3lmCcw8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1623141939179973.7005851472414; Tue, 8 Jun 2021 01:45:39 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-150-xctUVHm9OSWotHQrB3glIA-1; Tue, 08 Jun 2021 04:45:36 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 46D40800D62; Tue, 8 Jun 2021 08:45:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2AA4F6060F; Tue, 8 Jun 2021 08:45:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id ECA5D18033F6; Tue, 8 Jun 2021 08:45:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1588jK28007064 for ; Tue, 8 Jun 2021 04:45:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6B2E55D764; Tue, 8 Jun 2021 08:45:20 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.90]) by smtp.corp.redhat.com (Postfix) with ESMTP id DDD495D75A for ; Tue, 8 Jun 2021 08:45:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623141938; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=fGoKm0G8LyX7QfZnH9GsKH3QxUyX7ucYdINzQ01EkOE=; b=IU8yQImmXOd7gFcVpdpxIEQAId8DNlxanPmEjumAtA+n+meI3x8NtH6k4aAUsL0N0VT3py IojWp9t7flKLARRK//Nq8SOn1hDv6cCMbokKFA7siha078+pbvFQ7q5bxTJ4aAA1C9yQKB ZXHhIz92Hw42yoh+paqp3QFBy2jQHJY= X-MC-Unique: xctUVHm9OSWotHQrB3glIA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 5/5] virHostValidateSecureGuests: Drop useless 'return 0' at the end Date: Tue, 8 Jun 2021 10:45:10 +0200 Message-Id: <6373fcc0540e46b536c02fbe26b0cd375f8ef90b.1623141866.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Previous patches rendered 'return 0' at the end of the function a dead code. Therefore, the code can be rearranged a bit and the line can be dropped. Signed-off-by: Michal Privoznik Reviewed-by: Fabiano Fid=C3=AAncio Reviewed-by: J=C3=A1n Tomko --- tools/virt-host-validate-common.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-c= ommon.c index 9ec4e6f00b..8ce45609e7 100644 --- a/tools/virt-host-validate-common.c +++ b/tools/virt-host-validate-common.c @@ -517,11 +517,9 @@ int virHostValidateSecureGuests(const char *hvname, "disabled in firemare."); return VIR_HOST_VALIDATE_FAILURE(level); } - } else { - virHostMsgFail(level, - "Unknown if this platform has Secure Guest support"= ); - return VIR_HOST_VALIDATE_FAILURE(level); } =20 - return 0; + virHostMsgFail(level, + "Unknown if this platform has Secure Guest support"); + return VIR_HOST_VALIDATE_FAILURE(level); } --=20 2.31.1