From nobody Mon Feb 9 20:59:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=foxmail.com ARC-Seal: i=1; a=rsa-sha256; t=1585818319; cv=none; d=zohomail.com; s=zohoarc; b=G9skfGo4X4T2uKNwA1902TO74qgi0ofB/JJxpanPb1mDgIOalJVO9fL0gby3PLiRCKikwYuLttirvckL3gRXxypgR3xv4sPXIj6ZeRODTmwxKus65TCWLg7LeWshfA+eiyTDaM8i70l0XHVlsV+vM/c8fHKKrH/axhZxA10bw7w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585818319; 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=8CAPMzc/IKBQkmVYYATEJl4s//77bx6WJGGeLPTi68c=; b=CTsID6NQlM+NHT+oIb+r4nD0LKdUKP8dPdR0CRmN6d/oHq2FM9xjkg5otASMgeZtO8DCpWyJe3Vl82XbvfpD7m7FUI/Yig5Bh3VfnwkDnKcsJ5QCgnshEuPJCp4fsn1iCcFbukJNs0Cm7IC6otMm15YXVrjWByr1V3zkqgFnSnA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1585818319982868.086515788711; Thu, 2 Apr 2020 02:05:19 -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-104-nBQknbj5NmiEQlcu0wL6JA-1; Thu, 02 Apr 2020 05:05:15 -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 A5C52DB22; Thu, 2 Apr 2020 09:05:10 +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 6EC5E5DA66; Thu, 2 Apr 2020 09:05:10 +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 F1FBF18089D5; Thu, 2 Apr 2020 09:05:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 032958wF009219 for ; Thu, 2 Apr 2020 05:05:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 64EA211F4C4; Thu, 2 Apr 2020 09:05:08 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6124411F4C9 for ; Thu, 2 Apr 2020 09:05:06 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (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 2198E1019E0D for ; Thu, 2 Apr 2020 09:05:06 +0000 (UTC) Received: from qq.com (out203-205-221-247.mail.qq.com [203.205.221.247]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-152-vX6hN5jbNTmOzxEVDjErsw-1; Thu, 02 Apr 2020 05:05:03 -0400 Received: from localhost.localdomain ([111.21.171.11]) by newxmesmtplogicsvrsza6.qq.com (NewEsmtp) with SMTP id 107BACA1; Thu, 02 Apr 2020 17:04:07 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585818318; 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=8CAPMzc/IKBQkmVYYATEJl4s//77bx6WJGGeLPTi68c=; b=WHXuPYazV0xYEX0L9vvmPT7Bi2LBOuvaLffQlBruUx+Mki2I1XgyePn42SOReuH5rAubbv q/vg7h/afJwvVqjkbBDe57a+6At3ihWq0jJ5Rdc8pph+BiSEHbf1kc5v0Sp8lQgBhxrFDH 2NPdFgQDpLnNSLgKLzgUQoT8FQ0Vm3k= X-MC-Unique: nBQknbj5NmiEQlcu0wL6JA-1 X-MC-Unique: vX6hN5jbNTmOzxEVDjErsw-1 X-QQ-mid: xmsmtpt1585818284tk2l7o8wi X-QQ-XMAILINFO: MFZPeigTIzMtEb0PwUhBEJcMZX1KhPqBv/YVMG3HTf1ta0NSqv4sXZs0RCYcEM A0DRyLbcX3c1EOzdDMtjRzX441VaqaPoMA1XGwrLS6daHfNtA76Pxcu48qj1Z3Bgx4aQvkRJ+LvJ cbbZadpnFDAZvo315dc5uapD2EnjHm3iH5VBHRdE1YredDnidnqJtgTne+GBmjqvJfWWUYX1hB8T d3W3Tt9sTonpCCVhYg6t0Nc+do6DSK1WsbJlH8DxbQ21GyzO+/bwNjewu+OP6or4L9NgEQxS6YWL xcwMu6ztpkBqwlx9M7jeA7aJnuOe3jdfZNk7e8r4G9+GBKC+Qd53bsiWwaGU+O/hpFqqEckjV4+k U14YSIpBVBSBybhHiXheBC3bbq+0Ap81fEo5M2IhS9tBEImp3H7OArJMzgLMORwrB6TqjYb4f+di XZ0SNij5ZGQ4LL6GOsfyrLBu2zJcBAUg2U6ixxUEoK1dx0NYLyX533gDW/VX+ic33PdAt1RdWlP4 3d+/NM4tdEKs1kzOFQe6LvBEGbTbzFzGMn3v0wx8KMkZsRsPTonjufZc5Qi4SoQTYF5rwFJQ00sG SR6tpcCBxd1+wXKtdhLO1LtDLrWG3sHRnH+mYAYElTPn1qjA== From: Zhenyu Zheng To: libvir-list@redhat.com Subject: [PATCH V2 3/5] cpu: Introduce ARM related structs Date: Thu, 2 Apr 2020 17:03:55 +0800 Message-Id: <20200402090354.2193-4-zheng.zhenyu@foxmail.com> In-Reply-To: <20200402090354.2193-1-zheng.zhenyu@foxmail.com> References: <20200402090354.2193-1-zheng.zhenyu@foxmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 032958wF009219 X-loop: libvir-list@redhat.com Cc: Zhenyu Zheng , Zhenyu Zheng 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 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" Introduce vendor and model struct and related cleanup functions for ARM cpu. Signed-off-by: Zhenyu Zheng Reviewed-by: Daniel P. Berrang=C3=A9 --- src/cpu/cpu_arm.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c index ee5802198f..c757c24a37 100644 --- a/src/cpu/cpu_arm.c +++ b/src/cpu/cpu_arm.c @@ -1,6 +1,7 @@ /* * cpu_arm.c: CPU driver for arm CPUs * + * Copyright (C) 2020 Huawei Technologies Co., Ltd. * Copyright (C) 2013 Red Hat, Inc. * Copyright (C) Canonical Ltd. 2012 * @@ -23,12 +24,16 @@ =20 #include "viralloc.h" #include "cpu.h" +#include "cpu_arm.h" #include "cpu_map.h" +#include "virlog.h" #include "virstring.h" #include "virxml.h" =20 #define VIR_FROM_THIS VIR_FROM_CPU =20 +VIR_LOG_INIT("cpu.cpu_arm"); + static const virArch archs[] =3D { VIR_ARCH_ARMV6L, VIR_ARCH_ARMV7B, @@ -36,6 +41,21 @@ static const virArch archs[] =3D { VIR_ARCH_AARCH64, }; =20 +typedef struct _virCPUarmVendor virCPUarmVendor; +typedef virCPUarmVendor *virCPUarmVendorPtr; +struct _virCPUarmVendor { + char *name; + unsigned long value; +}; + +typedef struct _virCPUarmModel virCPUarmModel; +typedef virCPUarmModel *virCPUarmModelPtr; +struct _virCPUarmModel { + char *name; + virCPUarmVendorPtr vendor; + virCPUarmData data; +}; + typedef struct _virCPUarmFeature virCPUarmFeature; typedef virCPUarmFeature *virCPUarmFeaturePtr; struct _virCPUarmFeature { @@ -64,6 +84,10 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCPUarmFeature, virCPUar= mFeatureFree); typedef struct _virCPUarmMap virCPUarmMap; typedef virCPUarmMap *virCPUarmMapPtr; struct _virCPUarmMap { + size_t nvendors; + virCPUarmVendorPtr *vendors; + size_t nmodels; + virCPUarmModelPtr *models; GPtrArray *features; }; =20 @@ -81,12 +105,62 @@ virCPUarmMapNew(void) return map; } =20 +static void +virCPUarmDataClear(virCPUarmData *data) +{ + if (!data) + return; + + VIR_FREE(data->features); +} + +static void +virCPUarmDataFree(virCPUDataPtr cpuData) +{ + if (!cpuData) + return; + + virCPUarmDataClear(&cpuData->data.arm); + VIR_FREE(cpuData); +} + +static void +armModelFree(virCPUarmModelPtr model) +{ + if (!model) + return; + + virCPUarmDataClear(&model->data); + g_free(model->name); + g_free(model); +} + +static void +armVendorFree(virCPUarmVendorPtr vendor) +{ + if (!vendor) + return; + + g_free(vendor->name); + g_free(vendor); +} + static void virCPUarmMapFree(virCPUarmMapPtr map) { if (!map) return; =20 + size_t i; + + for (i =3D 0; i < map->nmodels; i++) + armModelFree(map->models[i]); + g_free(map->models); + + for (i =3D 0; i < map->nvendors; i++) + armVendorFree(map->vendors[i]); + g_free(map->vendors); + g_ptr_array_free(map->features, TRUE); =20 g_free(map); @@ -259,6 +333,7 @@ struct cpuArchDriver cpuDriverArm =3D { .compare =3D virCPUarmCompare, .decode =3D NULL, .encode =3D NULL, + .dataFree =3D virCPUarmDataFree, .baseline =3D virCPUarmBaseline, .update =3D virCPUarmUpdate, .validateFeatures =3D virCPUarmValidateFeatures, --=20 2.26.0.windows.1