From nobody Mon Feb 9 23:44:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1665479200; cv=none; d=zohomail.com; s=zohoarc; b=dve1c/kR6IfIQFdetuQY9lR3pv6fY3nlYcNP9rLv9p1kTCNk/I1odzDbD/VJKCLIOMsMIGIcKm032uwCi9EcylqdbeY2qJiF5iyu10QZbrZBeyCU+msK8h6UIXauTwbYZu9fe2pn1Fdr+SvOAxEtQlXsVQIoHFKl7JYQwzMHw7M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665479200; h=Content-Type:Content-Transfer-Encoding:Cc: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=aHw6k5nJvK7DEt7bjLyvPgNAck4ylEKZWP8BVMgC8Wo=; b=OfWx3JDvM02ZPhmQlg3kw7OpIW9UnAQ5eKRosBQN/v1fohjG0EeViDnWWzeAOcPiBJW5+1Z256DMbOTlSAlUzhzk8sUbFoJrVtTmrZ3vNklkCS4+j+Noui2aJZyHFXD13Zs0xT5zBjlx9NYKyaJ2P4LQZXA+rNLE6T4mejSXk4c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1665479199994982.8858923767253; Tue, 11 Oct 2022 02:06:39 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-191-2xftkT4cOSmy4cSHKomkBw-1; Tue, 11 Oct 2022 05:06:34 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6F582862FE3; Tue, 11 Oct 2022 09:06:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D630414A809; Tue, 11 Oct 2022 09:06:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 148D81946A61; Tue, 11 Oct 2022 09:06:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B87E719465A0 for ; Tue, 11 Oct 2022 09:06:25 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AA6621121319; Tue, 11 Oct 2022 09:06:25 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 017F61121314; Tue, 11 Oct 2022 09:06:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665479198; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=aHw6k5nJvK7DEt7bjLyvPgNAck4ylEKZWP8BVMgC8Wo=; b=G0AdL7u9z7a3DG53Ofh7AtGghq0/zibWtiXseM2Uhl40Jq8FK4hYhD/BCGkNKE/LHK2TGC JObEvUWi+mMACwrjdJTX0hmap0xirYuma2L3SNlXvpH8aAFGVK/8hfxQqlVJtVDD2ugbGs 2ShaYscO1LgWdQ9aJOJfsIGkdmYXYck= X-MC-Unique: 2xftkT4cOSmy4cSHKomkBw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 2/2] conf: skip resource cache init if sysfs files are missing Date: Tue, 11 Oct 2022 10:06:21 +0100 Message-Id: <20221011090621.1712993-3-berrange@redhat.com> In-Reply-To: <20221011090621.1712993-1-berrange@redhat.com> References: <20221011090621.1712993-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665479200305100005 On aarch64 the 'id' file is not present for CPU cache information in sysfs. This causes the local stateful hypervisor drivers to fail to initialize capabilities: virStateInitialize:657 : Initialisation of cloud-hypervisor state driver fa= iled: no error The 'no error' is because the 'virFileReadValueNNN' methods return ret=3D=3D-2, with no error raised, when the requeted file does not exist. None of the callers were checking for this scenario when populating capabilities. The most graceful way to handle this is to skip the cache bank in question. This fixes failure to launch libvirt drivers on certain aarch64 hardware. Fixes: https://gitlab.com/libvirt/libvirt/-/issues/389 Signed-off-by: Daniel P. Berrang=C3=A9 --- src/conf/capabilities.c | 56 ++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index d693d38f3c..a79547f6ca 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -2183,6 +2183,7 @@ virCapabilitiesInitCaches(virCaps *caps) g_autofree char *type =3D NULL; int kernel_type; unsigned int level; + int ret; =20 if (!STRPREFIX(ent->d_name, "index")) continue; @@ -2198,29 +2199,54 @@ virCapabilitiesInitCaches(virCaps *caps) bank =3D g_new0(virCapsHostCacheBank, 1); bank->level =3D level; =20 - if (virFileReadValueUint(&bank->id, - "%s/cpu/cpu%zd/cache/%s/id", - SYSFS_SYSTEM_PATH, pos, ent->d_name) = < 0) + ret =3D virFileReadValueUint(&bank->id, + "%s/cpu/cpu%zd/cache/%s/id", + SYSFS_SYSTEM_PATH, pos, ent->d_name= ); + if (ret =3D=3D -2) { + VIR_DEBUG("CPU %zd cache %s 'id' missing", pos, ent->d_nam= e); + continue; + } + if (ret < 0) return -1; =20 - if (virFileReadValueUint(&bank->level, - "%s/cpu/cpu%zd/cache/%s/level", - SYSFS_SYSTEM_PATH, pos, ent->d_name) = < 0) + ret =3D virFileReadValueUint(&bank->level, + "%s/cpu/cpu%zd/cache/%s/level", + SYSFS_SYSTEM_PATH, pos, ent->d_name= ); + if (ret =3D=3D -2) { + VIR_DEBUG("CPU %zd cache %s 'level' missing", pos, ent->d_= name); + continue; + } + if (ret < 0) return -1; =20 - if (virFileReadValueString(&type, - "%s/cpu/cpu%zd/cache/%s/type", - SYSFS_SYSTEM_PATH, pos, ent->d_name= ) < 0) + ret =3D virFileReadValueString(&type, + "%s/cpu/cpu%zd/cache/%s/type", + SYSFS_SYSTEM_PATH, pos, ent->d_na= me); + if (ret =3D=3D -2) { + VIR_DEBUG("CPU %zd cache %s 'type' missing", pos, ent->d_n= ame); + continue; + } + if (ret < 0) return -1; =20 - if (virFileReadValueScaledInt(&bank->size, - "%s/cpu/cpu%zd/cache/%s/size", - SYSFS_SYSTEM_PATH, pos, ent->d_n= ame) < 0) + ret =3D virFileReadValueScaledInt(&bank->size, + "%s/cpu/cpu%zd/cache/%s/size", + SYSFS_SYSTEM_PATH, pos, ent->d= _name); + if (ret =3D=3D -2) { + VIR_DEBUG("CPU %zd cache %s 'size' missing", pos, ent->d_n= ame); + continue; + } + if (ret < 0) return -1; =20 - if (virFileReadValueBitmap(&bank->cpus, - "%s/cpu/cpu%zd/cache/%s/shared_cpu_= list", - SYSFS_SYSTEM_PATH, pos, ent->d_name= ) < 0) + ret =3D virFileReadValueBitmap(&bank->cpus, + "%s/cpu/cpu%zd/cache/%s/shared_cp= u_list", + SYSFS_SYSTEM_PATH, pos, ent->d_na= me); + if (ret =3D=3D -2) { + VIR_DEBUG("CPU %zd cache %s 'shared_cpu_list' missing", po= s, ent->d_name); + continue; + } + if (ret < 0) return -1; =20 kernel_type =3D virCacheKernelTypeFromString(type); --=20 2.37.3