From nobody Sun Feb 8 18:39:30 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1560937335; cv=none; d=zoho.com; s=zohoarc; b=Ig249Rc+UQZt9LIlbjUr9hkO4JCiInrJT2iSGjxRZiGF+L31Vj+xjKjp1CdD1S+DdIWdJ1d87a7NM8w57zAqSVvp5hnoHd4V9TtU7aXpjBxfJ0Kr1t/ydfv2G1iBIe1p94Q/7HgMOEV8XxubZ6eHvR3dxh8m/E3QU1ERB8xcRDg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560937335; h=Content-Type:Content-Transfer-Encoding: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:ARC-Authentication-Results; bh=uYv54QkGBAOX77h160JjxB7o9v2lzuU6OTtVV4fk1UI=; b=LCrA7/Xrw3Sn5TamN+qiVIDVIXvCfZrvvJNz1KR48iVxRvAZjVdTGh/KfHsehq2WoT60Sld+XhP9q82xee9weoAtf6v5AMMvG8htbTdLbdPiIP7q9tJQLotqCJ6SVszlyeGddm7arGfAmVrmwYaJaJmJlr7YJO255yFNiUxbMcg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1560937335300857.0924832144768; Wed, 19 Jun 2019 02:42:15 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 74759DF26; Wed, 19 Jun 2019 09:42:13 +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 4301D601A5; Wed, 19 Jun 2019 09:42:13 +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 DA58D206D9; Wed, 19 Jun 2019 09:42:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x5J9cVlR024381 for ; Wed, 19 Jun 2019 05:38:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 763EB1001B39; Wed, 19 Jun 2019 09:38:31 +0000 (UTC) Received: from orkuz.int.mamuti.net (ovpn-204-21.brq.redhat.com [10.40.204.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 203121001E69 for ; Wed, 19 Jun 2019 09:38:31 +0000 (UTC) Received: by orkuz.int.mamuti.net (Postfix, from userid 500) id BAAB62A4127; Wed, 19 Jun 2019 11:38:23 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 19 Jun 2019 11:38:16 +0200 Message-Id: <28da8411312064cec30e5405c76e43792e46fa33.1560936842.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 19/24] cpu: Introduce virCPUDataAddFeature 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 19 Jun 2019 09:42:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This is a generic replacement for the former virCPUx86DataAddFeature, which worked on the generic virCPUDataPtr anyway. Signed-off-by: Jiri Denemark --- src/cpu/cpu.c | 33 +++++++++++++++++++++++++++++++++ src/cpu/cpu.h | 9 +++++++++ src/cpu/cpu_x86.c | 3 ++- src/cpu/cpu_x86.h | 3 --- src/libvirt_private.syms | 2 +- src/qemu/qemu_capabilities.c | 2 +- 6 files changed, 46 insertions(+), 6 deletions(-) diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index a223ff06e8..b89462cc0c 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -1075,3 +1075,36 @@ virCPUValidateFeatures(virArch arch, else return 0; } + + +/** + * virCPUDataAddFeature: + * + * @cpuData: CPU data + * @name: feature to be added to @cpuData + * + * Adds a feature called @name to @cpuData. + * + * Returns 0 on success, -1 on error. + */ +int +virCPUDataAddFeature(virCPUDataPtr cpuData, + const char *name) +{ + struct cpuArchDriver *driver; + + VIR_DEBUG("arch=3D%s, cpuData=3D%p, name=3D%s", + virArchToString(cpuData->arch), cpuData, name); + + if (!(driver =3D cpuGetSubDriver(cpuData->arch))) + return -1; + + if (!driver->dataAddFeature) { + virReportError(VIR_ERR_NO_SUPPORT, + _("cannot add guest CPU feature for %s architecture= "), + virArchToString(cpuData->arch)); + return -1; + } + + return driver->dataAddFeature(cpuData, name); +} diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index 7cc9e7d9db..13909bb7a4 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -117,6 +117,10 @@ typedef virCPUDefPtr typedef int (*virCPUArchValidateFeatures)(virCPUDefPtr cpu); =20 +typedef int +(*virCPUArchDataAddFeature)(virCPUDataPtr cpuData, + const char *name); + struct cpuArchDriver { const char *name; const virArch *arch; @@ -139,6 +143,7 @@ struct cpuArchDriver { virCPUArchExpandFeatures expandFeatures; virCPUArchCopyMigratable copyMigratable; virCPUArchValidateFeatures validateFeatures; + virCPUArchDataAddFeature dataAddFeature; }; =20 =20 @@ -256,6 +261,10 @@ virCPUValidateFeatures(virArch arch, virCPUDefPtr cpu) ATTRIBUTE_NONNULL(2); =20 +int +virCPUDataAddFeature(virCPUDataPtr cpuData, + const char *name); + /* virCPUDataFormat and virCPUDataParse are implemented for unit tests onl= y and * have no real-life usage */ diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 689b6cdaf5..b6a94d483a 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -3326,7 +3326,7 @@ virCPUx86DataSetVendor(virCPUDataPtr cpuData, } =20 =20 -int +static int virCPUx86DataAddFeature(virCPUDataPtr cpuData, const char *name) { @@ -3371,4 +3371,5 @@ struct cpuArchDriver cpuDriverX86 =3D { .expandFeatures =3D virCPUx86ExpandFeatures, .copyMigratable =3D virCPUx86CopyMigratable, .validateFeatures =3D virCPUx86ValidateFeatures, + .dataAddFeature =3D virCPUx86DataAddFeature, }; diff --git a/src/cpu/cpu_x86.h b/src/cpu/cpu_x86.h index 29037d4afa..28ae46647a 100644 --- a/src/cpu/cpu_x86.h +++ b/src/cpu/cpu_x86.h @@ -40,6 +40,3 @@ uint32_t virCPUx86DataGetSignature(virCPUDataPtr cpuData, =20 int virCPUx86DataSetVendor(virCPUDataPtr cpuData, const char *vendor); - -int virCPUx86DataAddFeature(virCPUDataPtr cpuData, - const char *name); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 228cd929b4..ab2e4bc6fe 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1245,6 +1245,7 @@ virCPUCompare; virCPUCompareXML; virCPUConvertLegacy; virCPUCopyMigratable; +virCPUDataAddFeature; virCPUDataCheckFeature; virCPUDataFormat; virCPUDataFree; @@ -1263,7 +1264,6 @@ virCPUValidateFeatures; =20 # cpu/cpu_x86.h virCPUx86DataAdd; -virCPUx86DataAddFeature; virCPUx86DataGetSignature; virCPUx86DataSetSignature; virCPUx86DataSetVendor; diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 9ef1eabc95..4134f319ac 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3009,7 +3009,7 @@ virQEMUCapsGetCPUModelX86Data(virQEMUCapsPtr qemuCaps, (migratable && prop->migratable =3D=3D VIR_TRISTATE_BOOL_N= O)) continue; =20 - if (virCPUx86DataAddFeature(data, name) < 0) + if (virCPUDataAddFeature(data, name) < 0) goto cleanup; =20 break; --=20 2.22.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list