From nobody Mon Feb 9 10:12:35 2026 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=1609759864; cv=none; d=zohomail.com; s=zohoarc; b=Bse1YxV9Lwo1DLakkndjZ2FVeeVET1WrioQAA7LIkz+FpKEon0P4bAchtUhyumQIVCqBoKTQERDcE/R+apVMUkexYB4ShcfbVzmxh93VvpCI3y/JCyGwqbFJ6CyaqUQ/sswN4jopVK3RPltXYWxn+zQDwHrrjhl1fQxxc14y6zY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609759864; 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=VeCGxiXhJTAfoMKnMXt2RAPwWRq9pEuBl3K+iel6T1w=; b=YUWdm92ymhG8oW59xyo575hEGljczj7+1vm0miMIMnE0ORW9PDO3rce9ezx8HnF1ve2+eLl4f6D5NFDvVTGIjWQE14bOGTQAJNnWT63zsdJNyLgVKRXHZi5TLor5f9fCbeWdLfX3le1ZP8eruRG/Nl5GvVIrOA4nXM1mLT47YgA= 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 160975986398621.94962974572968; Mon, 4 Jan 2021 03:31:03 -0800 (PST) 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-15-ZYgg2Y2wOn24id9bF25_Bg-1; Mon, 04 Jan 2021 06:30:46 -0500 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 1F6C1612B5; Mon, 4 Jan 2021 11:30:40 +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 EFD8060BE5; Mon, 4 Jan 2021 11:30:39 +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 BA3FB1809CA6; Mon, 4 Jan 2021 11:30:39 +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 104BUTN6006514 for ; Mon, 4 Jan 2021 06:30:29 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0E9F7669FC; Mon, 4 Jan 2021 11:30:29 +0000 (UTC) Received: from work.redhat.com (ovpn-112-122.ams2.redhat.com [10.36.112.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F33C61F20; Mon, 4 Jan 2021 11:30:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609759862; 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=VeCGxiXhJTAfoMKnMXt2RAPwWRq9pEuBl3K+iel6T1w=; b=heEWBQ5SqaWA8JiCXuImV888K7mk576XRgIlQ7sDUgfBz05+gT25/GNvy/bRD+rOjOPtCn yI9jASPIym5GAos2XIUkiCLah59L64wJV7zC91ecPtNTLOen5aadzWHsJ08yrHr7WpeTlm UWrF9Jf4bibnQ5KvPsbmsRw3YFgd3gE= X-MC-Unique: ZYgg2Y2wOn24id9bF25_Bg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 4/9] cpu-cpuid: Merge addFeature functions Date: Mon, 4 Jan 2021 12:30:14 +0100 Message-Id: <20210104113019.106513-5-twiederh@redhat.com> In-Reply-To: <20210104113019.106513-1-twiederh@redhat.com> References: <20210104113019.106513-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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" Prepare to deduplicate the list of relevant registers for cpuid and msr information. Signed-off-by: Tim Wiederhake --- tests/cputestdata/cpu-cpuid.py | 48 ++++++++++++---------------------- 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/tests/cputestdata/cpu-cpuid.py b/tests/cputestdata/cpu-cpuid.py index d570884db6..c9948da6f8 100755 --- a/tests/cputestdata/cpu-cpuid.py +++ b/tests/cputestdata/cpu-cpuid.py @@ -54,41 +54,25 @@ def checkFeature(cpuData, feature): return checkMSRFeature(cpuData, feature) =20 =20 -def addCPUIDFeature(cpuData, feature): - if "cpuid" not in cpuData: - cpuData["cpuid"] =3D {} - cpuid =3D cpuData["cpuid"] - - if feature["eax_in"] not in cpuid: - cpuid[feature["eax_in"]] =3D {} - leaf =3D cpuid[feature["eax_in"]] - - if feature["ecx_in"] not in leaf: - leaf[feature["ecx_in"]] =3D {"eax": 0, "ebx": 0, "ecx": 0, "edx": = 0} - leaf =3D leaf[feature["ecx_in"]] - - for reg in ["eax", "ebx", "ecx", "edx"]: - leaf[reg] |=3D feature[reg] - - -def addMSRFeature(cpuData, feature): - if "msr" not in cpuData: - cpuData["msr"] =3D {} - msr =3D cpuData["msr"] - - if feature["index"] not in msr: - msr[feature["index"]] =3D {"edx": 0, "eax": 0} - msr =3D msr[feature["index"]] - - for reg in ["edx", "eax"]: - msr[reg] |=3D feature[reg] - - def addFeature(cpuData, feature): if feature["type"] =3D=3D "cpuid": - addCPUIDFeature(cpuData, feature) + # cpuData["cpuid"][eax_in][ecx_in] =3D {eax:, ebx:, ecx:, edx:} + keyList =3D ["type", "eax_in", "ecx_in"] + regList =3D ["eax", "ebx", "ecx", "edx"] elif feature["type"] =3D=3D "msr": - addMSRFeature(cpuData, feature) + # cpuData["msr"][index] =3D {eax:, edx:} + keyList =3D ["type", "index"] + regList =3D ["eax", "edx"] + else: + return + + for key in keyList: + if feature[key] not in cpuData: + cpuData[feature[key]] =3D dict() + cpuData =3D cpuData[feature[key]] + + for reg in regList: + cpuData[reg] =3D cpuData.get(reg, 0) | feature[reg] =20 =20 def parseQemu(path, features): --=20 2.26.2