From nobody Mon Apr 29 22:44:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1636043271; cv=none; d=zohomail.com; s=zohoarc; b=e4yC3yawOVxnK1Rab7ZteIWEEDvejLF8tiHwoJIbQpP3zZ5iMwFv7tTCn/q5qmwyMc9nb/Xls83aof5VrOt6hpW0LQQMN/z0WO/A+fxmZxb10GDCbP7S9vJJd9nMDoRDcgrmt01g9OLPHlCSjT1az7cTHWbqFQe+XnizOHF9TcY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636043271; 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=qATWJ9GE8x+asjWlfESBNuxr3YoEUjHXFsLSD5OUr7I=; b=WdaiBQuMgiML0Aj7t/ixN2M3gAqIwxvQUx0zwyweZonZCu/1EC/aN41ux7YC7KIKHimWc77VyImZBwJbLcupwtzzDayD++HeY3nVhnozc+RR9hMjh0Pjhrm+uz+4VKor1IGWnMNU9hKpIIVxGJEKr7h6/WHoQnAeq8HEiDi2eRM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1636043271540871.8031992343552; Thu, 4 Nov 2021 09:27:51 -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-508-T1blv1QpOQyZ80zopwEh8g-1; Thu, 04 Nov 2021 12:27:48 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 826DA1023F59; Thu, 4 Nov 2021 16:27:43 +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 576F77086C; Thu, 4 Nov 2021 16:27:43 +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 1DA124EA2A; Thu, 4 Nov 2021 16:27:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A4GRMD1026329 for ; Thu, 4 Nov 2021 12:27:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id B35AA19723; Thu, 4 Nov 2021 16:27:22 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A02219C79; Thu, 4 Nov 2021 16:27:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636043270; 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=qATWJ9GE8x+asjWlfESBNuxr3YoEUjHXFsLSD5OUr7I=; b=HLTZQyWcGi6ELxqiQNXNfS1alHvNbtmtpKBRGOX07GNxSB7jA1Pb+qTlPTfX43OJYoGgKI wtLqbNh7idnAM4X477mnfXqXPcB8M6jCRceew+6Lxeh6+eIudnV+N5D6vcrbfny7K0zTjh jOL3EmNpJvK+vTiCtr27L/DAInGANgc= X-MC-Unique: T1blv1QpOQyZ80zopwEh8g-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 01/20] cpu_x86: Simplify x86ParseCPUID Date: Thu, 4 Nov 2021 17:27:01 +0100 Message-Id: <20211104162720.108973-2-twiederh@redhat.com> In-Reply-To: <20211104162720.108973-1-twiederh@redhat.com> References: <20211104162720.108973-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.13 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) X-ZM-MESSAGEID: 1636043275299100001 Content-Type: text/plain; charset="utf-8" ... by using virXMLProp*() helpers. These only require a xmlNodePtr and do not need a xmlXPathContextPtr. Reflect that in the function signature. Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/cpu/cpu_x86.c | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 1b829e5658..b0f6fa8f34 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -1021,37 +1021,28 @@ x86FeatureNames(virCPUx86Map *map, =20 =20 static int -x86ParseCPUID(xmlXPathContextPtr ctxt, +x86ParseCPUID(xmlNodePtr node, virCPUx86DataItem *item) { - virCPUx86CPUID *cpuid; - unsigned long eax_in, ecx_in; - unsigned long eax, ebx, ecx, edx; - int ret_eax_in, ret_ecx_in, ret_eax, ret_ebx, ret_ecx, ret_edx; - - memset(item, 0, sizeof(*item)); + virCPUx86CPUID cpuid; =20 - eax_in =3D ecx_in =3D 0; - eax =3D ebx =3D ecx =3D edx =3D 0; - ret_eax_in =3D virXPathULongHex("string(@eax_in)", ctxt, &eax_in); - ret_ecx_in =3D virXPathULongHex("string(@ecx_in)", ctxt, &ecx_in); - ret_eax =3D virXPathULongHex("string(@eax)", ctxt, &eax); - ret_ebx =3D virXPathULongHex("string(@ebx)", ctxt, &ebx); - ret_ecx =3D virXPathULongHex("string(@ecx)", ctxt, &ecx); - ret_edx =3D virXPathULongHex("string(@edx)", ctxt, &edx); + memset(&cpuid, 0, sizeof(cpuid)); =20 - if (ret_eax_in < 0 || ret_ecx_in =3D=3D -2 || - ret_eax =3D=3D -2 || ret_ebx =3D=3D -2 || ret_ecx =3D=3D -2 || ret= _edx =3D=3D -2) + if (virXMLPropUInt(node, "eax_in", 0, VIR_XML_PROP_REQUIRED, &cpuid.ea= x_in) < 0) + return -1; + if (virXMLPropUInt(node, "ecx_in", 0, VIR_XML_PROP_NONE, &cpuid.ecx_in= ) < 0) + return -1; + if (virXMLPropUInt(node, "eax", 0, VIR_XML_PROP_NONE, &cpuid.eax) < 0) + return -1; + if (virXMLPropUInt(node, "ebx", 0, VIR_XML_PROP_NONE, &cpuid.ebx) < 0) + return -1; + if (virXMLPropUInt(node, "ecx", 0, VIR_XML_PROP_NONE, &cpuid.ecx) < 0) + return -1; + if (virXMLPropUInt(node, "edx", 0, VIR_XML_PROP_NONE, &cpuid.edx) < 0) return -1; =20 item->type =3D VIR_CPU_X86_DATA_CPUID; - cpuid =3D &item->data.cpuid; - cpuid->eax_in =3D eax_in; - cpuid->ecx_in =3D ecx_in; - cpuid->eax =3D eax; - cpuid->ebx =3D ebx; - cpuid->ecx =3D ecx; - cpuid->edx =3D edx; + item->data.cpuid =3D cpuid; return 0; } =20 @@ -1122,7 +1113,7 @@ x86FeatureParse(xmlXPathContextPtr ctxt, for (i =3D 0; i < n; i++) { ctxt->node =3D nodes[i]; if (virXMLNodeNameEqual(nodes[i], "cpuid")) { - if (x86ParseCPUID(ctxt, &item) < 0) { + if (x86ParseCPUID(ctxt->node, &item) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid cpuid[%zu] in %s feature"), i, feature->name); @@ -1812,7 +1803,7 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt) for (i =3D 0; i < n; i++) { ctxt->node =3D nodes[i]; if (virXMLNodeNameEqual(nodes[i], "cpuid")) { - if (x86ParseCPUID(ctxt, &item) < 0) { + if (x86ParseCPUID(ctxt->node, &item) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse cpuid[%zu]"), i); return NULL; --=20 2.31.1 From nobody Mon Apr 29 22:44:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1636043546; cv=none; d=zohomail.com; s=zohoarc; b=k6sA7l9JfpYSwk8fRSzEpN+mA5gkjqwly5WBAduOR7SJjiHPLy3cikYSjDd46eSiuRmG2mjHHVMYRhq3Y1d8dYgEcntZOBp6/wUMy99CobWO7CmeYo9EAjojesY4pmX9Ff9pEIonKdkwFHVL5VVKwqxEqhtUtXhPgz3xbk2kXHY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636043546; 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=Kv87WaFOI8dk2WDvNVR9dZZqlrOPe+n5WkqEUq/uMJo=; b=EyZUVnnOq7Rc8x9OfsYXYH5WTsRxJTWMnSgjDpUOWmCgKOBkWesKvcvMZ1rIpES9JYuV4vx0E04lZyxuhFmaxn0Opn7eGYLAgINWXvhG2hNqFwimenw5SvBYPDThrQcy1BGWblhTZ7LJDlBM5MiSYzLZ4iILwsN2Az32I6SRd9E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1636043546977833.4725844336695; Thu, 4 Nov 2021 09:32:26 -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-518-u6Aj_RB3MUqg7lVI0rYdpg-1; Thu, 04 Nov 2021 12:32:23 -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 DF9808799EC; Thu, 4 Nov 2021 16:32:18 +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 9527A5D9DE; Thu, 4 Nov 2021 16:32:18 +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 5B6084EA30; Thu, 4 Nov 2021 16:32:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A4GRNQ4026340 for ; Thu, 4 Nov 2021 12:27:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id BC16219724; Thu, 4 Nov 2021 16:27:23 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 124B819C79; Thu, 4 Nov 2021 16:27:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636043545; 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=Kv87WaFOI8dk2WDvNVR9dZZqlrOPe+n5WkqEUq/uMJo=; b=fagoMQVMudLFGht5pHgW+rCgVCFabz4D2mMDOLt6vfudrOW6CHKT6sAZtgQezhie30Qj4b T8qyZeBIk/lgxB6041tpHC7M35NVGcS3Lz/6iWEmpLCysIQ15GlLQjMGFCTRPE2/YjEghl asTL6Gem9j5vlbnCki5+g1xdKFpwMyI= X-MC-Unique: u6Aj_RB3MUqg7lVI0rYdpg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 02/20] cpu_x86: Simplify x86ParseMSR Date: Thu, 4 Nov 2021 17:27:02 +0100 Message-Id: <20211104162720.108973-3-twiederh@redhat.com> In-Reply-To: <20211104162720.108973-1-twiederh@redhat.com> References: <20211104162720.108973-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.14 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) X-ZM-MESSAGEID: 1636043548422100001 Content-Type: text/plain; charset="utf-8" ... by using virXMLProp*() helpers. These only require a xmlNodePtr and do not need a xmlXPathContextPtr. Reflect that in the function signature. Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/cpu/cpu_x86.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index b0f6fa8f34..006221215a 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -1048,26 +1048,22 @@ x86ParseCPUID(xmlNodePtr node, =20 =20 static int -x86ParseMSR(xmlXPathContextPtr ctxt, +x86ParseMSR(xmlNodePtr node, virCPUx86DataItem *item) { - virCPUx86MSR *msr; - unsigned long index; - unsigned long eax; - unsigned long edx; + virCPUx86MSR msr; =20 - memset(item, 0, sizeof(*item)); + memset(&msr, 0, sizeof(msr)); =20 - if (virXPathULongHex("string(@index)", ctxt, &index) < 0 || - virXPathULongHex("string(@eax)", ctxt, &eax) < 0 || - virXPathULongHex("string(@edx)", ctxt, &edx) < 0) + if (virXMLPropUInt(node, "index", 0, VIR_XML_PROP_REQUIRED, &msr.index= ) < 0) + return -1; + if (virXMLPropUInt(node, "eax", 0, VIR_XML_PROP_REQUIRED, &msr.eax) < = 0) + return -1; + if (virXMLPropUInt(node, "edx", 0, VIR_XML_PROP_REQUIRED, &msr.edx) < = 0) return -1; =20 item->type =3D VIR_CPU_X86_DATA_MSR; - msr =3D &item->data.msr; - msr->index =3D index; - msr->eax =3D eax; - msr->edx =3D edx; + item->data.msr =3D msr; return 0; } =20 @@ -1120,7 +1116,7 @@ x86FeatureParse(xmlXPathContextPtr ctxt, return -1; } } else { - if (x86ParseMSR(ctxt, &item) < 0) { + if (x86ParseMSR(ctxt->node, &item) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid msr[%zu] in %s feature"), i, feature->name); @@ -1809,7 +1805,7 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt) return NULL; } } else { - if (x86ParseMSR(ctxt, &item) < 0) { + if (x86ParseMSR(ctxt->node, &item) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse msr[%zu]"), i); return NULL; --=20 2.31.1 From nobody Mon Apr 29 22:44:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1636043260; cv=none; d=zohomail.com; s=zohoarc; b=jjKhbvLisom94cCzCdS7JdQU2cd449HY1myXEKi9iuUTTpLUMMiSqeB4b6lTQFkR4xvcVP44wNXsoVF/2EZwgcVcw58rimFYHk8/gfx0EqX7xWcgvVZBoZpKqmwA7gr8uuM36mVnxE4AXscBGm2dirNxGKwabAmlu5eEgliEC0k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636043260; 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=OO79J1BSd4A8IaIU2xrdumL9N4e5H4cj/oKlQ3w5wn4=; b=K9wlZe6+d5JRaaH1wfRX7v76FaumlE0VrbKV6pWiAPbw+erUmPJ9V/ULOTdu1jJrlahYSav0GY6rLwy0ZXQoU+g6XY8j9XrBpFQ8VygMQVQA3kJCHHh/zgoBMEFSt7A3BYbRnR0dyW2JWKFxZPqd/C89LusXbwBQ2tdWCvq7R6Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1636043260458464.4797775756108; Thu, 4 Nov 2021 09:27:40 -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-378-T4gyflAnOwuaz1cYAUzw4A-1; Thu, 04 Nov 2021 12:27:36 -0400 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 33B9A8AF849; Thu, 4 Nov 2021 16:27:31 +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 1FD0360BD8; Thu, 4 Nov 2021 16:27:30 +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 43C4A4EA2A; Thu, 4 Nov 2021 16:27:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A4GROZ9026352 for ; Thu, 4 Nov 2021 12:27:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id C5DCA19D9F; Thu, 4 Nov 2021 16:27:24 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B89519C79; Thu, 4 Nov 2021 16:27:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636043259; 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=OO79J1BSd4A8IaIU2xrdumL9N4e5H4cj/oKlQ3w5wn4=; b=UhoQK8XhytMq9AFzhh6da52GHbfWm7RiPNdlQpddTpsfObfRl1YixnTIj+bHoQDicOlXNO Fq2ZB87RDtsHw/HyMoGFKBYpKZjYWGX7c5oIB3xIDA3BUtmO8Cwri7DRVX4w61ihbZG9bN TSzhXgWMzGApcufXCooKTVh7skc0bac= X-MC-Unique: T4gyflAnOwuaz1cYAUzw4A-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 03/20] cpu_x86: Add x86ParseDataItemList Date: Thu, 4 Nov 2021 17:27:03 +0100 Message-Id: <20211104162720.108973-4-twiederh@redhat.com> In-Reply-To: <20211104162720.108973-1-twiederh@redhat.com> References: <20211104162720.108973-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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) X-ZM-MESSAGEID: 1636043260744100001 Content-Type: text/plain; charset="utf-8" Factor out duplicated code from x86FeatureParse and virCPUx86DataParse. This also consolidates error messages. Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/cpu/cpu_x86.c | 106 ++++++++++++++++++---------------------------- 1 file changed, 41 insertions(+), 65 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 006221215a..29b4df1f79 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -1068,17 +1068,51 @@ x86ParseMSR(xmlNodePtr node, } =20 =20 +static int +x86ParseDataItemList(virCPUx86Data *cpudata, + xmlNodePtr node) +{ + size_t i; + + if (xmlChildElementCount(node) <=3D 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no x86 CPU data fo= und")); + return -1; + } + + node =3D xmlFirstElementChild(node); + for (i =3D 0; node; ++i) { + virCPUx86DataItem item; + + if (virXMLNodeNameEqual(node, "cpuid")) { + if (x86ParseCPUID(node, &item) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid cpuid[%zu]"), i); + return -1; + } + } else { + if (x86ParseMSR(node, &item) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid msr[%zu]"), i); + return -1; + } + } + + if (virCPUx86DataAddItem(cpudata, &item) < 0) + return -1; + + node =3D xmlNextElementSibling(node); + } + + return 0; +} + static int x86FeatureParse(xmlXPathContextPtr ctxt, const char *name, void *data) { virCPUx86Map *map =3D data; - g_autofree xmlNodePtr *nodes =3D NULL; g_autoptr(virCPUx86Feature) feature =3D NULL; - virCPUx86DataItem item; - size_t i; - int n; g_autofree char *str =3D NULL; =20 feature =3D g_new0(virCPUx86Feature, 1); @@ -1095,38 +1129,8 @@ x86FeatureParse(xmlXPathContextPtr ctxt, if (STREQ_NULLABLE(str, "no")) feature->migratable =3D false; =20 - n =3D virXPathNodeSet("./cpuid|./msr", ctxt, &nodes); - if (n < 0) - return -1; - - if (n =3D=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Missing cpuid or msr element in feature %s"), - feature->name); + if (x86ParseDataItemList(&feature->data, ctxt->node) < 0) return -1; - } - - for (i =3D 0; i < n; i++) { - ctxt->node =3D nodes[i]; - if (virXMLNodeNameEqual(nodes[i], "cpuid")) { - if (x86ParseCPUID(ctxt->node, &item) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid cpuid[%zu] in %s feature"), - i, feature->name); - return -1; - } - } else { - if (x86ParseMSR(ctxt->node, &item) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid msr[%zu] in %s feature"), - i, feature->name); - return -1; - } - } - - if (virCPUx86DataAddItem(&feature->data, &item)) - return -1; - } =20 if (!feature->migratable) VIR_APPEND_ELEMENT_COPY(map->migrate_blockers, map->nblockers, fea= ture); @@ -1780,41 +1784,13 @@ virCPUx86DataFormat(const virCPUData *data) static virCPUData * virCPUx86DataParse(xmlXPathContextPtr ctxt) { - g_autofree xmlNodePtr *nodes =3D NULL; g_autoptr(virCPUData) cpuData =3D NULL; - virCPUx86DataItem item; - size_t i; - int n; - - n =3D virXPathNodeSet("/cpudata/cpuid|/cpudata/msr", ctxt, &nodes); - if (n <=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("no x86 CPU data found")); - return NULL; - } =20 if (!(cpuData =3D virCPUDataNew(VIR_ARCH_X86_64))) return NULL; =20 - for (i =3D 0; i < n; i++) { - ctxt->node =3D nodes[i]; - if (virXMLNodeNameEqual(nodes[i], "cpuid")) { - if (x86ParseCPUID(ctxt->node, &item) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to parse cpuid[%zu]"), i); - return NULL; - } - } else { - if (x86ParseMSR(ctxt->node, &item) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to parse msr[%zu]"), i); - return NULL; - } - } - - if (virCPUx86DataAdd(cpuData, &item) < 0) - return NULL; - } + if (x86ParseDataItemList(&cpuData->data.x86, ctxt->node) < 0) + return NULL; =20 return g_steal_pointer(&cpuData); } --=20 2.31.1 From nobody Mon Apr 29 22:44:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1636043551; cv=none; d=zohomail.com; s=zohoarc; b=dZAun0aPWsfrDywGujot1XM5FXXSDqelgt8iahnvG/qkNcBNBQgC6u8i6g9UI/saC71Xn6pzsjLq6aJj80MQHxCqx9/AOFoelVDKDucBT53arJgGe628pXV6w1E0QUyI2tXbzwLnBaRFuEQuM7PFXnqYXj+jSdpyFU3riveOXIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636043551; 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=zk4ggB5PTql1yLq+rY9cuZkENa5+iJDWPRLUEVVmh4A=; b=MZ4rMlvmVj2UDY1D0Ux6Sv6CYbkUwMl4Fh0U7r8XMjZTY9nYga0f+2X9beqq6dzsl+vwi3q5q7wQDTgHgnnAd8W6wK8yBfnCrkwtvP64JhobahNdfdqAxN2XoutMsrUBCzdTsGxrP8kShBokJPZvlMJOKyFW1P/mOlDnJbRrjZ0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 163604355108441.54940054587996; Thu, 4 Nov 2021 09:32:31 -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-251-mkDYbLdaMhO_ZcA2bC9ygg-1; Thu, 04 Nov 2021 12:32:28 -0400 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 93EF8879515; Thu, 4 Nov 2021 16:32:22 +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 7292D60C0F; Thu, 4 Nov 2021 16:32:22 +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 340F31806D03; Thu, 4 Nov 2021 16:32:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A4GRP1U026360 for ; Thu, 4 Nov 2021 12:27:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id D08DF19723; Thu, 4 Nov 2021 16:27:25 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 25BBA19C79; Thu, 4 Nov 2021 16:27:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636043550; 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=zk4ggB5PTql1yLq+rY9cuZkENa5+iJDWPRLUEVVmh4A=; b=B7za1W0PuBFRbe+O+MJtra6stw5rBVOiUWVxXpYhDK53YmiAUn2/BqLmBAjKaZojnL6eOy PYInZYW1gDhgrbQan+/Up/6IOJh3WOlunNh7xKpS1EtGtqq7FQrnnNLi7Y9vTRh3xzrqh1 X+t3M0M2fyx4T8h/B1NovIqPyu//ir4= X-MC-Unique: mkDYbLdaMhO_ZcA2bC9ygg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 04/20] cpu: Change virCPUArchDataParse to take xmlNodePtr Date: Thu, 4 Nov 2021 17:27:04 +0100 Message-Id: <20211104162720.108973-5-twiederh@redhat.com> In-Reply-To: <20211104162720.108973-1-twiederh@redhat.com> References: <20211104162720.108973-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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) X-ZM-MESSAGEID: 1636043553251100001 Content-Type: text/plain; charset="utf-8" The function does not need a full xmlXPathContextPtr any longer and a later patch will require a call to this function with only a xmlNodePtr available. Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/cpu/cpu.c | 2 +- src/cpu/cpu.h | 2 +- src/cpu/cpu_x86.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index b4965f3ee0..7823c7cd3d 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -832,7 +832,7 @@ virCPUDataParse(const char *xmlStr) return NULL; } =20 - data =3D driver->dataParse(ctxt); + data =3D driver->dataParse(ctxt->node); return data; } =20 diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index d11d2641fc..c4897a33f5 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -98,7 +98,7 @@ typedef char * (*virCPUArchDataFormat)(const virCPUData *data); =20 typedef virCPUData * -(*virCPUArchDataParse)(xmlXPathContextPtr ctxt); +(*virCPUArchDataParse)(xmlNodePtr node); =20 typedef int (*virCPUArchGetModels)(char ***models); diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 29b4df1f79..a08ac225ef 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -1782,14 +1782,14 @@ virCPUx86DataFormat(const virCPUData *data) =20 =20 static virCPUData * -virCPUx86DataParse(xmlXPathContextPtr ctxt) +virCPUx86DataParse(xmlNodePtr node) { g_autoptr(virCPUData) cpuData =3D NULL; =20 if (!(cpuData =3D virCPUDataNew(VIR_ARCH_X86_64))) return NULL; =20 - if (x86ParseDataItemList(&cpuData->data.x86, ctxt->node) < 0) + if (x86ParseDataItemList(&cpuData->data.x86, node) < 0) return NULL; =20 return g_steal_pointer(&cpuData); --=20 2.31.1 From nobody Mon Apr 29 22:44:40 2024 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=1636043554; cv=none; d=zohomail.com; s=zohoarc; b=RrJQlmzopyBKM/fb7P2b4HevdqMCRCFEMFVF3Ifjqi7UKPPle+Gp7FkOJ46BXM8EKQqA162Qn7iq4FLTWeRG+LEXM5WMcdLYyoirmTBljcXwmbL8tc7d/fX5GAJjiJWzWdDh/Jz4udiVj0z0oj0hDJXDGrER2IwY7FPOmCGOjqU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636043554; 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=ym+0kegCrsjnmOgpe1UiqlBuldZIsNZqhTEe1crhnYs=; b=lWkzrj50qFSSqJQSm1xJssHGLPwi9rldZ2D8OQRhxxwWh2i3Q6aEED0XXdu8NCsgLQD6fB5HP3HL7E7pIdjlVeV1zsQyTLflOYEf+TByZgyEwXSy8+A47QymtCkoEQOPYcIKl7Vs+OlvrndMKYCRTHKdDi7jf6WhpOEjOwz9NwU= 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) 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 1636043554539358.51801951212656; Thu, 4 Nov 2021 09:32:34 -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-479-3IqzNn99PmCOYldmNwQeAw-1; Thu, 04 Nov 2021 12:32:30 -0400 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 1E3A8CC621; Thu, 4 Nov 2021 16:32:25 +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 F342760C17; Thu, 4 Nov 2021 16:32:24 +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 BEBFC4EA2A; Thu, 4 Nov 2021 16:32:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A4GRQDc026367 for ; Thu, 4 Nov 2021 12:27:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id D80F619C79; Thu, 4 Nov 2021 16:27:26 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2FE8A19D9F; Thu, 4 Nov 2021 16:27:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636043553; 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=ym+0kegCrsjnmOgpe1UiqlBuldZIsNZqhTEe1crhnYs=; b=GLP3MzrCMP3MzBePUk65geyDU/DYY7zE+VcJDhaV88HB0Q2F0HbpI3ZQFWNS2/3YMISjHz 9YZsIxm9vuXw50RCze4RpQ9J0HBiyMgwuXvunmzEAsA9ppPA5CgkgTQADmI7ZwtGoeytEX NZbLJ1WT6yEpkihX0DXdgGdBbcMe/i0= X-MC-Unique: 3IqzNn99PmCOYldmNwQeAw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 05/20] cpu: Split up virCPUDataParse Date: Thu, 4 Nov 2021 17:27:05 +0100 Message-Id: <20211104162720.108973-6-twiederh@redhat.com> In-Reply-To: <20211104162720.108973-1-twiederh@redhat.com> References: <20211104162720.108973-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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) X-ZM-MESSAGEID: 1636043555823100001 Content-Type: text/plain; charset="utf-8" This makes it possible to call virCPUDataParse with a xmlNodePtr, which will be required by a later patch. Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/cpu/cpu.c | 29 +++++++++++++++++++++-------- src/cpu/cpu.h | 2 ++ src/libvirt_private.syms | 1 + 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 7823c7cd3d..b97d06c7d8 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -803,11 +803,8 @@ virCPUDataFormat(const virCPUData *data) virCPUData * virCPUDataParse(const char *xmlStr) { - struct cpuArchDriver *driver; g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; - virCPUData *data =3D NULL; - g_autofree char *arch =3D NULL; =20 VIR_DEBUG("xmlStr=3D%s", xmlStr); =20 @@ -817,7 +814,25 @@ virCPUDataParse(const char *xmlStr) return NULL; } =20 - if (!(arch =3D virXPathString("string(/cpudata/@arch)", ctxt))) { + return virCPUDataParseNode(ctxt->node); +} + + +/** + * virCPUDataParseNode: + * + * @node: XML node as produced by virCPUDataFormat + * + * Parses XML representation of virCPUData structure. + * + * Returns internal CPU data structure parsed from the XML or NULL on erro= r. + */ +virCPUData *virCPUDataParseNode(xmlNodePtr node) +{ + g_autofree char *arch =3D NULL; + struct cpuArchDriver *driver; + + if (!(arch =3D virXMLPropString(node, "arch"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing CPU data architecture")); return NULL; @@ -827,13 +842,11 @@ virCPUDataParse(const char *xmlStr) return NULL; =20 if (!driver->dataParse) { - virReportError(VIR_ERR_NO_SUPPORT, - _("cannot parse %s CPU data"), arch); + virReportError(VIR_ERR_NO_SUPPORT, _("cannot parse %s CPU data"), = arch); return NULL; } =20 - data =3D driver->dataParse(ctxt->node); - return data; + return driver->dataParse(node); } =20 =20 diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index c4897a33f5..a67af61757 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -285,3 +285,5 @@ char *virCPUDataFormat(const virCPUData *data) ATTRIBUTE_NONNULL(1); virCPUData *virCPUDataParse(const char *xmlStr) ATTRIBUTE_NONNULL(1); +virCPUData *virCPUDataParseNode(xmlNodePtr node) + ATTRIBUTE_NONNULL(1); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 55ae7d5b6f..21a723035d 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1462,6 +1462,7 @@ virCPUDataFormat; virCPUDataFree; virCPUDataNew; virCPUDataParse; +virCPUDataParseNode; virCPUExpandFeatures; virCPUGetHost; virCPUGetHostIsSupported; --=20 2.31.1 From nobody Mon Apr 29 22:44:40 2024 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=1636043555; cv=none; d=zohomail.com; s=zohoarc; b=bGSagA7zrV/xG6QOA7lF2f4YPHp7oI+PP9t0yKHnyxo6LyjAh/9m+1w0P6EwbWvdIA2IewgSp1mNtl2q4j3im06iDsUu9DJfz4ZkB/N30WMCTa2F4YkLJkiiVbth/Xuh7+tVLSCY/2IQJUSYLsxWUAgvSe2gSJzyE3pzyWmotM4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636043555; 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=57ENT8foVnq9LUNY4NYhpzKh7nUkzzyeWjJkX7CxXL8=; b=ffJc8gONWK4jp8UMZ46LNII9JOgStMibTVmse3pSw+ES9ZHOJ5U3ZpQ8VZ7YdRnWVpI+9rzWM1hkmxe8ECG3exPJmwEEcHN20HQt5x4LQuOWDZCLlnE8FuaVk+cZ+X6WGEmyNJF8ojcdPUmYubGbuEkxnKkjM8Uv9DXpy5XtmIE= 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) 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 1636043555691486.1718923513989; Thu, 4 Nov 2021 09:32:35 -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-297-cvxTtDSvMuWvqBcW4bjTDA-1; Thu, 04 Nov 2021 12:32:33 -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 EEF348799F8; Thu, 4 Nov 2021 16:32:27 +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 C63FD5D9DE; Thu, 4 Nov 2021 16:32:27 +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 985C0180BAD2; Thu, 4 Nov 2021 16:32:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A4GRRe6026372 for ; Thu, 4 Nov 2021 12:27:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id EB61419D9F; Thu, 4 Nov 2021 16:27:27 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 387F119C79; Thu, 4 Nov 2021 16:27:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636043554; 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=57ENT8foVnq9LUNY4NYhpzKh7nUkzzyeWjJkX7CxXL8=; b=AHLj8Kh6JWyTgnirYxd2VIWdw/bI2HAKX6low9G+kocHgp5nxIexpWxJo+yQxQ/s+ADQ1X prWp4AlVAKQtiOk8XSB0zbEqmmG6MohYNwzz2klzAqb5cU0YaMtuu9/LMnV0b5iyUqkCNo +uY9PeqVbN6VRNVo08Vw3buPbcpSxn8= X-MC-Unique: cvxTtDSvMuWvqBcW4bjTDA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 06/20] cpu: Add virCPUDataIsIdentical Date: Thu, 4 Nov 2021 17:27:06 +0100 Message-Id: <20211104162720.108973-7-twiederh@redhat.com> In-Reply-To: <20211104162720.108973-1-twiederh@redhat.com> References: <20211104162720.108973-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.14 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) X-ZM-MESSAGEID: 1636043557732100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/cpu/cpu.c | 28 ++++++++++++++++++++++++++++ src/cpu/cpu.h | 9 +++++++++ src/libvirt_private.syms | 1 + 3 files changed, 38 insertions(+) diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index b97d06c7d8..0c1c7902f0 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -1141,6 +1141,34 @@ virCPUDataAddFeature(virCPUData *cpuData, } =20 =20 +/** + * virCPUDataIsIdentical: + * + * Returns VIR_CPU_COMPARE_IDENTICAL if @a and @b are identical, + * VIR_CPU_COMPARE_INCOMPATIBLE if @a and @b are not identical, or + * VIR_CPU_COMPARE_ERROR on error. + */ +virCPUCompareResult +virCPUDataIsIdentical(const virCPUData *a, + const virCPUData *b) +{ + struct cpuArchDriver *driver; + + VIR_DEBUG("a=3D%p, b=3D%p", a, b); + + if (!a || !b) + return VIR_CPU_COMPARE_ERROR; + + if (!(driver =3D cpuGetSubDriver(a->arch))) + return VIR_CPU_COMPARE_ERROR; + + if (!driver->dataIsIdentical) + return VIR_CPU_COMPARE_ERROR; + + return driver->dataIsIdentical(a, b); +} + + /** * virCPUArchIsSupported: * diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index a67af61757..7ecb0d6921 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -123,6 +123,10 @@ typedef int (*virCPUArchDataAddFeature)(virCPUData *cpuData, const char *name); =20 +typedef virCPUCompareResult +(*virCPUArchDataIsIdentical)(const virCPUData *a, + const virCPUData *b); + struct cpuArchDriver { const char *name; const virArch *arch; @@ -146,6 +150,7 @@ struct cpuArchDriver { virCPUArchCopyMigratable copyMigratable; virCPUArchValidateFeatures validateFeatures; virCPUArchDataAddFeature dataAddFeature; + virCPUArchDataIsIdentical dataIsIdentical; }; =20 =20 @@ -275,6 +280,10 @@ int virCPUDataAddFeature(virCPUData *cpuData, const char *name); =20 +virCPUCompareResult +virCPUDataIsIdentical(const virCPUData *a, + const virCPUData *b); + bool virCPUArchIsSupported(virArch arch); =20 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 21a723035d..3b6645b4a8 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1460,6 +1460,7 @@ virCPUDataAddFeature; virCPUDataCheckFeature; virCPUDataFormat; virCPUDataFree; +virCPUDataIsIdentical; virCPUDataNew; virCPUDataParse; virCPUDataParseNode; --=20 2.31.1 From nobody Mon Apr 29 22:44:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1636043559; cv=none; d=zohomail.com; s=zohoarc; b=UoouHZL4pjf0p3CIQqUOhPlSarFH/Fphma39Fp3l4h6HVCxcHMiokH/BxdZ2eXvR+ZBoeLBMt9TAqnDvwpOvjvc17mBAVZCgElbxTfOrO5LK9CiklwvMyXswoEr3duem3wyts01prp9Tp6Fv2p3MDio5OxYB/409k4lTgLURZ4A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636043559; 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=Vsy593sWOraW1TuLUIDl0Q+y6cH+Cyg9+j9tmjDbC6I=; b=HjpemRmxXwAtZDM0n3xLt/U1SJzlUoya7+1gdI3HNW89WVswogBxzY2gIGkvDRa27PVKYs5AJCR/nEbmLm9pTBQcnHWRnM/MwsYH2MVOtHgD5oLxwOIVHEuv+TvVx3tOYyX2IQ6btsL3dgLObF9b5bev5dLkTS5Dwhd2nwP58tE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1636043559016702.5534112337768; Thu, 4 Nov 2021 09:32:39 -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-398-RrG2ShibPMKRAFZZVIKrxw-1; Thu, 04 Nov 2021 12:32:36 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5CEC61018722; Thu, 4 Nov 2021 16:32:31 +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 3A66F70953; Thu, 4 Nov 2021 16:32:31 +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 2997E4EA37; Thu, 4 Nov 2021 16:32:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A4GRTxi026392 for ; Thu, 4 Nov 2021 12:27:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id F365319D9F; Thu, 4 Nov 2021 16:27:28 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B72419C79; Thu, 4 Nov 2021 16:27:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636043558; 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=Vsy593sWOraW1TuLUIDl0Q+y6cH+Cyg9+j9tmjDbC6I=; b=iiiJem3JCDWw1Qt/iAdQHemEw+C9J96kCK0qo8vYCJVNdftiM3m+uQ+iV6bJoH1H1kdOXv jGe+Tn7lCkbDVglYT56MaaD+ijIV7Sh+KUw0+KhcXn0SeuQWmac9WYo4Il9M+L1lSQ8shd 2F7tAH0h9Uil1KlNGGv0yUi93r+uA1Y= X-MC-Unique: RrG2ShibPMKRAFZZVIKrxw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 07/20] cpu_x86: Implement virCPUDataIsIdentical for x86 Date: Thu, 4 Nov 2021 17:27:07 +0100 Message-Id: <20211104162720.108973-8-twiederh@redhat.com> In-Reply-To: <20211104162720.108973-1-twiederh@redhat.com> References: <20211104162720.108973-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.13 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) X-ZM-MESSAGEID: 1636043560192100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/cpu/cpu_x86.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index a08ac225ef..5ce193e693 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -3332,6 +3332,74 @@ virCPUx86DataAddFeature(virCPUData *cpuData, } =20 =20 +static bool +virCPUx86DataItemIsIdentical(const virCPUx86DataItem *a, + const virCPUx86DataItem *b) +{ + if (a->type !=3D b->type) + return false; + + switch (a->type) { + case VIR_CPU_X86_DATA_NONE: + break; + + case VIR_CPU_X86_DATA_CPUID: + return a->data.cpuid.eax_in =3D=3D b->data.cpuid.eax_in && + a->data.cpuid.ecx_in =3D=3D b->data.cpuid.ecx_in && + a->data.cpuid.eax =3D=3D b->data.cpuid.eax && + a->data.cpuid.ebx =3D=3D b->data.cpuid.ebx && + a->data.cpuid.ecx =3D=3D b->data.cpuid.ecx && + a->data.cpuid.edx =3D=3D b->data.cpuid.edx; + + case VIR_CPU_X86_DATA_MSR: + return a->data.msr.index =3D=3D b->data.msr.index && + a->data.msr.eax =3D=3D b->data.msr.eax && + a->data.msr.edx =3D=3D b->data.msr.edx; + } + + return true; +} + +static virCPUCompareResult +virCPUx86DataIsIdentical(const virCPUData *a, + const virCPUData *b) +{ + const virCPUx86Data *adata; + const virCPUx86Data *bdata; + size_t i; + size_t j; + + if (!a || !b) + return VIR_CPU_COMPARE_ERROR; + + if (a->arch !=3D b->arch) + return VIR_CPU_COMPARE_INCOMPATIBLE; + + if (!((adata =3D &a->data.x86) && (bdata =3D &b->data.x86))) + return VIR_CPU_COMPARE_ERROR; + + if (adata->len !=3D bdata->len) + return VIR_CPU_COMPARE_INCOMPATIBLE; + + for (i =3D 0; i < adata->len; ++i) { + bool found =3D false; + + for (j =3D 0; j < bdata->len; ++j) { + if (!virCPUx86DataItemIsIdentical(&adata->items[i], + &bdata->items[j])) + continue; + + found =3D true; + break; + } + + if (!found) + return VIR_CPU_COMPARE_INCOMPATIBLE; + } + + return VIR_CPU_COMPARE_IDENTICAL; +} + static bool virCPUx86FeatureIsMSR(const char *name) { @@ -3415,4 +3483,5 @@ struct cpuArchDriver cpuDriverX86 =3D { .copyMigratable =3D virCPUx86CopyMigratable, .validateFeatures =3D virCPUx86ValidateFeatures, .dataAddFeature =3D virCPUx86DataAddFeature, + .dataIsIdentical =3D virCPUx86DataIsIdentical, }; --=20 2.31.1 From nobody Mon Apr 29 22:44:40 2024 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=1636043566; cv=none; d=zohomail.com; s=zohoarc; b=JrrjYBp4HpWRhtZZbJXWDUZtSo2Q8jiMTUq0xf0LfVticCxTAQdtz03ATgEW8JQe3BQLewFadksrqpLUkqXGzkAD7MvIcf270snbqKrn8jdJS2IvgUWOxsg6m2zWbb0437vNEaS93Y2JCo+iFJeK+tmuXkS4Ol8lYj5JD6W+NUg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636043566; 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=kLoMDo5AAjI7fd1RBrr3KLzQIEMuA17rIRI8I0Upu/w=; b=dUyqg2mtst4zCWXb53cncK1M5jpYX2f4PLerLK3vWaLUDPe1yjEEcqZ6yQIBfv+dSwfVbPNK4JzpLjBLOagw76OQOzm8KvfLRwU3UKptnR97gWoS1ZNMnlwIV8E82eopCgFINd8VYvmtBl35AZoOegfVtm/uHdC1rBuYRcgDqXQ= 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) 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 1636043566632234.9245565418663; Thu, 4 Nov 2021 09:32:46 -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-499-w0QZG2NSOhaFQixddMtLWQ-1; Thu, 04 Nov 2021 12:32:44 -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 4F8921018721; Thu, 4 Nov 2021 16:32:35 +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 0797B5D9D3; Thu, 4 Nov 2021 16:32:35 +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 CFD6C180BAD2; Thu, 4 Nov 2021 16:32:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A4GRU0a026399 for ; Thu, 4 Nov 2021 12:27:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 095CF19723; Thu, 4 Nov 2021 16:27:30 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53AD419C79; Thu, 4 Nov 2021 16:27:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636043565; 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=kLoMDo5AAjI7fd1RBrr3KLzQIEMuA17rIRI8I0Upu/w=; b=fuQM920KhHvZvLpqspVFuoYNO8Hr6Njxo7vt1YYY8c4pZcAlTPYBQ74MOWnwinUuChLNhn 0j7X1K03S/zP8fnsCMAipXDfgYh3GYG8GQyXZfL63yUZBwVpZ+gA5J/NHvkB6TrknZSFE0 tXq63ZEuyqN2YDskJMFhrsa7gypVPBk= X-MC-Unique: w0QZG2NSOhaFQixddMtLWQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 08/20] cpu_arm: No need to protect macro definitions Date: Thu, 4 Nov 2021 17:27:08 +0100 Message-Id: <20211104162720.108973-9-twiederh@redhat.com> In-Reply-To: <20211104162720.108973-1-twiederh@redhat.com> References: <20211104162720.108973-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.14 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) X-ZM-MESSAGEID: 1636043567012100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/cpu/cpu_arm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c index 09ade1d422..ac174891b7 100644 --- a/src/cpu/cpu_arm.c +++ b/src/cpu/cpu_arm.c @@ -39,12 +39,11 @@ #include "virxml.h" =20 #define VIR_FROM_THIS VIR_FROM_CPU -#if defined(__aarch64__) + /* Shift bit mask for parsing cpu flags */ -# define BIT_SHIFTS(n) (1UL << (n)) +#define BIT_SHIFTS(n) (1UL << (n)) /* The current max number of cpu flags on ARM is 32 */ -# define MAX_CPU_FLAGS 32 -#endif +#define MAX_CPU_FLAGS 32 =20 =20 VIR_LOG_INIT("cpu.cpu_arm"); --=20 2.31.1 From nobody Mon Apr 29 22:44:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1636043569; cv=none; d=zohomail.com; s=zohoarc; b=nYOjUDJzvlg6aG9XPtpVWLUWP4MPKBkN6Y0G9+XNIB+GhBFTcsyRWzXOnvP7bgsoWJvgbHUvANRDvGDxBNXwNZP5LsqDAh4JW8WHeOxgrnpbEhwDqYcnHN7c3mOxv5zQZWOgfgf5Z4oTRsE9NTTI4/x+9fbbGgIj/oodY4pA16I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636043569; 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=x7DtqHaKi5SqaqJIKEmI+SZdxqzVZY83/PrZQUZ7JcA=; b=dBdtHaPQnjEiiWF0OJI3RWGCjcbZ3Kq/SOeLv/auBV8aZwat1cVm4U+THdYEe4NfZ+GlJhWptk4OmgHV9ibUOgUzc+XW6K+V1l4eSKr2w64t1TUOVaVxlx1yPjsppW/JsoHSwrQHah0BM9SIKODkMG/B9diji3voLknJkxKHtRo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1636043569029939.7069037320618; Thu, 4 Nov 2021 09:32:49 -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-494-hnIqqwUfNFakswm0Sz_EEw-1; Thu, 04 Nov 2021 12:32:46 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D0E9280669D; Thu, 4 Nov 2021 16:32:37 +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 AC2805F4ED; Thu, 4 Nov 2021 16:32:37 +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 777D84EA38; Thu, 4 Nov 2021 16:32:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A4GRVjC026413 for ; Thu, 4 Nov 2021 12:27:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 103EC19D9F; Thu, 4 Nov 2021 16:27:31 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C55B19C79; Thu, 4 Nov 2021 16:27:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636043568; 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=x7DtqHaKi5SqaqJIKEmI+SZdxqzVZY83/PrZQUZ7JcA=; b=GYQ9xLwssA10QUxtJoOY6n8ykRbQpQtYVvpp2PlWQnS98APHM/TokgnKRwdcKenbkixzJe z/7xkC9mTzmEmquZMvKnszgJAqDgXu4a/qhqmMdyFdku370qec6HPwjS8MS2J4fvNoxw9I WDuLLosjTVvQ89sTl6NJHp87vtQ3uLk= X-MC-Unique: hnIqqwUfNFakswm0Sz_EEw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 09/20] cpu_arm: Implement virCPUDataIsIdentical for arm Date: Thu, 4 Nov 2021 17:27:09 +0100 Message-Id: <20211104162720.108973-10-twiederh@redhat.com> In-Reply-To: <20211104162720.108973-1-twiederh@redhat.com> References: <20211104162720.108973-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.15 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) X-ZM-MESSAGEID: 1636043569276100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/cpu/cpu_arm.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c index ac174891b7..c9114d53bf 100644 --- a/src/cpu/cpu_arm.c +++ b/src/cpu/cpu_arm.c @@ -124,6 +124,32 @@ virCPUarmDataClear(virCPUarmData *data) g_strfreev(data->features); } =20 +static virCPUCompareResult +virCPUarmDataIsIdentical(const virCPUData *a, + const virCPUData *b) +{ + size_t i; + + if (!a || !b) + return VIR_CPU_COMPARE_ERROR; + + if (a->arch !=3D b->arch) + return VIR_CPU_COMPARE_INCOMPATIBLE; + + if (a->data.arm.pvr !=3D b->data.arm.pvr) + return VIR_CPU_COMPARE_INCOMPATIBLE; + + if (a->data.arm.vendor_id !=3D b->data.arm.vendor_id) + return VIR_CPU_COMPARE_INCOMPATIBLE; + + for (i =3D 0; i < MAX_CPU_FLAGS; ++i) { + if (STRNEQ(a->data.arm.features[i], b->data.arm.features[i])) + return VIR_CPU_COMPARE_INCOMPATIBLE; + } + + return VIR_CPU_COMPARE_IDENTICAL; +} + static void virCPUarmDataFree(virCPUData *cpuData) { @@ -674,4 +700,5 @@ struct cpuArchDriver cpuDriverArm =3D { .baseline =3D virCPUarmBaseline, .update =3D virCPUarmUpdate, .validateFeatures =3D virCPUarmValidateFeatures, + .dataIsIdentical =3D virCPUarmDataIsIdentical, }; --=20 2.31.1 From nobody Mon Apr 29 22:44:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1636043268; cv=none; d=zohomail.com; s=zohoarc; b=TF+okW3UXXCCJ8oR3mq1hxbEGlfe5GaaibgzS7yF1ASLjKjDrR7WyFzEBRjluPfasBSnOYIAMm1a80XA17YjqZ7D8/Q8LkYOg+IXBZhxgAJwk2dvrY8U+0WCVOkAi/DRNj6uLQ5r5lwypU/2XXnbUG9VRN8OV7BRRBgriUy813Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636043268; 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=R9siTCEIsGzPSqwN6BpvP0ctGLWdIVv5TRt1inYmDnU=; b=MTNCsYboiykm/wEwOn2bkGAWx4/C2R10NSg9fUGgIb3OMtmIyAVC8XwjwTMDRFuoNSsbnqwBZbCHJrTCm2rzr/xp9udnp6IeV7ldYrO0tkoBQYhQLO9PYJL2/ZvnTH9PD/WGoehRzQj63ocRlnGxXXW6/9tDoQXB1c6e05r0UKA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1636043268342925.9739602744472; Thu, 4 Nov 2021 09:27:48 -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-44-kgWBq02CM_eu5iV2Jt5VXg-1; Thu, 04 Nov 2021 12:27:45 -0400 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 A2C348AF84E; Thu, 4 Nov 2021 16:27: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 8176157CD3; Thu, 4 Nov 2021 16:27:40 +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 EAE011806D04; Thu, 4 Nov 2021 16:27:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A4GRW40026418 for ; Thu, 4 Nov 2021 12:27:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1DDFC19723; Thu, 4 Nov 2021 16:27:32 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67DAF19C79; Thu, 4 Nov 2021 16:27:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636043267; 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=R9siTCEIsGzPSqwN6BpvP0ctGLWdIVv5TRt1inYmDnU=; b=E0+gusxeYLqltf+tbqzstfMcJR3qppDdfmwXGWfJDViS3yLJ3mhJXtYu6mjF2SEJCQFRuK TDOUnkwt4gc+KbZ70ta62QeQesIaKEtgZW/9060V1wxYaDqaf70iatZ+bc2wFW8T2eSH4O Qtnr8X8tWPpKMuDHXH8AC/BOLWeSzlw= X-MC-Unique: kgWBq02CM_eu5iV2Jt5VXg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 10/20] cpu_ppc64: Implement virCPUDataIsIdentical for ppc64 Date: Thu, 4 Nov 2021 17:27:10 +0100 Message-Id: <20211104162720.108973-11-twiederh@redhat.com> In-Reply-To: <20211104162720.108973-1-twiederh@redhat.com> References: <20211104162720.108973-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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) X-ZM-MESSAGEID: 1636043272807100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/cpu/cpu_ppc64.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c index 4909f61ff1..fcd68c8a7c 100644 --- a/src/cpu/cpu_ppc64.c +++ b/src/cpu/cpu_ppc64.c @@ -578,6 +578,31 @@ ppc64DriverDecode(virCPUDef *cpu, return 0; } =20 +static virCPUCompareResult +virCPUppc64DataIsIdentical(const virCPUData *a, + const virCPUData *b) +{ + size_t i; + + if (!a || !b) + return VIR_CPU_COMPARE_ERROR; + + if (a->arch !=3D b->arch) + return VIR_CPU_COMPARE_INCOMPATIBLE; + + if (a->data.ppc64.len !=3D b->data.ppc64.len) + return VIR_CPU_COMPARE_INCOMPATIBLE; + + for (i =3D 0; i < a->data.ppc64.len; ++i) { + if (a->data.ppc64.pvr[i].mask !=3D b->data.ppc64.pvr[i].mask) + return VIR_CPU_COMPARE_INCOMPATIBLE; + if (a->data.ppc64.pvr[i].value !=3D b->data.ppc64.pvr[i].value) + return VIR_CPU_COMPARE_INCOMPATIBLE; + } + + return VIR_CPU_COMPARE_IDENTICAL; +} + static void virCPUppc64DataFree(virCPUData *data) { @@ -749,4 +774,5 @@ struct cpuArchDriver cpuDriverPPC64 =3D { .update =3D virCPUppc64Update, .getModels =3D virCPUppc64DriverGetModels, .convertLegacy =3D virCPUppc64ConvertLegacy, + .dataIsIdentical =3D virCPUppc64DataIsIdentical, }; --=20 2.31.1 From nobody Mon Apr 29 22:44:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1636043570; cv=none; d=zohomail.com; s=zohoarc; b=RtYI12TdBG2DNCe5q6c76AtO4AokVCQpetDHi3zu6TuCcgjzrPurvnUpxZ1T4OfCAjx0RWn/g91P1i5U3azSF1/eRaT1RLzeK5h7hY7HY1LDK3zk4GgQl3TEgE+3I7Gm80V6wnGJ0+XAx0l7mPADlPWjcRjPXlPSWB9mR3vdWBM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636043570; 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=eghD3Bxy2yPtIhSI5t7SJPuOJ2fTk1sD5sXmC8o0zM0=; b=dqtOlI5m7irkxEubYOfySv9V+/+lIhLpByWncc4mHKJUUfjftbBDfK1dnAQshBQwO/mWvFhjpDomt74KwtuU8UeOHsdSZPKNWzaLqlIGv0OrtDqhnYnMCpgr6d2go/Arpz9Q0Deg5eb8/J/5Ydsx2ydTZpsve0FltwuT4lVw7Gs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 163604357013125.881417643554073; Thu, 4 Nov 2021 09:32:50 -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-28-0FTZ8RJ1MS-5dHpwpdD9Cw-1; Thu, 04 Nov 2021 12:32:46 -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 DF8208066EB; Thu, 4 Nov 2021 16:32:40 +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 BD151A6C42; Thu, 4 Nov 2021 16:32:40 +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 831CA4EA3B; Thu, 4 Nov 2021 16:32:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A4GRXOW026439 for ; Thu, 4 Nov 2021 12:27:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 25BE219D9F; Thu, 4 Nov 2021 16:27:33 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7197B19C79; Thu, 4 Nov 2021 16:27:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636043568; 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=eghD3Bxy2yPtIhSI5t7SJPuOJ2fTk1sD5sXmC8o0zM0=; b=NvhOBgYzK/mM49Rq49+7W/pfDqbEdxkQ91PeXRshTx0Ar0ZGhULQSuOElxgYF2dWnuGCRo egSn6B47/zSqRiGwyMChqYWncPER7QkvZ1mzjsj3nrQrFboSw7AY3L5o8HynjzqQx3hXzi mZYuH3f9V0ZFu7I9GoA1WcMjcyXK1/8= X-MC-Unique: 0FTZ8RJ1MS-5dHpwpdD9Cw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 11/20] cpu: Add virCPUDataNewCopy Date: Thu, 4 Nov 2021 17:27:11 +0100 Message-Id: <20211104162720.108973-12-twiederh@redhat.com> In-Reply-To: <20211104162720.108973-1-twiederh@redhat.com> References: <20211104162720.108973-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.16 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) X-ZM-MESSAGEID: 1636043571462100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/cpu/cpu.c | 21 +++++++++++++++++++++ src/cpu/cpu.h | 7 +++++++ src/libvirt_private.syms | 1 + 3 files changed, 29 insertions(+) diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 0c1c7902f0..b5669246b4 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -294,6 +294,27 @@ virCPUDataNew(virArch arch) } =20 =20 +/** + * virCPUDataNewCopy: + * + * Returns a copy of @data or NULL on error. + */ +virCPUData * +virCPUDataNewCopy(virCPUData *data) +{ + struct cpuArchDriver *driver; + + VIR_DEBUG("data=3D%p", data); + + if (!data) + return NULL; + + if ((driver =3D cpuGetSubDriver(data->arch)) && driver->dataCopyNew) + return driver->dataCopyNew(data); + + return NULL; +} + /** * virCPUDataFree: * diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index 7ecb0d6921..d3e5ca79f2 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -62,6 +62,9 @@ typedef int virCPUData **forbidden, virCPUData **vendor); =20 +typedef virCPUData * +(*cpuArchDataCopyNew)(virCPUData *data); + typedef void (*cpuArchDataFree) (virCPUData *data); =20 @@ -134,6 +137,7 @@ struct cpuArchDriver { virCPUArchCompare compare; cpuArchDecode decode; cpuArchEncode encode; + cpuArchDataCopyNew dataCopyNew; cpuArchDataFree dataFree; virCPUArchGetHost getHost; virCPUArchBaseline baseline; @@ -188,6 +192,9 @@ cpuEncode (virArch arch, virCPUData * virCPUDataNew(virArch arch); =20 +virCPUData * +virCPUDataNewCopy(virCPUData *data); + void virCPUDataFree(virCPUData *data); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCPUData, virCPUDataFree); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 3b6645b4a8..665db255a6 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1462,6 +1462,7 @@ virCPUDataFormat; virCPUDataFree; virCPUDataIsIdentical; virCPUDataNew; +virCPUDataNewCopy; virCPUDataParse; virCPUDataParseNode; virCPUExpandFeatures; --=20 2.31.1 From nobody Mon Apr 29 22:44:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1636043273; cv=none; d=zohomail.com; s=zohoarc; b=RucCYuPmmsLEChWDMJtZwN/xmDIoB62z9t5VpgRgcKZ577y41/4peuCZfOZ9KhEuKq7FT4HzqdG08dukm1E22zyAGPmPkGMpZ72EMNvo980RW8tA85wi5lEYSKD5udNWdnGFQlaYMZ4gxiJvlaOdWeiau3BAFL523nPdfEH/0HE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636043273; 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=abXc4QOQnpCpfVFWAObK4fly1cPisNK1c2ON59LMO5I=; b=UESXOhWq8NlO0gWWcWFFL5td0HNAAcgKc6kIgwNsCBB+pwN0ErA8SZfpmv98733tbxyuOZweZWd0FrfywQSWaqt7Jmyb/7+YD8KYUEd+TTuZN3sSyDOVlDveRdlFN6NoX3MqrHSx6kJ99W6RmryUVLM783mS99uJ2Y826Ar0+TM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1636043273692722.3648589217078; Thu, 4 Nov 2021 09:27:53 -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-112-XDwPwWBgMW2nVJD0hDZGLg-1; Thu, 04 Nov 2021 12:27:49 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 467E619057A0; Thu, 4 Nov 2021 16:27:44 +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 235FC5D740; Thu, 4 Nov 2021 16:27:44 +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 E54964EA2A; Thu, 4 Nov 2021 16:27:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A4GRYQU026451 for ; Thu, 4 Nov 2021 12:27:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 307F819C79; Thu, 4 Nov 2021 16:27:34 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 795A019723; Thu, 4 Nov 2021 16:27:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636043272; 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=abXc4QOQnpCpfVFWAObK4fly1cPisNK1c2ON59LMO5I=; b=HFJWtKDGexvn8Yzp7B4w1ISnJH0O9VqORVzQo/SY+gGB3ERP+ddOCWNM+//QNuaovHlJSO I6pDWYkxorVnubJMIfEri6zycQGxKx07k8PNg281ZjgngyEuMq9Hi300csP/6G60KFh8IY n4GZ/JRO70NdcgxT5vTWBJV0y7zprNk= X-MC-Unique: XDwPwWBgMW2nVJD0hDZGLg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 12/20] cpu_x86: Implement virCPUDataNewCopy for x86 Date: Thu, 4 Nov 2021 17:27:12 +0100 Message-Id: <20211104162720.108973-13-twiederh@redhat.com> In-Reply-To: <20211104162720.108973-1-twiederh@redhat.com> References: <20211104162720.108973-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.15 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) X-ZM-MESSAGEID: 1636043276715100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/cpu/cpu_x86.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 5ce193e693..0dc9a7d9fb 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -481,6 +481,23 @@ virCPUx86DataClear(virCPUx86Data *data) G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virCPUx86Data, virCPUx86DataClear); =20 =20 +static virCPUData * +virCPUx86DataCopyNew(virCPUData *data) +{ + virCPUData *copy; + + if (!data) + return NULL; + + copy =3D virCPUDataNew(data->arch); + copy->data.x86.len =3D data->data.x86.len; + copy->data.x86.items =3D g_new0(virCPUx86DataItem, data->data.x86.len); + memcpy(copy->data.x86.items, data->data.x86.items, + data->data.x86.len * sizeof(*data->data.x86.items)); + + return copy; +} + static void virCPUx86DataFree(virCPUData *data) { @@ -3466,6 +3483,7 @@ struct cpuArchDriver cpuDriverX86 =3D { .compare =3D virCPUx86Compare, .decode =3D x86DecodeCPUData, .encode =3D x86Encode, + .dataCopyNew =3D virCPUx86DataCopyNew, .dataFree =3D virCPUx86DataFree, #if defined(__i386__) || defined(__x86_64__) .getHost =3D virCPUx86GetHost, --=20 2.31.1 From nobody Mon Apr 29 22:44:40 2024 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=1636043342; cv=none; d=zohomail.com; s=zohoarc; b=EbtLTQc5HpUnVvMR8edFu0tVtrDpYRpUNBeVUha+R4u3JjkRG/FA8tQTTxqifA9qrp19/Sj97Iv9XA0Gf/gV6yZZAr5X8Vzl0scfac89DuxAsIV4KXYUBilL2YAt9W5UYHKFexhV66VhzFQZrvxd4moi4VZ45Fx805/LMhOD78A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636043342; 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=s3rqkWtaWFk4QqHey9k+NYabhJG8USQ2bbXhn2yWaZo=; b=l24nzndoURXoF366hAw9JskFidt7Gtej3savY9z5OLBnCgLm+fNGe1G+UR8S6N0uQqQksl+E1OPlW35kKKA/0i3IWkblnxreDuNJrrL+oza7ZkQsGukimJSRiMISCQaoD4+RsJ3j88sElZpsj8mZ7UZbbDiJ98moaZXfuHEomfk= 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) 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 1636043342410931.7266482103084; Thu, 4 Nov 2021 09:29:02 -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-75-rIyG7q77PtyEtmpAAI3IGQ-1; Thu, 04 Nov 2021 12:27:57 -0400 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 A4331BD544; Thu, 4 Nov 2021 16:27:46 +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 45C3260CA0; Thu, 4 Nov 2021 16:27:46 +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 0BEF41806D03; Thu, 4 Nov 2021 16:27:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A4GRZQj026461 for ; Thu, 4 Nov 2021 12:27:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3C20819D9F; Thu, 4 Nov 2021 16:27:35 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8648C19C79; Thu, 4 Nov 2021 16:27:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636043341; 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=s3rqkWtaWFk4QqHey9k+NYabhJG8USQ2bbXhn2yWaZo=; b=f7l9X1RYkShY9GUBm0zmGJOGVcPVE1QL7s1Eaj/4aRSnhdkmnGnZG2SpTLasNGFe9Oe0og GWDnnkDOYfdbFUGvJy4dE7MfwQfNxAW4RyJ/bLIycz/woNYuwOrj3iqa4bZASHqNQFcwVH +0Z9eaSukzC1f8Off5NQjv5VkeRPVbg= X-MC-Unique: rIyG7q77PtyEtmpAAI3IGQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 13/20] cpu_arm: Implement virCPUDataNewCopy for arm Date: Thu, 4 Nov 2021 17:27:13 +0100 Message-Id: <20211104162720.108973-14-twiederh@redhat.com> In-Reply-To: <20211104162720.108973-1-twiederh@redhat.com> References: <20211104162720.108973-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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) X-ZM-MESSAGEID: 1636043343477100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/cpu/cpu_arm.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c index c9114d53bf..51a3c1f3ee 100644 --- a/src/cpu/cpu_arm.c +++ b/src/cpu/cpu_arm.c @@ -150,6 +150,25 @@ virCPUarmDataIsIdentical(const virCPUData *a, return VIR_CPU_COMPARE_IDENTICAL; } =20 +static virCPUData * +virCPUarmDataCopyNew(virCPUData *data) +{ + virCPUData *copy; + size_t i; + + if (!data) + return NULL; + + copy =3D virCPUDataNew(data->arch); + copy->data.arm.pvr =3D data->data.arm.pvr; + copy->data.arm.vendor_id =3D data->data.arm.vendor_id; + copy->data.arm.features =3D g_new0(char *, MAX_CPU_FLAGS + 1); + for (i =3D 0; i < MAX_CPU_FLAGS; ++i) + copy->data.arm.features[i] =3D g_strdup(data->data.arm.features[i]= ); + + return copy; +} + static void virCPUarmDataFree(virCPUData *cpuData) { @@ -696,6 +715,7 @@ struct cpuArchDriver cpuDriverArm =3D { #endif .decode =3D NULL, .encode =3D NULL, + .dataCopyNew =3D virCPUarmDataCopyNew, .dataFree =3D virCPUarmDataFree, .baseline =3D virCPUarmBaseline, .update =3D virCPUarmUpdate, --=20 2.31.1 From nobody Mon Apr 29 22:44:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1636043275; cv=none; d=zohomail.com; s=zohoarc; b=f+JxvSl+a2YkUzoLIRpj74/t2B4F8YSw0piPi4FwOto9pZS7WG2bm2x1zbm0Yeospa1mqWAfNahomSGYSvuU++cbXYTaljK7CPoHMqxYtaJ8/xla4YUhLUqHuf+9MOL3q9JzmbEv5ZO+1if8PeeioRtznZrnzzrSocZxHuvx6aY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636043275; 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=c1bhscF9nSqgYzK/n1dhcns8lLBGsCtA1XSg3CmQp0s=; b=TMYHy4Ec3hPUeVm+rmAVioS05nBYTjjJ5TnwLfMry/RsRnNvJXyg8Ry1HZzK98l6NgLDMOmQxP2/PTRwgaz3rlXL2Yw5NpnWrNOVwIeJvMhB4KkmQN/vOOcIHJknjegJ/txdyeiMCJjbDvC2wF0rGxAa9MkOQiO0hNl3JO4lsTs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1636043275177937.5511024049752; Thu, 4 Nov 2021 09:27:55 -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-454-AxF0CVQiPfeT-KZASr3R4w-1; Thu, 04 Nov 2021 12:27:52 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 58E8F8030D2; Thu, 4 Nov 2021 16:27:47 +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 305F519723; Thu, 4 Nov 2021 16:27:47 +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 016D61806D04; Thu, 4 Nov 2021 16:27:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A4GRakT026471 for ; Thu, 4 Nov 2021 12:27:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5362819741; Thu, 4 Nov 2021 16:27:36 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 90FD619C79; Thu, 4 Nov 2021 16:27:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636043274; 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=c1bhscF9nSqgYzK/n1dhcns8lLBGsCtA1XSg3CmQp0s=; b=bnESHqsf+Ou5cjp5nqYqk4xfHSXycLlw1cnmU6B1pSZTW67Mdp0cHzf0LBrRNX2LrnquHL WYnWAbwH0IxWvjDeltbH4dokXKz1xxERaY2xTzKshjNBsqY+sRh2TprOZLrYcBFLBWRkui DRuVyVeS4y146v0/hRzguNmXl2JmDYM= X-MC-Unique: AxF0CVQiPfeT-KZASr3R4w-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 14/20] cpu_ppc64: Implement virCPUDataNewCopy for ppc64 Date: Thu, 4 Nov 2021 17:27:14 +0100 Message-Id: <20211104162720.108973-15-twiederh@redhat.com> In-Reply-To: <20211104162720.108973-1-twiederh@redhat.com> References: <20211104162720.108973-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.84 on 10.5.11.23 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) X-ZM-MESSAGEID: 1636043276934100005 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/cpu/cpu_ppc64.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c index fcd68c8a7c..c7caaa9608 100644 --- a/src/cpu/cpu_ppc64.c +++ b/src/cpu/cpu_ppc64.c @@ -603,6 +603,23 @@ virCPUppc64DataIsIdentical(const virCPUData *a, return VIR_CPU_COMPARE_IDENTICAL; } =20 +static virCPUData * +virCPUppc64DataCopyNew(virCPUData *data) +{ + virCPUData *copy; + size_t i; + + if (!data) + return NULL; + + copy =3D virCPUDataNew(data->arch); + copy->data.ppc64.len =3D data->data.ppc64.len; + for (i =3D 0; i < copy->data.ppc64.len; ++i) + copy->data.ppc64.pvr[i] =3D data->data.ppc64.pvr[i]; + + return copy; +} + static void virCPUppc64DataFree(virCPUData *data) { @@ -768,6 +785,7 @@ struct cpuArchDriver cpuDriverPPC64 =3D { .compare =3D virCPUppc64Compare, .decode =3D ppc64DriverDecode, .encode =3D NULL, + .dataCopyNew =3D virCPUppc64DataCopyNew, .dataFree =3D virCPUppc64DataFree, .getHost =3D virCPUppc64GetHost, .baseline =3D virCPUppc64Baseline, --=20 2.31.1 From nobody Mon Apr 29 22:44:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1636043572; cv=none; d=zohomail.com; s=zohoarc; b=jnG7BCtCrwLu0tGSZuVwFKqS9AWFmkPfnGadF7Tde8uh7Ql3g6q7emB5etFVZczF6nssL/Y8p7xnbyrQK+fdkxOC+YuW69xVtMGOWu31FmjK82USttzxdwUn4mi3RTaz1/uWNDkzlZ3p04XfEwHDZHPCr4XhjHuPe9vyy5vr9CQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636043572; 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=dkQePM/GmueTFq+2rPlOp15wW38Uz7R2PZ5SMoAvWgg=; b=dnF4D+DLbyrJeX52DYG1xKrV7+L0eqNiTS0mnPa/cNrHkJlRW/QVFjKrbHcAdWjLnpCB+9LNaeDvAkH78v/nf0LsAJbZUyAEHSfVY9nmYO2D9kshAyB25h0V/261IsEwLUnCB4hjDeDCVHStj6qG+pnBBphPzIKQo+5YqFpa/D8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1636043572717748.9383584105354; Thu, 4 Nov 2021 09:32:52 -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-257-LPxiWTbRPkG4DJMgS513mw-1; Thu, 04 Nov 2021 12:32:49 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 24DD510168CC; Thu, 4 Nov 2021 16:32:44 +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 00C455D740; Thu, 4 Nov 2021 16:32:43 +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 BD2354EA3C; Thu, 4 Nov 2021 16:32:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A4GRbcw026482 for ; Thu, 4 Nov 2021 12:27:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5A10619730; Thu, 4 Nov 2021 16:27:37 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id A640B19C79; Thu, 4 Nov 2021 16:27:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636043571; 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=dkQePM/GmueTFq+2rPlOp15wW38Uz7R2PZ5SMoAvWgg=; b=JYft/oohSfux5JgmAFyY4bOs3PvGQb/6PnDcW2yf4k3i6T0Aiy4hfUN8/3rwl+MTXCtEMy Q6cMysyp7kSEUL9sgArXDLzuzV1J6MZWIltGzaXWI5pRgswLMS0wIB3/nAvFEUIHMVgugP RQIqlsU3UH/qZ2cT7XMgBMVOdK8b7As= X-MC-Unique: LPxiWTbRPkG4DJMgS513mw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 15/20] virhostcpu: Add virHostCPUGetCPUID Date: Thu, 4 Nov 2021 17:27:15 +0100 Message-Id: <20211104162720.108973-16-twiederh@redhat.com> In-Reply-To: <20211104162720.108973-1-twiederh@redhat.com> References: <20211104162720.108973-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.15 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) X-ZM-MESSAGEID: 1636043573824100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/libvirt_private.syms | 1 + src/util/virhostcpu.c | 43 ++++++++++++++++++++++++++++++++++++++++ src/util/virhostcpu.h | 2 ++ 3 files changed, 46 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 665db255a6..e92670c85d 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2396,6 +2396,7 @@ virHookPresent; # util/virhostcpu.h virHostCPUGetAvailableCPUsBitmap; virHostCPUGetCount; +virHostCPUGetCPUID; virHostCPUGetHaltPollTime; virHostCPUGetInfo; virHostCPUGetKVMMaxVCPUs; diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 5dd2baf2df..3563a662d5 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -1336,6 +1336,41 @@ virHostCPUGetMSR(unsigned long index, } =20 =20 +struct kvm_cpuid2 * +virHostCPUGetCPUID(void) +{ + size_t i; + VIR_AUTOCLOSE fd =3D open(KVM_DEVICE, O_RDONLY); + + if (fd < 0) { + virReportSystemError(errno, _("Unable to open %s"), KVM_DEVICE); + return NULL; + } + + for (i =3D 1; i < INT32_MAX; i *=3D 2) { + g_autofree struct kvm_cpuid2 *kvm_cpuid =3D NULL; + kvm_cpuid =3D g_malloc0(sizeof(struct kvm_cpuid2) + + sizeof(struct kvm_cpuid_entry2) * i); + kvm_cpuid->nent =3D i; + + if (ioctl(fd, KVM_GET_SUPPORTED_CPUID, kvm_cpuid) =3D=3D 0) { + /* filter out local apic id */ + for (i =3D 0; i < kvm_cpuid->nent; ++i) { + struct kvm_cpuid_entry2 *entry =3D &kvm_cpuid->entries[i]; + if (entry->function =3D=3D 0x01 && entry->index =3D=3D 0x0= 0) + entry->ebx &=3D 0x00ffffff; + if (entry->function =3D=3D 0x0b) + entry->edx &=3D 0xffffff00; + } + + return g_steal_pointer(&kvm_cpuid); + } + } + + virReportSystemError(errno, "%s", _("Cannot read host CPUID")); + return NULL; +} + /* * This function should only be called when the host CPU supports invarian= t TSC * (invtsc CPUID feature). @@ -1391,6 +1426,14 @@ virHostCPUGetTscInfo(void) =20 #else =20 +struct kvm_cpuid2 * +virHostCPUGetCPUID(void) +{ + virReportSystemError(ENOSYS, "%s", + _("Reading CPUID is not supported on this platfor= m")); + return NULL; +} + int virHostCPUGetMSR(unsigned long index G_GNUC_UNUSED, uint64_t *msr G_GNUC_UNUSED) diff --git a/src/util/virhostcpu.h b/src/util/virhostcpu.h index d98385d53f..a96dd5afba 100644 --- a/src/util/virhostcpu.h +++ b/src/util/virhostcpu.h @@ -80,6 +80,8 @@ virHostCPUGetMicrocodeVersion(virArch hostArch) G_GNUC_NO= _INLINE; int virHostCPUGetMSR(unsigned long index, uint64_t *msr); =20 +struct kvm_cpuid2 *virHostCPUGetCPUID(void); + virHostCPUTscInfo *virHostCPUGetTscInfo(void); =20 int virHostCPUGetSignature(char **signature); --=20 2.31.1 From nobody Mon Apr 29 22:44:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1636043276; cv=none; d=zohomail.com; s=zohoarc; b=DmC3Zq560rTBl2SvssiSTin8RteSMsDIOBvFs2p+y3axe2f9Ra9D3ewHnYLtkNV9flA0RFF0VONIfpjCy2Pe8wcTEqv7gaxDaHOa5dov12avhpu+mMgZ3bC+uJ6rHOz8mwgMO/7R4uIfHswCb74xs2X93Jwh0FHQ7lyjvwt4p2s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636043276; 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=1A9lfjpxy2rMBuo0/iYQH57M5a88gE/jMBNFc9/TmLQ=; b=MZSubY35CZ04rWJeJZAKknUqR9VzAkSQ1JzN+ZJ8prKg3WWeY87tqrww4CV1TICmbfsv8cN3HyY0flL6BCP1oxJciH5pg7fLz8XML/EIhfXvZBJHrBDy6Mey2odv/YGCgpRZoYdU7ZSZUBEl4iwtGzZZ1u1qR4LSHKHzgqH//Ik= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1636043276492964.6616882852297; Thu, 4 Nov 2021 09:27:56 -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-123-M1s7Ay0oPNO0p4f00yA5RQ-1; Thu, 04 Nov 2021 12:27:54 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DB0EC19200D1; Thu, 4 Nov 2021 16:27:48 +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 B6E8E5F4ED; Thu, 4 Nov 2021 16:27:48 +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 7F3D64EA2A; Thu, 4 Nov 2021 16:27:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A4GRcwq026489 for ; Thu, 4 Nov 2021 12:27:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6354D19723; Thu, 4 Nov 2021 16:27:38 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id AEE9E19C79; Thu, 4 Nov 2021 16:27:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636043275; 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=1A9lfjpxy2rMBuo0/iYQH57M5a88gE/jMBNFc9/TmLQ=; b=EuYCrxq0t/NqmzVbQGzK4Di900EBkXBly6MP6zyyEb+invWm3J6yKs/gKF70npNHNuuF4u 5dYqt+MonCQDF3rB5ImfCy8bMMC+ydoIcJCHKIU+blioNMXsESW3brw6SgPT9U9LmrSZuL /ZepgITxI3uKXPZMHFZ/65az2L2cefo= X-MC-Unique: M1s7Ay0oPNO0p4f00yA5RQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 16/20] cpu_x86: Add virCPUDataGetHost Date: Thu, 4 Nov 2021 17:27:16 +0100 Message-Id: <20211104162720.108973-17-twiederh@redhat.com> In-Reply-To: <20211104162720.108973-1-twiederh@redhat.com> References: <20211104162720.108973-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.15 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) X-ZM-MESSAGEID: 1636043277781100007 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/cpu/cpu.c | 19 +++++++++++++++++++ src/cpu/cpu.h | 7 +++++++ src/libvirt_private.syms | 1 + 3 files changed, 27 insertions(+) diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index b5669246b4..285c7eee44 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -1190,6 +1190,25 @@ virCPUDataIsIdentical(const virCPUData *a, } =20 =20 +/** + * virCPUDataGetHost: + * + */ +virCPUData* +virCPUDataGetHost(void) +{ + struct cpuArchDriver *driver; + + if (!(driver =3D cpuGetSubDriver(virArchFromHost()))) + return NULL; + + if (!driver->dataGetHost) + return NULL; + + return driver->dataGetHost(); +} + + /** * virCPUArchIsSupported: * diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index d3e5ca79f2..071b33fe76 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -130,6 +130,9 @@ typedef virCPUCompareResult (*virCPUArchDataIsIdentical)(const virCPUData *a, const virCPUData *b); =20 +typedef virCPUData * +(*virCPUArchDataGetHost)(void); + struct cpuArchDriver { const char *name; const virArch *arch; @@ -155,6 +158,7 @@ struct cpuArchDriver { virCPUArchValidateFeatures validateFeatures; virCPUArchDataAddFeature dataAddFeature; virCPUArchDataIsIdentical dataIsIdentical; + virCPUArchDataGetHost dataGetHost; }; =20 =20 @@ -291,6 +295,9 @@ virCPUCompareResult virCPUDataIsIdentical(const virCPUData *a, const virCPUData *b); =20 +virCPUData* +virCPUDataGetHost(void); + bool virCPUArchIsSupported(virArch arch); =20 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index e92670c85d..d4e2d3db74 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1460,6 +1460,7 @@ virCPUDataAddFeature; virCPUDataCheckFeature; virCPUDataFormat; virCPUDataFree; +virCPUDataGetHost; virCPUDataIsIdentical; virCPUDataNew; virCPUDataNewCopy; --=20 2.31.1 From nobody Mon Apr 29 22:44:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1636043280; cv=none; d=zohomail.com; s=zohoarc; b=bH+iZ630SoKWTDe276YdjUbIqDe6GBMW1j1fgxqbdJngHLq4NjxnE7/Oyct8u0rZEWWeAXdy3K7KV/NMXhbm8fDU6hgE0Y3/JQMBpaJBadepuKTpG12jx59r2Z4ysVJnr5zXSqykGCkg2/mUHC1RPmSfMDoPbG6nJtapi17JRqs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636043280; 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=snnmz0EuWm3zGOC1qffcXuc2Ba1BVeg4svDdVd4HXOs=; b=i8FHppAvAwkRCTfVT1h7RdE+ig6xGW7BZWwUoeUEM8gNHYgKMlxmRE0GxzMovaYQleBxeUFDJRQTyUyly4Y8PGqNgziCMTA5KvS+hCsp2GnbVF7GZpVuihcS+E35s4MgYNA7IuD4ga+xqGuiG8B5t6GWw0E1zj2nUy0JpEwFXu0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1636043280696486.2769190753711; Thu, 4 Nov 2021 09:28:00 -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-273-BOGxo_vLMZC9RxOM7yfqaw-1; Thu, 04 Nov 2021 12:27:56 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 214161006AA6; Thu, 4 Nov 2021 16:27:50 +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 0249A60854; Thu, 4 Nov 2021 16:27:50 +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 BB8EA4EA2F; Thu, 4 Nov 2021 16:27:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A4GRd9r026504 for ; Thu, 4 Nov 2021 12:27:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6ED5A19C79; Thu, 4 Nov 2021 16:27:39 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id B926619D9F; Thu, 4 Nov 2021 16:27:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636043279; 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=snnmz0EuWm3zGOC1qffcXuc2Ba1BVeg4svDdVd4HXOs=; b=e7eGU83Kx4GA47DO4xO4tf8XAXuRoaSEPzHBvQ11M6chFmFuI3xyiHzIBwBMEsPYNlFvvs QsTzbIeBrsckMyjHJhcI+8EyzBR34Ah+2hYm/CO2QVx/pkBWnVN7dne280ESlaQ+nod9Nd pdZNeNgdWV2dMA19FALGoVp33CK2RtI= X-MC-Unique: BOGxo_vLMZC9RxOM7yfqaw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 17/20] cpu_x86: Implement virCPUDataGetHost for x86 Date: Thu, 4 Nov 2021 17:27:17 +0100 Message-Id: <20211104162720.108973-18-twiederh@redhat.com> In-Reply-To: <20211104162720.108973-1-twiederh@redhat.com> References: <20211104162720.108973-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.13 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) X-ZM-MESSAGEID: 1636043282306100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/cpu/cpu_x86.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 0dc9a7d9fb..a72eae07dd 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -20,6 +20,9 @@ =20 #include =20 +#if WITH_LINUX_KVM_H +# include +#endif =20 #include "virlog.h" #include "viralloc.h" @@ -3417,6 +3420,38 @@ virCPUx86DataIsIdentical(const virCPUData *a, return VIR_CPU_COMPARE_IDENTICAL; } =20 +#if WITH_LINUX_KVM_H && defined(KVM_GET_MSRS) && \ + (defined(__i386__) || defined(__x86_64__)) && \ + (defined(__linux__) || defined(__FreeBSD__)) +static virCPUData * +virCPUx86DataGetHost(void) +{ + size_t i; + virCPUData *cpuid; + g_autofree struct kvm_cpuid2 *kvm_cpuid =3D NULL; + + if ((kvm_cpuid =3D virHostCPUGetCPUID()) =3D=3D NULL) + return NULL; + + cpuid =3D virCPUDataNew(virArchFromHost()); + cpuid->data.x86.len =3D kvm_cpuid->nent; + cpuid->data.x86.items =3D g_new0(virCPUx86DataItem, kvm_cpuid->nent); + + for (i =3D 0; i < kvm_cpuid->nent; ++i) { + virCPUx86DataItem *item =3D &cpuid->data.x86.items[i]; + item->type =3D VIR_CPU_X86_DATA_CPUID; + item->data.cpuid.eax_in =3D kvm_cpuid->entries[i].function; + item->data.cpuid.ecx_in =3D kvm_cpuid->entries[i].index; + item->data.cpuid.eax =3D kvm_cpuid->entries[i].eax; + item->data.cpuid.ebx =3D kvm_cpuid->entries[i].ebx; + item->data.cpuid.ecx =3D kvm_cpuid->entries[i].ecx; + item->data.cpuid.edx =3D kvm_cpuid->entries[i].edx; + } + + return cpuid; +} +#endif + static bool virCPUx86FeatureIsMSR(const char *name) { @@ -3502,4 +3537,9 @@ struct cpuArchDriver cpuDriverX86 =3D { .validateFeatures =3D virCPUx86ValidateFeatures, .dataAddFeature =3D virCPUx86DataAddFeature, .dataIsIdentical =3D virCPUx86DataIsIdentical, +#if WITH_LINUX_KVM_H && defined(KVM_GET_MSRS) && \ + (defined(__i386__) || defined(__x86_64__)) && \ + (defined(__linux__) || defined(__FreeBSD__)) + .dataGetHost =3D virCPUx86DataGetHost, +#endif }; --=20 2.31.1 From nobody Mon Apr 29 22:44:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1636043285; cv=none; d=zohomail.com; s=zohoarc; b=cUGy15tqrqfWskmF7WexObvd90DUaIG2dg72Tm4SFGmiQ6f1McLUvRIcL4ODR6FuG5NJsh+dv7usoUR+A6l3SyYIVP8zyDmJTx93GjZp+D0Yt+4Mv4pDeaSYrOg7zDb7eZjCdyf+Vb+FLffoT9JCFNdF4AGvjDg724XS5biBeYk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636043285; 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=VhkB9Qq52k+fxGhvHIUc0AkIDLvU1vFbs4Dyv68BI78=; b=kQQ5ft95FVc2a1oR5hhX1aDIECs9xtwoONk78gqlCuqGupEvU+1uP2Hz6Wyb2vRLJn0GwkemiHp+CFjQrpxnadcnYVdrBRhJmCbt1/m84po8peoeg08P3iZFOd2HvgceTYqznqMNUB/ZPeO0aY5uSdEAa21t1shE7MfImKKTgdI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1636043285303295.91170010271594; Thu, 4 Nov 2021 09:28:05 -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-29-bwRnCAcfPYuy8Cxlx8-OPA-1; Thu, 04 Nov 2021 12:28:01 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7A079CF9B1; Thu, 4 Nov 2021 16:27:53 +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 5F21360854; Thu, 4 Nov 2021 16:27:53 +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 362501806D03; Thu, 4 Nov 2021 16:27:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A4GReil026515 for ; Thu, 4 Nov 2021 12:27:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7E27319723; Thu, 4 Nov 2021 16:27:40 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id C488F19C79; Thu, 4 Nov 2021 16:27:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636043284; 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=VhkB9Qq52k+fxGhvHIUc0AkIDLvU1vFbs4Dyv68BI78=; b=b3AtxtbwIqmYNs0bNvmEv/NsMKtBU22CzXFqfKBs3WpsQ9AkZ9YgSTda+A0CurjWEOUmWN 9W+eMmK9nqq74VGu29JaHkxJZSlP6Z7ooRosmLA4GTcztKM/BshJQrMLbWNK0ObM6hljh/ E/mIJHZQ6CBXrlyLc9U51d1Xzdlbn60= X-MC-Unique: bwRnCAcfPYuy8Cxlx8-OPA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 18/20] virQEMUCaps: Add host cpuid information Date: Thu, 4 Nov 2021 17:27:18 +0100 Message-Id: <20211104162720.108973-19-twiederh@redhat.com> In-Reply-To: <20211104162720.108973-1-twiederh@redhat.com> References: <20211104162720.108973-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.13 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) X-ZM-MESSAGEID: 1636043286807100001 Content-Type: text/plain; charset="utf-8" Many things can affect the availability of cpu flags (e.g. software upgrades, kernel versions, kernel command line, etc.) and invalidate the cached capabilities without notice. Add CPUID information to the capabilities cache. Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/qemu/qemu_capabilities.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index e4fdd9a1eb..b2d5242264 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -725,6 +725,7 @@ struct _virQEMUCaps { char *kernelVersion; =20 virArch arch; + virCPUData *cpuData; =20 size_t ngicCapabilities; virGICCapability *gicCapabilities; @@ -1965,6 +1966,7 @@ virQEMUCaps *virQEMUCapsNewCopy(virQEMUCaps *qemuCaps) ret->kernelVersion =3D g_strdup(qemuCaps->kernelVersion); =20 ret->arch =3D qemuCaps->arch; + ret->cpuData =3D virCPUDataNewCopy(qemuCaps->cpuData); =20 if (virQEMUCapsAccelCopy(&ret->kvm, &qemuCaps->kvm) < 0 || virQEMUCapsAccelCopy(&ret->tcg, &qemuCaps->tcg) < 0) @@ -2015,6 +2017,8 @@ void virQEMUCapsDispose(void *obj) =20 g_free(qemuCaps->gicCapabilities); =20 + virCPUDataFree(qemuCaps->cpuData); + virSEVCapabilitiesFree(qemuCaps->sevCapabilities); =20 virQEMUCapsAccelClear(&qemuCaps->kvm); @@ -4260,6 +4264,12 @@ virQEMUCapsLoadCache(virArch hostArch, } VIR_FREE(str); =20 + if (virXPathBoolean("boolean(./cpudata)", ctxt) > 0) { + qemuCaps->cpuData =3D virCPUDataParseNode(virXPathNode("./cpudata"= , ctxt)); + if (!qemuCaps->cpuData) + goto cleanup; + } + if (virQEMUCapsLoadAccel(qemuCaps, ctxt, VIR_DOMAIN_VIRT_KVM) < 0 || virQEMUCapsLoadAccel(qemuCaps, ctxt, VIR_DOMAIN_VIRT_QEMU) < 0) goto cleanup; @@ -4561,6 +4571,11 @@ virQEMUCapsFormatCache(virQEMUCaps *qemuCaps) virBufferAsprintf(&buf, "%s\n", qemuCaps->kernelVersion); =20 + if (qemuCaps->cpuData) { + g_autofree char * cpudata =3D virCPUDataFormat(qemuCaps->cpuData); + virBufferAsprintf(&buf, "%s", cpudata); + } + virBufferAsprintf(&buf, "%s\n", virArchToString(qemuCaps->arch)); =20 @@ -5418,6 +5433,7 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch, if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) { qemuCaps->hostCPUSignature =3D g_strdup(hostCPUSignature); qemuCaps->microcodeVersion =3D microcodeVersion; + qemuCaps->cpuData =3D NULL; =20 qemuCaps->kernelVersion =3D g_strdup(kernelVersion); =20 --=20 2.31.1 From nobody Mon Apr 29 22:44:40 2024 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=1636043281; cv=none; d=zohomail.com; s=zohoarc; b=PpXBs8fSFfAn2BDGenvcRh8a2JOeAttcsAAtEiTpMzRxUcO1Qq8K17AOh76nGUwbJEAgg14T4BqP1jXcb8GPGQHctHcyQXPTOjVLQs3h9Q2z2KWfEp8FmlCePemEgPgsLK9fswjkXBHLBeyhdE4Zi0VzGfZgyUXnSPcIFSUgoSA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636043281; 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=WshEK8frE8BnXimlLNkXBLE/V1+cIOXW0S8amwkddRA=; b=ZObonJJHPKzw9N5q0ACB4Cat1HjLEXYvsbPYu5d39L7leTim31GRbplIYiU37fvj7x7FK/5duCu/HmKVfhM1HJJ3+QBH2W9ECbkmtnC/EUoA4i2uE+PuYD+I6w9oSCjnbvpEyezp8MhJ3TTRjEtQEPB48cWjXiz8lN5JV/XawVk= 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) 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 1636043281203751.1767336714202; Thu, 4 Nov 2021 09:28:01 -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-547-1161QcKBPF2cyLSBjanjFQ-1; Thu, 04 Nov 2021 12:27:58 -0400 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 6340E8B426D; Thu, 4 Nov 2021 16:27:53 +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 1882119EF9; Thu, 4 Nov 2021 16:27:53 +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 D1BEA4EA37; Thu, 4 Nov 2021 16:27:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A4GRfcp026521 for ; Thu, 4 Nov 2021 12:27:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8A87B19730; Thu, 4 Nov 2021 16:27:41 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id D4E0219723; Thu, 4 Nov 2021 16:27:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636043280; 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=WshEK8frE8BnXimlLNkXBLE/V1+cIOXW0S8amwkddRA=; b=cFs7yUhZ1DGmQR0eH4Vl35Hw4bOsDgQe9wfFD9QsBMMbI28WR+djIYylHdnSYrZlVjx9w3 QHbcYTPFgJLAjgz5oa/RXS/X15TuMMae2eod70fpOUkZuHVng6qD521iwz0yde3GSnsjKY 0tPuUj8lATXbgXeYcmIaZwqG427LGTA= X-MC-Unique: 1161QcKBPF2cyLSBjanjFQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 19/20] virQEMUCapsCachePriv: Add host cpuid information Date: Thu, 4 Nov 2021 17:27:19 +0100 Message-Id: <20211104162720.108973-20-twiederh@redhat.com> In-Reply-To: <20211104162720.108973-1-twiederh@redhat.com> References: <20211104162720.108973-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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) X-ZM-MESSAGEID: 1636043282393100002 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/qemu/qemu_capabilities.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index b2d5242264..5fa3111201 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4023,6 +4023,7 @@ struct _virQEMUCapsCachePriv { gid_t runGid; virArch hostArch; unsigned int microcodeVersion; + virCPUData *cpuData; char *kernelVersion; char *hostCPUSignature; =20 @@ -4040,6 +4041,7 @@ virQEMUCapsCachePrivFree(void *privData) =20 g_free(priv->libDir); g_free(priv->kernelVersion); + virCPUDataFree(priv->cpuData); g_free(priv->hostCPUSignature); g_free(priv); } @@ -5568,6 +5570,8 @@ virQEMUCapsCacheNew(const char *libDir, if (uname(&uts) =3D=3D 0) priv->kernelVersion =3D g_strdup_printf("%s %s", uts.release, uts.= version); =20 + priv->cpuData =3D virCPUDataGetHost(); + cleanup: return cache; =20 --=20 2.31.1 From nobody Mon Apr 29 22:44:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1636043287; cv=none; d=zohomail.com; s=zohoarc; b=ZBJ97BGboS972QnTVccuOZoq4CQSUVZV4q4jemc8fBBcRpUhZdJfJJQHqqFNEodDA8dzIc2YVVelKrr/UaZI8riZO0cbiQ1BuNa3k6vuEBhHdVSLht1GAVyfR8Xxpm3wXyKBWMIkIa/gaExPAcxu/xgByTpODOF96/1Yd5JYq3E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636043287; 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=xBEQ8lqFDKtvSxQibwL1P2SGlKD2mq11xyYiOUR//8c=; b=hpuFlkDLWRupvPzb9XaCEQKE/aC9mNBF2NhnqzzWg2QjIKQsYboIvHgfAdmGyDBG44rC8DNiSkzbRr/0ORxPrCedNJpIYiq8WZvXiNBUTKMCPexzzpe+BDFqLjW+6HY9Dbkz6IVuMLO0M6kqPCrX/R7WVLM2IDSb4NCKxynal1k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1636043287133553.4240316324918; Thu, 4 Nov 2021 09:28:07 -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-602-_yXfLHTFOs6gsL14yH9FjQ-1; Thu, 04 Nov 2021 12:28:02 -0400 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 3A6C810168F0; Thu, 4 Nov 2021 16:27:56 +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 11B1160C13; Thu, 4 Nov 2021 16:27:56 +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 CE29F181A1D1; Thu, 4 Nov 2021 16:27:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A4GRgvh026537 for ; Thu, 4 Nov 2021 12:27:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9354C19D9F; Thu, 4 Nov 2021 16:27:42 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE8CC19C79; Thu, 4 Nov 2021 16:27:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636043286; 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=xBEQ8lqFDKtvSxQibwL1P2SGlKD2mq11xyYiOUR//8c=; b=c09vGTOMQGfnypVX0n+otN937BG9YLym4NSABBzeK4qPXZzIwkQ/BSrodenPKMkqgX1fve 8HVwWKV0jOJzcSO7Fn/pvibGUcVuTAjeH8WhhalryH2p0WzaFiJWewdGEGz3oTsuccy0M/ V8jyGL/XmQytf0cB27fxNFiiBr2GQ2w= X-MC-Unique: _yXfLHTFOs6gsL14yH9FjQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 20/20] qemu: Invalidate capabilities cache on host cpuid mismatch Date: Thu, 4 Nov 2021 17:27:20 +0100 Message-Id: <20211104162720.108973-21-twiederh@redhat.com> In-Reply-To: <20211104162720.108973-1-twiederh@redhat.com> References: <20211104162720.108973-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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) X-ZM-MESSAGEID: 1636043289059100001 Content-Type: text/plain; charset="utf-8" See https://bugzilla.redhat.com/show_bug.cgi?id=3D1953389. Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/qemu/qemu_capabilities.c | 15 ++++++++++++--- src/qemu/qemu_capspriv.h | 3 ++- tests/qemucapsprobe.c | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 5fa3111201..67fae46a34 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4907,6 +4907,13 @@ virQEMUCapsIsValid(void *data, return false; } =20 + if (virCPUDataIsIdentical(priv->cpuData, qemuCaps->cpuData) !=3D + VIR_CPU_COMPARE_IDENTICAL) { + VIR_DEBUG("Outdated capabilities for '%s': host cpuid changed", + qemuCaps->binary); + return false; + } + kvmSupportsNesting =3D virQEMUCapsKVMSupportsNesting(); if (kvmSupportsNesting !=3D qemuCaps->kvmSupportsNesting) { VIR_DEBUG("Outdated capabilities for '%s': kvm kernel nested " @@ -5387,7 +5394,8 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch, gid_t runGid, const char *hostCPUSignature, unsigned int microcodeVersion, - const char *kernelVersion) + const char *kernelVersion, + virCPUData* cpuData) { g_autoptr(virQEMUCaps) qemuCaps =3D NULL; struct stat sb; @@ -5435,7 +5443,7 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch, if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) { qemuCaps->hostCPUSignature =3D g_strdup(hostCPUSignature); qemuCaps->microcodeVersion =3D microcodeVersion; - qemuCaps->cpuData =3D NULL; + qemuCaps->cpuData =3D virCPUDataNewCopy(cpuData); =20 qemuCaps->kernelVersion =3D g_strdup(kernelVersion); =20 @@ -5460,7 +5468,8 @@ virQEMUCapsNewData(const char *binary, priv->runGid, priv->hostCPUSignature, virHostCPUGetMicrocodeVersion(p= riv->hostArch), - priv->kernelVersion); + priv->kernelVersion, + priv->cpuData); } =20 =20 diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h index a54a22685e..f4f4a99d32 100644 --- a/src/qemu/qemu_capspriv.h +++ b/src/qemu/qemu_capspriv.h @@ -35,7 +35,8 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch, gid_t runGid, const char *hostCPUSignature, unsigned int microcodeVersion, - const char *kernelVersion); + const char *kernelVersion, + virCPUData* cpuData); =20 int virQEMUCapsLoadCache(virArch hostArch, virQEMUCaps *qemuCaps, diff --git a/tests/qemucapsprobe.c b/tests/qemucapsprobe.c index bfa8ae8db7..76c18f0dcd 100644 --- a/tests/qemucapsprobe.c +++ b/tests/qemucapsprobe.c @@ -79,7 +79,7 @@ main(int argc, char **argv) return EXIT_FAILURE; =20 if (!(caps =3D virQEMUCapsNewForBinaryInternal(VIR_ARCH_NONE, argv[1],= "/tmp", - -1, -1, NULL, 0, NULL))) + -1, -1, NULL, 0, NULL, NU= LL))) return EXIT_FAILURE; =20 host =3D virArchFromHost(); --=20 2.31.1