From nobody Fri May 17 07:47:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) client-ip=216.205.24.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1584403351; cv=none; d=zohomail.com; s=zohoarc; b=dFMiS1yjufEw4VFkb6+Lmn735paQkJvBYWem42b4awMO9fHZ8eX7Qc0IcEaoQlE+Z3pnjlkOTXmW23a4goZgpc1QHAv+/O+Q658hHFdMq6CBFpqo1UjOJVJno9/5H/Whs5Q+Irk2sZ9bOpVOtzQAU5LZ0SvdnmvLJdkMdG2ir98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584403351; 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=Vk/7GA5vyZ3PQsjgD7/CamUUDStX6/BVbocndFY+8dg=; b=SGmXiwZH7M3EX0SJHu+5lDKRWWZNehyP9PBgEmiqHsILy5LXMHRXDao2IlZ36Lm628ulkKCitz7Lw1QOKnEk0IpBbuXsBnE0wWjKSXAffMb+vEAO4ra0yMtkTouOcA9GUW7IlEQGSt2nJdMo6EQ5cS8Yy7F/9dlGEBQpSBXR7MU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by mx.zohomail.com with SMTPS id 1584403351809373.80520737442623; Mon, 16 Mar 2020 17:02:31 -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-305-r9dOlB-9PBGALFrIoPlt8g-1; Mon, 16 Mar 2020 20:02:28 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 475D0100550E; Tue, 17 Mar 2020 00:02:22 +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 E7B521001DC2; Tue, 17 Mar 2020 00:02:21 +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 C0DCD86FF6; Tue, 17 Mar 2020 00:02:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02H01tfQ005209 for ; Mon, 16 Mar 2020 20:01:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 62D712022EAC; Tue, 17 Mar 2020 00:01:55 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5D6DE2022EA5 for ; Tue, 17 Mar 2020 00:01:55 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3ADEA185A791 for ; Tue, 17 Mar 2020 00:01:55 +0000 (UTC) Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-385-g5LOwtv_OYKMG8Xd7O1srw-1; Mon, 16 Mar 2020 20:01:50 -0400 Received: by mail-qt1-f194.google.com with SMTP id h16so15958676qtr.11; Mon, 16 Mar 2020 17:01:50 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:98d4:ad75:e292:7da8:ed0a]) by smtp.gmail.com with ESMTPSA id p35sm1044991qtk.2.2020.03.16.17.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 17:01:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584403350; 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=Vk/7GA5vyZ3PQsjgD7/CamUUDStX6/BVbocndFY+8dg=; b=H2mlbbcIiN+nHe8GlXbqlk+U7LXtEtUb0hKHxdD5PlCLiSM8fe+xu99rtdnJ0Q6bV9LDJC 8W1wsZKssufK4V8EREHp6PDEXP+jf9hupEKFFVmfpq48G+RTMkTC75TXnA0Huj9/zMFYmb OabGdPUVzkSCnZ3b/Mdtgaej70Yoqn8= X-MC-Unique: r9dOlB-9PBGALFrIoPlt8g-1 X-MC-Unique: g5LOwtv_OYKMG8Xd7O1srw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AUWIhz0u90jBum/ARqujfj+ZslL6G/+Jq0+XMm93sms=; b=lQHbc6rdlqf9W9lnG2wdMNcyk0i3FqTtHpmyUhZR1SHOuBcT/pXmZXDP3nl72Od1jf 5DyKVuTb/F0MaVBUVXYYS6j/nsC3zBs1uTWViECfjWKjtjDChKvs12230EAcEeEI/IF6 4KvjINpch1hVg0XfrxadBwNzCIBGC7pgGHEW6QAhNVUemi0VgQUygRXbj4I1CNJ3GLEK 0wNaqYvZfU8LtVXyD6iXY4JBXmpmOSkblzYaq8MpNlcBUn/lZAwJeNlVgtui3CmW7yEF D2hvXVnb9foy3TIvJ8RxU/aC1WI643SEXukcn1vh+xvyAuz4BTOZi1pL9stmDF6QR6wv Pycw== X-Gm-Message-State: ANhLgQ1/l8V/6WXgOX8xKO260vPgbpEstqS2gUyAiLDtpIfOG6MzB38t 99yVqMZMCsBjodqkpMbrMwsyXrfY X-Google-Smtp-Source: ADFU+vtKV8iwKJ2MBH8zCYN6AcFrB7EYA2VyhQiotMaL4S7eGobuWQps/E1DOdxqVKKb0m2afqBqiA== X-Received: by 2002:ac8:545a:: with SMTP id d26mr2822287qtq.238.1584403309982; Mon, 16 Mar 2020 17:01:49 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 1/1] virhostcpu.c: fix 'die_id' parsing for Power hosts Date: Mon, 16 Mar 2020 21:01:34 -0300 Message-Id: <20200317000134.1238432-2-danielhb413@gmail.com> In-Reply-To: <20200317000134.1238432-1-danielhb413@gmail.com> References: <20200317000134.1238432-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 02H01tfQ005209 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza 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.84 on 10.5.11.22 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" Commit 7b79ee2f78 makes assumptions about die_id parsing in the sysfs that aren't true for Power hosts. In both Power8 and Power9, running 5.6 and 4.18 kernel respectively, 'die_id' is set to -1: $ cat /sys/devices/system/cpu/cpu0/topology/die_id -1 This breaks virHostCPUGetDie() parsing because it is trying to retrieve an unsigned integer, causing problems during VM start: virFileReadValueUint:4128 : internal error: Invalid unsigned integer value '-1' in file '/sys/devices/system/cpu/cpu0/topology/die_id' This isn't necessarily a PowerPC only behavior. Linux kernel commit 0e344d8c70 added in the former Documentation/cputopology.txt, now Documentation/admin-guide/cputopology.rst, that: Reviewed-by: Michal Privoznik --- To be consistent on all architectures, include/linux/topology.h provides default definitions for any of the above macros that are not defined by include/asm-XXX/topology.h: 1) topology_physical_package_id: -1 2) topology_die_id: -1 (...) --- This means that it can be expected that an architecture that does not implement the die_id element will mark it as -1 in sysfs. Let's change the parsing being done in virHostCPUGetDie(), reading die_id as an integer instead of unsigned int. In case die_id is -1, default it to zero like the case of file not found. Fixes: 7b79ee2f78bbf2af76df2f6466919e19ae05aeeb Signed-off-by: Daniel Henrique Barboza --- src/util/virhostcpu.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index c1b39e772a..67d3e3308b 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -220,16 +220,23 @@ virHostCPUGetSocket(unsigned int cpu, unsigned int *s= ocket) int virHostCPUGetDie(unsigned int cpu, unsigned int *die) { - int ret =3D virFileReadValueUint(die, - "%s/cpu/cpu%u/topology/die_id", - SYSFS_SYSTEM_PATH, cpu); + int die_id; + int ret =3D virFileReadValueInt(&die_id, + "%s/cpu/cpu%u/topology/die_id", + SYSFS_SYSTEM_PATH, cpu); =20 - /* If the file is not there, it's 0 */ - if (ret =3D=3D -2) - *die =3D 0; - else if (ret < 0) + if (ret =3D=3D -1) return -1; =20 + /* If the file is not there, it's 0. + * Another alternative is die_id set to -1, meaning that + * the arch does not have die_id support. Set @die to + * 0 in this case too. */ + if (ret =3D=3D -2 || die_id < 0) + *die =3D 0; + else + *die =3D die_id; + return 0; } =20 --=20 2.24.1