From nobody Mon Feb 9 23:57:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; 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 207.211.31.81 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=1587539694; cv=none; d=zohomail.com; s=zohoarc; b=Sy27LMlrH6d0Abrx1pBREOop4Z8E3m2j5E0eLUtEqdU5j3pbHgTW4xIrOMVZpfXWIWqKSYC+Enk1JM0v5PLSXrJAyVm3IgGs5mDxhtx2ngSe3PX4s5SqTG4o6ZxMHaCpZ0u6m3K2RUcpVvJHar9mvsJ0EdiI3epFL0oLLVsMw+8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587539694; 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=1ZxWizVPbFJDMPPUUXmsPvtF6tNBXsC2cDD0YFZg7/o=; b=cv1E44ZmziSlZtEtyChJFKb/vJwy/MQugxdEJzl1ve4s6qhkjJA5tA4vk46g7kfwOZ2804O2ywZ1vu0wYN8ILdPKJocPmTUtINGKuDXt7MTlXgbu9D4loJ4ysOPfIziY723i+x0K6kGegvzFcVgXC5zIJXPbWbcUHZmPXHI+5BE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1587539694235895.4815654936921; Wed, 22 Apr 2020 00:14:54 -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-321-urAa3tsmPiucC5m3WSsS1Q-1; Wed, 22 Apr 2020 03:14:50 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7DF39107ACCC; Wed, 22 Apr 2020 07:14:45 +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 4EE9E5C1D4; Wed, 22 Apr 2020 07:14:45 +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 02A3218089CD; Wed, 22 Apr 2020 07:14:45 +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 03M7Eio4010680 for ; Wed, 22 Apr 2020 03:14:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3C6FAB3A6E; Wed, 22 Apr 2020 07:14:44 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast06.extmail.prod.ext.phx2.redhat.com [10.5.110.77]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 32178B3A66 for ; Wed, 22 Apr 2020 07:14:41 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 41C1B8017F3 for ; Wed, 22 Apr 2020 07:14:41 +0000 (UTC) Received: from qq.com (out203-205-221-210.mail.qq.com [203.205.221.210]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-368-r3BAMxv6Mby9ipvGT-amlA-1; Wed, 22 Apr 2020 03:12:30 -0400 Received: from localhost.localdomain ([111.21.171.11]) by newxmesmtplogicsvrsza5.qq.com (NewEsmtp) with SMTP id 2DD1AA27; Wed, 22 Apr 2020 15:11:29 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587539692; 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=1ZxWizVPbFJDMPPUUXmsPvtF6tNBXsC2cDD0YFZg7/o=; b=KwJy1UPhbQjFoE9QVnVly/IZugQOwKxC0nq6OU1NO8VpfEj0VfiammGZ1GzCJt36es+hpG i+f/FVnQOPbVehUEkVHTLIfUPXivUvb6s7wvXwwqg/ox7j+p+7bzud0Q2YcODHWuUjrnVo cG+qesCCmCIXkMEpdO7BK5ueqUXtX7c= X-MC-Unique: urAa3tsmPiucC5m3WSsS1Q-1 X-MC-Unique: r3BAMxv6Mby9ipvGT-amlA-1 X-QQ-mid: xmsmtpt1587539531tp0gju9ou X-QQ-XMAILINFO: NjnNvy0M8+t39ObFE59YHZ2rzStIOF0jxDUXgeFNZS74iP+DCuFWuWZyiyVxUa U99Zs7vt0OA1XynlVbc8VFA6G+E+Q8kcJfaBZ5bBmNipvdjDS7fiZympRMTB8ExVW6EiGUpJYNJy SDLBV/zCk9tvOezEIoo9URBBeZjmfrZpgoxOt4jkSbV7AkZNc/ghZFgmiu5J5T5o/vYPE5S+No+1 +segbIkRf+XBj4gjl6seHBZw8MIeEGHHrc+6rOl2NNWf/xcBmBoqY8qR4lT9D4r9NNkZcAcbYgW/ sCXdUhPfZCaOWLNAa79Y/3aHN2+zPq3oMMps1vZ/cfz+O8Rkk3LeS8Xgk49ygf3kx8Y+LJE7Y+4g uA3jIMiRvazGVJASfBIY1vJISjXyYHu3InP8UbuO9o/JUEwiDIPjTOzE2GH+8nlMYlEHEg6YkxTz xlBidogmRCd8iwl1eojxlxoIEFZravAytGuu9VuruJJvnm81taulw/ES3NcgVv5ZICBoXYXprMqy m/hr/hQ/cJfvtczXPsexwsuu8TBFM/rosrFhcVlryc5IOkn4OuyXuQ5NSIuF5rxBnpIecEifotVB F0uJrzDSO1N4aYNw01zP8vvjtjcVdxoW/3zbGVq+JTgF8yj74UfbWVlrt6A8a8/7JxsPk= From: ZhengZhenyu To: libvir-list@redhat.com Subject: [PATCH V3 3/5] cpu: Introduce ARM related structs Date: Wed, 22 Apr 2020 15:11:20 +0800 Message-Id: <20200422071119.2026-4-zheng.zhenyu@foxmail.com> In-Reply-To: <20200422071119.2026-1-zheng.zhenyu@foxmail.com> References: <20200422071119.2026-1-zheng.zhenyu@foxmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 03M7Eio4010680 X-loop: libvir-list@redhat.com Cc: Zhenyu Zheng , ZhengZhenyu 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.16 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 --- src/cpu/cpu_arm.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c index ee5802198f..2009904cc9 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,7 +24,9 @@ =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 @@ -36,6 +39,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 +82,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 +103,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 +virCPUarmModelFree(virCPUarmModelPtr model) +{ + if (!model) + return; + + virCPUarmDataClear(&model->data); + g_free(model->name); + g_free(model); +} + +static void +virCPUarmVendorFree(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++) + virCPUarmModelFree(map->models[i]); + g_free(map->models); + + for (i =3D 0; i < map->nvendors; i++) + virCPUarmVendorFree(map->vendors[i]); + g_free(map->vendors); + g_ptr_array_free(map->features, TRUE); =20 g_free(map); @@ -259,6 +331,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