From nobody Wed Dec 17 09:18:12 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1559304161; cv=none; d=zoho.com; s=zohoarc; b=D8hwWyusTGorLcqFas7WOIUN7K5hszw4VJoSz5nhuXNZ7tku1zhpTXctzH5KgO6RnFNt/EXdqDHoTKGpbLoSmVjO78t1BJbL3Fzhdvju2SPnDBoAxcawrGQp0s7YbTgMCXH33vT9WN0Nsap9y5wBDtg+z2sgTnJYuCYXuaZKN2o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559304161; 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:ARC-Authentication-Results; bh=h1r4CgYp+mRauN9ek+eXMOy26vXvIj6qWZGOxOWf1sY=; b=nZ2nY1ULmbyNUJ7lTP60oSQ9RQQ7uLPPqrcdt9mk4l8SGB0Oc9d9rvlfjny7JPySToQXQS5F2xot7pWN2T1/j7Xd8qw+gatXuifXYTeGCP9IizculZNctGBfFxBquxxJ12w11gXCeTaIWBF4+annid/wrTinh8u7nRQDeLaEPpo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1559304161635920.4977385444278; Fri, 31 May 2019 05:02:41 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 4C56330BC57B; Fri, 31 May 2019 12:02:39 +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 2391C7E8E0; Fri, 31 May 2019 12:02:36 +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 D1E53E179; Fri, 31 May 2019 12:02:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4VC0r4Q010265 for ; Fri, 31 May 2019 08:00:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 96EF56FC35; Fri, 31 May 2019 12:00:53 +0000 (UTC) Received: from orkuz.int.mamuti.net (ovpn-204-108.brq.redhat.com [10.40.204.108]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2243078379; Fri, 31 May 2019 12:00:22 +0000 (UTC) Received: by orkuz.int.mamuti.net (Postfix, from userid 500) id C2EB12A10F7; Fri, 31 May 2019 14:00:20 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Fri, 31 May 2019 14:00:08 +0200 Message-Id: <1389e4e9bd78c7b3a5835859beb6d641b9f04a14.1559303790.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Marcelo Tosatti Subject: [libvirt] [PATCH 2/5] conf: Report TSC frequency in host CPU capabilities X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 31 May 2019 12:02:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This patch adds a new element into the host CPU capabilities XML. Signed-off-by: Jiri Denemark --- src/conf/cpu_conf.c | 48 +++++++++++++++++++++++++++++++++++++++++++++ src/conf/cpu_conf.h | 2 ++ 2 files changed, 50 insertions(+) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index bd2beab33e..dc46e7f57a 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -112,6 +112,7 @@ virCPUDefFree(virCPUDefPtr def) =20 virCPUDefFreeModel(def); VIR_FREE(def->cache); + VIR_FREE(def->tsc); VIR_FREE(def); } =20 @@ -233,6 +234,13 @@ virCPUDefCopyWithoutModel(const virCPUDef *cpu) *copy->cache =3D *cpu->cache; } =20 + if (cpu->tsc) { + if (VIR_ALLOC(copy->tsc) < 0) + goto error; + + *copy->tsc =3D *cpu->tsc; + } + return copy; =20 error: @@ -286,6 +294,8 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, char *cpuMode; char *fallback =3D NULL; char *vendor_id =3D NULL; + char *tscScaling =3D NULL; + virHostCPUTscInfoPtr tsc =3D NULL; int ret =3D -1; =20 *cpu =3D NULL; @@ -402,6 +412,32 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, _("invalid microcode version")); goto cleanup; } + + if (virXPathBoolean("boolean(./counter[@name=3D'tsc'])", ctxt) > 0= ) { + if (VIR_ALLOC(tsc) < 0) + goto cleanup; + + if (virXPathULongLong("./counter[@name=3D'tsc']/@frequency", c= txt, + &tsc->frequency) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Invalid TSC frequency")); + goto cleanup; + } + + tscScaling =3D virXPathString("string(./counter[@name=3D'tsc']= /@scaling)", + ctxt); + if (tscScaling) { + int scaling =3D virTristateBoolTypeFromString(tscScaling); + if (scaling < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Invalid TSC scaling attribute")); + goto cleanup; + } + tsc->scaling =3D scaling; + } + + VIR_STEAL_PTR(def->tsc, tsc); + } } =20 if (!(def->model =3D virXPathString("string(./model[1])", ctxt)) && @@ -587,6 +623,8 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, VIR_FREE(fallback); VIR_FREE(vendor_id); VIR_FREE(nodes); + VIR_FREE(tscScaling); + VIR_FREE(tsc); virCPUDefFree(def); return ret; } @@ -744,6 +782,16 @@ virCPUDefFormatBuf(virBufferPtr buf, virBufferAsprintf(buf, "\n", def->microcodeVersion); =20 + if (def->type =3D=3D VIR_CPU_TYPE_HOST && def->tsc) { + virBufferAddLit(buf, "tsc->frequency); + if (def->tsc->scaling) { + virBufferAsprintf(buf, " scaling=3D'%s'", + virTristateBoolTypeToString(def->tsc->scalin= g)); + } + virBufferAddLit(buf, "/>\n"); + } + if (def->sockets && def->cores && def->threads) { virBufferAddLit(buf, "sockets); diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h index c98db65693..51bf744fab 100644 --- a/src/conf/cpu_conf.h +++ b/src/conf/cpu_conf.h @@ -28,6 +28,7 @@ # include "virarch.h" # include "numa_conf.h" # include "virenum.h" +# include "virhostcpu.h" =20 # define VIR_CPU_VENDOR_ID_LENGTH 12 =20 @@ -139,6 +140,7 @@ struct _virCPUDef { size_t nfeatures_max; virCPUFeatureDefPtr features; virCPUCacheDefPtr cache; + virHostCPUTscInfoPtr tsc; }; =20 =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list