From nobody Mon Feb 9 11:46:59 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=1609759839; cv=none; d=zohomail.com; s=zohoarc; b=g1KMEiNMTJ32n7T/0i1DX1oENbgJnphRLiOTsy/erdhkbliOaoPKGGXWgBsvTpz6rhjnogcBNYyj837STdN3h/obMIuIh3vllVntoeXbdJ2RW3Noaq4gYfJ0vdegM1PnwZo2VSzqaB1jyGGvtmRtF9MAasz2mQWkpQv8dqzL+ec= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609759839; 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=CfbiicbQeY/mrQG8spT3HS1rZNf+6AcdKndCxCxYQpw=; b=SrDK4PbQnn8Em8bx1pos831IATcBAoAtZyOq07co2cfO9CxJ8XiGMuTkVoXPZDO9V/7xqsXbS0D9Xhz68aLe/2lrnCGmXVVTj2yBiDbK8p8mOj6iVpqO9pfRNZarLHbaRxmZxfCmlz/2w5L29AhK181JTyKxHhjCD1ZFbCA8kSo= 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 1609759839734828.3722625700536; Mon, 4 Jan 2021 03:30:39 -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-235-r93kJuZlOFq2DRVsLObsbQ-1; Mon, 04 Jan 2021 06:30:35 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A559C1005504; Mon, 4 Jan 2021 11:30: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 836F86F7EF; Mon, 4 Jan 2021 11:30: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 188D11809CA2; Mon, 4 Jan 2021 11:30: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 104BURfx006501 for ; Mon, 4 Jan 2021 06:30:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id ED46D669FC; Mon, 4 Jan 2021 11:30:27 +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 308EC5D756; Mon, 4 Jan 2021 11:30:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609759838; 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=CfbiicbQeY/mrQG8spT3HS1rZNf+6AcdKndCxCxYQpw=; b=bjVSpdFX16Fiu3sVvcHRokYiSyYvsWiX0wR7C+Ckyi3IpvaMM18MyPMPHVKaqjiQlsAb8C gylvaXlzj1bRZRY11sYrwjwZraHcVmN+KqBfvqQ23e9wrjLmYi+8V0v4g8sn39xoGLtjLz IOLSRimxHZgGSi2ScsBKY9YbrN8tWXU= X-MC-Unique: r93kJuZlOFq2DRVsLObsbQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 3/9] cpu-cpuid: Remove xmltodict usage in parseCPU Date: Mon, 4 Jan 2021 12:30:13 +0100 Message-Id: <20210104113019.106513-4-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.11 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" 'xmltodict' is a Python module that is not installed by default. Replace it, so the dependencies of cpu-gather.py do not change when both scripts are merged. Signed-off-by: Tim Wiederhake --- tests/cputestdata/cpu-cpuid.py | 35 +++++++++++----------------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/tests/cputestdata/cpu-cpuid.py b/tests/cputestdata/cpu-cpuid.py index 8e06baea85..d570884db6 100755 --- a/tests/cputestdata/cpu-cpuid.py +++ b/tests/cputestdata/cpu-cpuid.py @@ -4,7 +4,6 @@ import argparse import os import sys import json -import xmltodict import xml.etree.ElementTree =20 =20 @@ -105,31 +104,19 @@ def parseQemu(path, features): =20 =20 def parseCPUData(path): - cpuData =3D {} - with open(path, "rb") as f: - data =3D xmltodict.parse(f) - - for leaf in data["cpudata"]["cpuid"]: - feature =3D {"type": "cpuid"} - feature["eax_in"] =3D int(leaf["@eax_in"], 0) - feature["ecx_in"] =3D int(leaf["@ecx_in"], 0) - for reg in ["eax", "ebx", "ecx", "edx"]: - feature[reg] =3D int(leaf["@" + reg], 0) + cpuData =3D dict() + for f in xml.etree.ElementTree.parse(path).getroot(): + if f.tag =3D=3D "cpuid": + reg_list =3D ["eax_in", "ecx_in", "eax", "ebx", "ecx", "edx"] + elif f.tag =3D=3D "msr": + reg_list =3D ["index", "eax", "edx"] + else: + continue =20 + feature =3D {"type": f.tag} + for reg in reg_list: + feature[reg] =3D int(f.attrib.get(reg, "0"), 0) addFeature(cpuData, feature) - - if "msr" in data["cpudata"]: - if not isinstance(data["cpudata"]["msr"], list): - data["cpudata"]["msr"] =3D [data["cpudata"]["msr"]] - - for msr in data["cpudata"]["msr"]: - feature =3D {"type": "msr"} - feature["index"] =3D int(msr["@index"], 0) - feature["edx"] =3D int(msr["@edx"], 0) - feature["eax"] =3D int(msr["@eax"], 0) - - addFeature(cpuData, feature) - return cpuData =20 =20 --=20 2.26.2