From nobody Sun May 5 00:59:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1573641236; cv=none; d=zoho.com; s=zohoarc; b=MRf9sZehtCYCV9k9IX0z7fpPTdbfIx7i7rsgnxjwawhEmTQct5TeiZi8r0wctkgn1TKwH1r/DH8vK4gVW3g4mBdPONaCLHatevoRWF8dmeVIjukIf6RWvX8dAkPKDMjuKIcoCHvqdY5cDdEFE3hPW0upq3ivkOchySXyYSSKRuw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573641236; 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=YNcpKF4thREkRyA9YnoxFoAhdRnYifQbz1/kExLoMbg=; b=Bxf2dtoLcI5Y3rlIVU+s2tgH1tZBHoiHNeWyD4I31v2Q/0FG5DX2qnuOxnv/jg3O8KabJmQjxU5zqAUfbDJIoraAxz+va360WaC955rgnG6hoVDw4cSUduqfftY+4IkMR6/tm17apbe7B639Mh7QdA3str0wZeeq35v6o7BIXtU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1573641236444217.74746288071935; Wed, 13 Nov 2019 02:33:56 -0800 (PST) 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-173-tpmdsfcaMsCbH50zbrMo4w-1; Wed, 13 Nov 2019 05:33:53 -0500 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 DC6A98048E4; Wed, 13 Nov 2019 10:33:47 +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 AF5216117E; Wed, 13 Nov 2019 10:33: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 69F474E566; Wed, 13 Nov 2019 10:33:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xAD961aU025501 for ; Wed, 13 Nov 2019 04:06:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id 394EB10D14E6; Wed, 13 Nov 2019 09:06:01 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3309B10D14E4 for ; Wed, 13 Nov 2019 09:05:59 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 109601065053 for ; Wed, 13 Nov 2019 09:05:59 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-362-o4dehcjtOiyiqLKnVP_O0Q-2; Wed, 13 Nov 2019 04:05:57 -0500 Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Nov 2019 01:05:55 -0800 Received: from david-unc.bj.intel.com ([10.238.157.59]) by orsmga006.jf.intel.com with ESMTP; 13 Nov 2019 01:05:55 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573641235; 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=YNcpKF4thREkRyA9YnoxFoAhdRnYifQbz1/kExLoMbg=; b=MjExYge8MMG4Bx3pCBf+7sbbey2dirctjWw6Fa6MJ21Z3kZmzLhxyWXftRk9juLTSU83qL ot4topZ640IKuU4n6NGElNtv5EOuOI1T1ZcFJK/qGnf7UHfeGHAAY2BAQdVE9YTipYBkBn TYd2z8DGyfTUaFAWArbyyYuMldmKDFU= X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,299,1569308400"; d="scan'208";a="207740836" From: Wang Huaqiang To: libvir-list@redhat.com Date: Thu, 14 Nov 2019 01:08:19 +0800 Message-Id: <20191113170823.17776-2-huaqiang.wang@intel.com> In-Reply-To: <20191113170823.17776-1-huaqiang.wang@intel.com> References: <20191113170823.17776-1-huaqiang.wang@intel.com> MIME-Version: 1.0 X-MC-Unique: o4dehcjtOiyiqLKnVP_O0Q-2 X-MC-Unique: tpmdsfcaMsCbH50zbrMo4w-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id xAD961aU025501 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Wed, 13 Nov 2019 05:33:31 -0500 Cc: Huaqiang Subject: [libvirt] [PATCH 1/5] util, resctrl: using 64bit interface instead of 32bit for counters 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 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Huaqiang The underlying resctrl monitoring is actually using 64 bit counters, not the 32bit one. Correct this by using 64bit interfaces. Signed-off-by: Huaqiang --- src/qemu/qemu_driver.c | 4 ++-- src/util/virfile.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/util/virfile.h | 2 ++ src/util/virresctrl.c | 6 +++--- src/util/virresctrl.h | 2 +- 5 files changed, 48 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f4ff2ba292..e396358871 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20587,8 +20587,8 @@ qemuDomainGetStatsCpuCache(virQEMUDriverPtr driver, "cpu.cache.monitor.%zu.bank.%zu.i= d", i, j) < 0) goto cleanup; =20 - if (virTypedParamListAddUInt(params, resdata[i]->stats[j]->val= s[0], - "cpu.cache.monitor.%zu.bank.%zu.b= ytes", i, j) < 0) + if (virTypedParamListAddULLong(params, resdata[i]->stats[j]->v= als[0], + "cpu.cache.monitor.%zu.bank.%zu= .bytes", i, j) < 0) goto cleanup; } } diff --git a/src/util/virfile.c b/src/util/virfile.c index ced0ea70b7..372498e69e 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -4204,6 +4204,46 @@ virFileReadValueUint(unsigned int *value, const char= *format, ...) } =20 =20 +/** + * virFileReadValueUllong: + * @value: pointer to unsigned long long to be filled in with the value + * @format, ...: file to read from + * + * Read unsigned int from @format and put it into @value. + * + * Return -2 for non-existing file, -1 on other errors and 0 if everything= went + * fine. + */ +int +virFileReadValueUllong(unsigned long long *value, const char *format, ...) +{ + g_autofree char *str =3D NULL; + g_autofree char *path =3D NULL; + va_list ap; + + va_start(ap, format); + path =3D g_strdup_vprintf(format, ap); + va_end(ap); + + if (!virFileExists(path)) + return -2; + + if (virFileReadAll(path, INT_BUFSIZE_BOUND(*value), &str) < 0) + return -1; + + virStringTrimOptionalNewline(str); + + if (virStrToLong_ullp(str, NULL, 10, value) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid unsigned long long value '%s' in file '%= s'"), + str, path); + return -1; + } + + return 0; +} + + /** * virFileReadValueScaledInt: * @value: pointer to unsigned long long int to be filled in with the value diff --git a/src/util/virfile.h b/src/util/virfile.h index a570529330..f77d8501c3 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -363,6 +363,8 @@ int virFileReadValueInt(int *value, const char *format,= ...) G_GNUC_PRINTF(2, 3); int virFileReadValueUint(unsigned int *value, const char *format, ...) G_GNUC_PRINTF(2, 3); +int virFileReadValueUllong(unsigned long long *value, const char *format, = ...) + G_GNUC_PRINTF(2, 3); int virFileReadValueBitmap(virBitmapPtr *value, const char *format, ...) G_GNUC_PRINTF(2, 3); int virFileReadValueScaledInt(unsigned long long *value, const char *forma= t, ...) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index b78fded026..684d2ce398 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -2678,7 +2678,7 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monito= r, int rv =3D -1; int ret =3D -1; size_t i =3D 0; - unsigned int val =3D 0; + unsigned long long val =3D 0; DIR *dirp =3D NULL; char *datapath =3D NULL; char *filepath =3D NULL; @@ -2734,8 +2734,8 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monito= r, goto cleanup; =20 for (i =3D 0; resources[i]; i++) { - rv =3D virFileReadValueUint(&val, "%s/%s/%s", datapath, - ent->d_name, resources[i]); + rv =3D virFileReadValueUllong(&val, "%s/%s/%s", datapath, + ent->d_name, resources[i]); if (rv =3D=3D -2) { virReportError(VIR_ERR_INTERNAL_ERROR, _("File '%s/%s/%s' does not exist."), diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h index 3dd7c96348..11f275acf4 100644 --- a/src/util/virresctrl.h +++ b/src/util/virresctrl.h @@ -204,7 +204,7 @@ struct _virResctrlMonitorStats { char **features; /* @vals store the statistical record values and @val[0] is the value = for * @features[0], @val[1] for@features[1] ... respectively */ - unsigned int *vals; + unsigned long long *vals; /* The length of @vals array */ size_t nvals; }; --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 00:59:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1573641239; cv=none; d=zoho.com; s=zohoarc; b=gAO3iseUyYPmmQodQermxrmXe5rTFnSp/qKLfRsPcLIWUpGWUngKGpvwtOXoqslg/jT+xOc9Ceqkf2OilPGh2ApycCe2Mkf0Uu0B6dhcvYNHix4URZwAQWLbum50MbxooMIZAbskFIFapOgHa7C8lTCct+u0NdDouJH3rZQUaZY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573641239; 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=CgWvvOt9Q+bdxmnYy4kQfy0ubzuepbpWCuuJKND6y2M=; b=dcdRkdT228QJOgGSOpjMNDcQ+g2xaiy6aUSnqKLjp2E6AgoC/SItTpIQbzhIpokidqc4STThbs1rOx8MKywUWZwmbFGNORzJxW4x2MrxjH2vbEfgGi/tpxqTtCJB2xViOlX6Py3LGKpuyWYQo1Uqgfa56Lgo7xBQyEF4LL5i2so= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1573641239280382.9747497870492; Wed, 13 Nov 2019 02:33:59 -0800 (PST) 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-31-4fEJhk6HOWCVBZ8LpDmEHA-1; Wed, 13 Nov 2019 05:33:56 -0500 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 497E78048E3; Wed, 13 Nov 2019 10:33:51 +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 19D6D1B420; Wed, 13 Nov 2019 10:33:51 +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 C5B5218089D5; Wed, 13 Nov 2019 10:33:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xAD9616h025515 for ; Wed, 13 Nov 2019 04:06:02 -0500 Received: by smtp.corp.redhat.com (Postfix) id D8E032166B12; Wed, 13 Nov 2019 09:06:01 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D4AD32166B0D for ; Wed, 13 Nov 2019 09:05:59 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A231080029C for ; Wed, 13 Nov 2019 09:05:59 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-170-iw-gC4ENM0WAouQ3w7QLNA-1; Wed, 13 Nov 2019 04:05:57 -0500 Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Nov 2019 01:05:56 -0800 Received: from david-unc.bj.intel.com ([10.238.157.59]) by orsmga006.jf.intel.com with ESMTP; 13 Nov 2019 01:05:55 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573641238; 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=CgWvvOt9Q+bdxmnYy4kQfy0ubzuepbpWCuuJKND6y2M=; b=cNpjmKdEOZViLL5/yQf63g4JvLtOwWfNEa4kSyBu9B8v3JJzchMIKXShTsTpwwlxfbrAoE 8MVTf56gUiEKv/3zanV3yxeNZV/Y5LX56qZ/I7YEojGRGy81uTLkTaEh+G+2ffTbmAGPOI ktH8inBYjY8sQMhRuKgilXnGGNhj9TY= X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,299,1569308400"; d="scan'208";a="207740842" From: Wang Huaqiang To: libvir-list@redhat.com Date: Thu, 14 Nov 2019 01:08:20 +0800 Message-Id: <20191113170823.17776-3-huaqiang.wang@intel.com> In-Reply-To: <20191113170823.17776-1-huaqiang.wang@intel.com> References: <20191113170823.17776-1-huaqiang.wang@intel.com> MIME-Version: 1.0 X-MC-Unique: iw-gC4ENM0WAouQ3w7QLNA-1 X-MC-Unique: 4fEJhk6HOWCVBZ8LpDmEHA-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id xAD9616h025515 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Wed, 13 Nov 2019 05:33:31 -0500 Cc: Huaqiang Subject: [libvirt] [PATCH 2/5] conf: showing cache/memoryBW monitor features in 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Huaqiang We learned that the hardware features of CAT, CMT, MBA and MBM are orthogonal ones, if CAT or MBA is not supported in system, but CMT or MBM are supported, then the cache monitor or memoryBW monitor features may not be correctly displayed in host capabilities through command 'virsh capabilites'. Showing the cache/memoryBW monitor capabilities even there is no support of cache allocation or memoryBW allocation features. Signed-off-by: Huaqiang Reviewed-by: Daniel P. Berrang=C3=A9 --- src/conf/capabilities.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 7edec75c31..a048427241 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -939,7 +939,7 @@ virCapabilitiesFormatCaches(virBufferPtr buf, size_t i =3D 0; size_t j =3D 0; =20 - if (!cache->nbanks) + if (!cache->nbanks && !cache->monitor) return 0; =20 virBufferAddLit(buf, "\n"); @@ -1025,7 +1025,7 @@ virCapabilitiesFormatMemoryBandwidth(virBufferPtr buf, { size_t i =3D 0; =20 - if (!memBW->nnodes) + if (!memBW->nnodes && !memBW->monitor) return 0; =20 virBufferAddLit(buf, "\n"); --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 00:59:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1573641239; cv=none; d=zoho.com; s=zohoarc; b=eAhHN6eSYrYU9M2oc0P42zS5iCrMF81JdRZHFfs0KY0JDe9WMCI6vx8/3dpYQl95Sme/fWEyZTqbseZaio2H9KHBn2Pm4bY9Kk1HR59hmx36NcZ4F7IScXBk7vOtYwM6yorDNH/J2aruxJSP/5BfJWswC9M3CcPZRzoAoXBsuqg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573641239; 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=Rn9zCVEQxLtw9mhCH5rB7RxC2cB7GGXfrWgndXzbFcc=; b=bvdpZIJIPHEe+0X/yAi/VrJIG1UIEj5qAhD2LILTCxXXuTWzuBMShJQ/uD/mAWlCSJfbB+B7FPCWSOKQD/EIdcx4T6skIDn+/OrYK0mg/ePHQlxAP1ycxVKS8JSPq7O7qLgLTMMgjIjVzxYISI1G4kDb/tPIMq+8EVnW2aDGZ7E= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1573641239774545.6120535281469; Wed, 13 Nov 2019 02:33:59 -0800 (PST) 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-79-uUbVTBSqPZq7ip0gNXHivQ-1; Wed, 13 Nov 2019 05:33:56 -0500 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 952D518B5F79; Wed, 13 Nov 2019 10:33:51 +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 5DB865E258; Wed, 13 Nov 2019 10:33:51 +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 C580818089D0; Wed, 13 Nov 2019 10:33:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xAD96219025516 for ; Wed, 13 Nov 2019 04:06:02 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0B65517897; Wed, 13 Nov 2019 09:06:02 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 06DF81D089 for ; Wed, 13 Nov 2019 09:05:59 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D2A518E3868 for ; Wed, 13 Nov 2019 09:05:59 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-362-nH1hUApwO4G_kY9ZurjeEg-3; Wed, 13 Nov 2019 04:05:58 -0500 Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Nov 2019 01:05:57 -0800 Received: from david-unc.bj.intel.com ([10.238.157.59]) by orsmga006.jf.intel.com with ESMTP; 13 Nov 2019 01:05:56 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573641238; 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=Rn9zCVEQxLtw9mhCH5rB7RxC2cB7GGXfrWgndXzbFcc=; b=TnNYZ6jHJbp+EKyT34PgF+wqfcZiI2IvPGwhpUGKlhdpO6+2CuAj2QBdyb9uN6TnrayaI+ s4mRFRarrJ+l0KwUmNiyjWzpHmdJtIyggup6gAwLzd+mEWi+pJyPKTYlhB5YPrIoUJHUXC GGxJxVKRpR7V42xrOTVHf+c6RmfoU2w= X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,299,1569308400"; d="scan'208";a="207740847" From: Wang Huaqiang To: libvir-list@redhat.com Date: Thu, 14 Nov 2019 01:08:21 +0800 Message-Id: <20191113170823.17776-4-huaqiang.wang@intel.com> In-Reply-To: <20191113170823.17776-1-huaqiang.wang@intel.com> References: <20191113170823.17776-1-huaqiang.wang@intel.com> MIME-Version: 1.0 X-MC-Unique: nH1hUApwO4G_kY9ZurjeEg-3 X-MC-Unique: uUbVTBSqPZq7ip0gNXHivQ-1 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id xAD96219025516 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Wed, 13 Nov 2019 05:33:31 -0500 Cc: Huaqiang Subject: [libvirt] [PATCH 3/5] cachetune schema: a looser check for the order of and element X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Huaqiang Originally, inside , it requires the element to be in the position before , and following configuration is not permitted by schema, but it is better to let it be valid. ^ |__ Not permitted originally because it is in the place before element. ... And, let schema do more strict check by identifying following configuration= to be invalid, due to should contain at least one or element. ^ |__ a SHOULD contain at least one or ... Signed-off-by: Huaqiang Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/schemas/domaincommon.rng | 68 +++++++++++------------ tests/genericxml2xmlindata/cachetune.xml | 1 + tests/genericxml2xmloutdata/cachetune.xml | 34 ++++++++++++ tests/genericxml2xmltest.c | 2 +- 4 files changed, 70 insertions(+), 35 deletions(-) create mode 100644 tests/genericxml2xmloutdata/cachetune.xml diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index e06f892da3..aa4f512e5c 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -980,41 +980,41 @@ - - - - - - - - - - - both - code - data - - - - - - - - + + + + + - - - - - - - - - - - - - + + + + + + both + code + data + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/genericxml2xmlindata/cachetune.xml b/tests/genericxml2xm= lindata/cachetune.xml index 645cab7771..eda2ca6fb6 100644 --- a/tests/genericxml2xmlindata/cachetune.xml +++ b/tests/genericxml2xmlindata/cachetune.xml @@ -6,6 +6,7 @@ 4 + diff --git a/tests/genericxml2xmloutdata/cachetune.xml b/tests/genericxml2x= mloutdata/cachetune.xml new file mode 100644 index 0000000000..dcde0ebc2a --- /dev/null +++ b/tests/genericxml2xmloutdata/cachetune.xml @@ -0,0 +1,34 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 4 + + + + + + + + + + + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + + diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c index 0d04413712..62005a5393 100644 --- a/tests/genericxml2xmltest.c +++ b/tests/genericxml2xmltest.c @@ -125,9 +125,9 @@ mymain(void) DO_TEST_FULL("chardev-reconnect-invalid-mode", 0, false, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); =20 - DO_TEST("cachetune"); DO_TEST("cachetune-small"); DO_TEST("cachetune-cdp"); + DO_TEST_DIFFERENT("cachetune"); DO_TEST_DIFFERENT("cachetune-extra-tunes"); DO_TEST_FULL("cachetune-colliding-allocs", false, true, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 00:59:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1573641224; cv=none; d=zoho.com; s=zohoarc; b=GIlsjeeSqSSsG5qjvmt6DabMKNta8/pubFdwBnDSrssdLjY/00wqnXp3zyYcBXQyrE829LvvJBRoHeXGOeVIYvzQ5u/quVrmBHLEr7T4wEu22O/uN2N3DXxWNUaXzWrnw8oyZP39wwZ6360/dUyNC0qzM8UrfK8kPE//1/NUq0w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573641224; 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=Wzf6PaK7t625dkhfviIlXcOGZONqCQegRldD3884LXo=; b=n3vR8bdBmDRruxJNdJtEuyD45q0vc+RfVhLLn+drghlAgwqhqTN7bWLJBbUOHICdAN3d8pHa9qluVqz3OV6xRESjUSzbMVnU0B3DuGxrbsQFzJEIyZbj4TDfoRIYCnDMKsuI6Ne2qmoDu8CaZeMM6vbJZUCWVJLkA/nogHYxnFU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1573641224051404.740868070078; Wed, 13 Nov 2019 02:33:44 -0800 (PST) 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-12-n7T0iDwwOpqumUshSL9XJg-1; Wed, 13 Nov 2019 05:33:41 -0500 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 EBDB9107ACC8; Wed, 13 Nov 2019 10:33: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 7AAB54FA33; Wed, 13 Nov 2019 10:33: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 F2C4918095FF; Wed, 13 Nov 2019 10:33:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xAD961Ok025500 for ; Wed, 13 Nov 2019 04:06:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3928610D14E5; Wed, 13 Nov 2019 09:06:01 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 32EB710D14E2 for ; Wed, 13 Nov 2019 09:06:00 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C44C1802FE6 for ; Wed, 13 Nov 2019 09:06:00 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-170-dhjUEXX5PT-hFPVDLw5VYg-2; Wed, 13 Nov 2019 04:05:59 -0500 Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Nov 2019 01:05:58 -0800 Received: from david-unc.bj.intel.com ([10.238.157.59]) by orsmga006.jf.intel.com with ESMTP; 13 Nov 2019 01:05:57 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573641222; 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=Wzf6PaK7t625dkhfviIlXcOGZONqCQegRldD3884LXo=; b=SxlOtqBARfVmm/VQGgdtJcjfeKcLiLaQdFHSuW8wI7L9r8SuupYxiKY3lfUyolbvVhfLbp B3BBs8OrVfU0PHBMB9uSm+t6HlZKbRW3ZO8z52mxTQVo3emUjbNMGoSWf4QHJx0L4h8KDy 8bdXZG05UYpJUop34pAYEHxA4l6LL7Y= X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,299,1569308400"; d="scan'208";a="207740852" From: Wang Huaqiang To: libvir-list@redhat.com Date: Thu, 14 Nov 2019 01:08:22 +0800 Message-Id: <20191113170823.17776-5-huaqiang.wang@intel.com> In-Reply-To: <20191113170823.17776-1-huaqiang.wang@intel.com> References: <20191113170823.17776-1-huaqiang.wang@intel.com> MIME-Version: 1.0 X-MC-Unique: dhjUEXX5PT-hFPVDLw5VYg-2 X-MC-Unique: n7T0iDwwOpqumUshSL9XJg-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id xAD961Ok025500 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Wed, 13 Nov 2019 05:33:31 -0500 Cc: Huaqiang Subject: [libvirt] [PATCH 4/5] conf: Parse dommon configure file for memorytune monitors X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Huaqiang Create memory bandwidth monitor. Following domain configuration changes create two memory bandwidth monitors: one is monitoring the bandwidth consumed by vCPU 0, another is for vCPU 5. ``` + + + + ``` Signed-off-by: Huaqiang Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/schemas/domaincommon.rng | 23 +++++++---- src/conf/domain_conf.c | 44 +++++++++++++++++----- tests/genericxml2xmlindata/memorytune.xml | 5 +++ tests/genericxml2xmloutdata/memorytune.xml | 42 +++++++++++++++++++++ tests/genericxml2xmltest.c | 2 +- 5 files changed, 98 insertions(+), 18 deletions(-) create mode 100644 tests/genericxml2xmloutdata/memorytune.xml diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index aa4f512e5c..adf1fcb36d 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1023,14 +1023,21 @@ - - - - - - - - + + + + + + + + + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 875490dd2b..51bf18a42b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -19639,10 +19639,14 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, { VIR_XPATH_NODE_AUTORESTORE(ctxt); virDomainResctrlDefPtr resctrl =3D NULL; + virDomainResctrlDefPtr newresctrl =3D NULL; g_autoptr(virBitmap) vcpus =3D NULL; g_autofree xmlNodePtr *nodes =3D NULL; g_autoptr(virResctrlAlloc) alloc =3D NULL; ssize_t i =3D 0; + size_t nmons =3D 0; + size_t ret =3D -1; + int n; =20 ctxt->node =3D node; @@ -19669,29 +19673,44 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, return -1; } =20 + /* First, parse element if any element exists= */ for (i =3D 0; i < n; i++) { if (virDomainMemorytuneDefParseMemory(ctxt, nodes[i], alloc) < 0) return -1; } =20 - if (n =3D=3D 0) - return 0; - /* * If this is a new allocation, format ID and append to resctrl, other= wise * just update the existing alloc information, which is done in above * virDomainMemorytuneDefParseMemory */ if (!resctrl) { - if (!(resctrl =3D virDomainResctrlNew(node, alloc, vcpus, flags))) + if (!(newresctrl =3D virDomainResctrlNew(node, alloc, vcpus, flags= ))) return -1; =20 - if (VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, resctrl) < 0= ) { - virDomainResctrlDefFree(resctrl); - return -1; - } + resctrl =3D newresctrl; } =20 - return 0; + /* Next, parse element */ + nmons =3D resctrl->nmonitors; + if (virDomainResctrlMonDefParse(def, ctxt, node, + VIR_RESCTRL_MONITOR_TYPE_MEMBW, + resctrl) < 0) + goto cleanup; + + nmons =3D resctrl->nmonitors - nmons; + /* Now @nmons contains the new element number found in curre= nt + * element, and @n holds the number of new element, + * only append the new @newresctrl object to domain if any of them is + * not zero. */ + if (newresctrl && (nmons || n)) { + if (VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, newresctrl) = < 0) + goto cleanup; + } + + ret =3D 0; + cleanup: + virDomainResctrlDefFree(newresctrl); + return ret; } =20 =20 @@ -27607,6 +27626,7 @@ virDomainMemorytuneDefFormat(virBufferPtr buf, { g_auto(virBuffer) childrenBuf =3D VIR_BUFFER_INITIALIZER; g_autofree char *vcpus =3D NULL; + size_t i =3D 0; =20 virBufferSetChildIndent(&childrenBuf, buf); if (virResctrlAllocForeachMemory(resctrl->alloc, @@ -27614,6 +27634,12 @@ virDomainMemorytuneDefFormat(virBufferPtr buf, &childrenBuf) < 0) return -1; =20 + for (i =3D 0; i< resctrl->nmonitors; i++) { + if (virDomainResctrlMonDefFormatHelper(resctrl->monitors[i], + VIR_RESCTRL_MONITOR_TYPE_ME= MBW, + &childrenBuf) < 0) + return -1; + } =20 if (!virBufferUse(&childrenBuf)) return 0; diff --git a/tests/genericxml2xmlindata/memorytune.xml b/tests/genericxml2x= mlindata/memorytune.xml index 7486b542c5..8d86ce4282 100644 --- a/tests/genericxml2xmlindata/memorytune.xml +++ b/tests/genericxml2xmlindata/memorytune.xml @@ -10,12 +10,17 @@ + + + + + hvm diff --git a/tests/genericxml2xmloutdata/memorytune.xml b/tests/genericxml2= xmloutdata/memorytune.xml new file mode 100644 index 0000000000..f996435a6e --- /dev/null +++ b/tests/genericxml2xmloutdata/memorytune.xml @@ -0,0 +1,42 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 4 + + + + + + + + + + + + + + + + + + + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + + diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c index 62005a5393..93f90f7cfd 100644 --- a/tests/genericxml2xmltest.c +++ b/tests/genericxml2xmltest.c @@ -137,7 +137,7 @@ mymain(void) TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); DO_TEST_FULL("cachetune-colliding-monitor", false, true, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); - DO_TEST("memorytune"); + DO_TEST_DIFFERENT("memorytune"); DO_TEST_FULL("memorytune-colliding-allocs", false, true, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); DO_TEST_FULL("memorytune-colliding-cachetune", false, true, --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 00:59:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1573641235; cv=none; d=zoho.com; s=zohoarc; b=NO3TiuVZDHNaQODtKO4II0D/X3CW5T8QRwdLhK8C1VmEXJUk3Jg0sqKzL4H7ql8m+cTYdn9pWDgOvXYz5DGi7JHIWpj4NGAAbyKUc9wMLpGSNllZ9J6sDZIpJ/0kb0S4GsxeloKMR5/VX6fGHAb0lDrLqN6b78imxoGeI3Z5++Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573641235; 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=gWlgCPgNFHVhm077FOo4tfYCvX+giv+J+PD63UkFII8=; b=iA7cLUI5NmBdOX5jNRwYm7u4J4M04+vB+EJ+FYXZ/AYj0peozF2VAErzaGkUdIYCkg7htAYSOEQzO/PxvTYpIgOM1XlDEgKjvNTtHgl+HW9cuqzxnAoGEibTayPuC7EfHaX/aTFwPKTLYRKuCfEomnnbF5sH7qm7Ow/UoXsVNqU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1573641235768547.1439985641697; Wed, 13 Nov 2019 02:33:55 -0800 (PST) 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-415-2Tp_aQpZMpyrGcyJF_RCKg-1; Wed, 13 Nov 2019 05:33:52 -0500 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 E11A2107ACE5; Wed, 13 Nov 2019 10:33:47 +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 B6EAC1B07A; Wed, 13 Nov 2019 10:33: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 71E4E4E56C; Wed, 13 Nov 2019 10:33:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xAD961HL025502 for ; Wed, 13 Nov 2019 04:06:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6DDE220316F6; Wed, 13 Nov 2019 09:06:01 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 69017200AF7D for ; Wed, 13 Nov 2019 09:06:01 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 430938007D8 for ; Wed, 13 Nov 2019 09:06:01 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-362-JmZFV0H5NQe_uAQ0rdvlwg-4; Wed, 13 Nov 2019 04:05:59 -0500 Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Nov 2019 01:05:59 -0800 Received: from david-unc.bj.intel.com ([10.238.157.59]) by orsmga006.jf.intel.com with ESMTP; 13 Nov 2019 01:05:58 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573641234; 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=gWlgCPgNFHVhm077FOo4tfYCvX+giv+J+PD63UkFII8=; b=d3zz3jvtOBDl5N8NFqW++GdW0RP/4jnjf0lKNLFs1o3b0qrdPDQVroAgN4vlO3fX1Fn9Kb r84tEsYk8OdDhcV2ubItvQVR7WELYSBmho42of1yuohvtcAZ/7m6tuMlv4ZwN8Fobemj8f Vgi0kAb9hz0YCWOfnGBY79Vr+mJmP9U= X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,299,1569308400"; d="scan'208";a="207740857" From: Wang Huaqiang To: libvir-list@redhat.com Date: Thu, 14 Nov 2019 01:08:23 +0800 Message-Id: <20191113170823.17776-6-huaqiang.wang@intel.com> In-Reply-To: <20191113170823.17776-1-huaqiang.wang@intel.com> References: <20191113170823.17776-1-huaqiang.wang@intel.com> MIME-Version: 1.0 X-MC-Unique: JmZFV0H5NQe_uAQ0rdvlwg-4 X-MC-Unique: 2Tp_aQpZMpyrGcyJF_RCKg-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id xAD961HL025502 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Wed, 13 Nov 2019 05:33:31 -0500 Cc: Huaqiang Subject: [libvirt] [PATCH 5/5] virsh: show memoryBW info in 'virsh domstats' command 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 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Huaqiang Introduce an option '--memory' for showing memory related information. The memory bandwidth infomatio is listed as: Domain: 'libvirt-vm' memory.bandwidth.monitor.count=3D4 memory.bandwidth.monitor.0.name=3Dvcpus_0-4 memory.bandwidth.monitor.0.vcpus=3D0-4 memory.bandwidth.monitor.0.node.count=3D2 memory.bandwidth.monitor.0.node.0.id=3D0 memory.bandwidth.monitor.0.node.0.bytes.total=3D10208067584 memory.bandwidth.monitor.0.node.0.bytes.local=3D4807114752 memory.bandwidth.monitor.0.node.1.id=3D1 memory.bandwidth.monitor.0.node.1.bytes.total=3D8693735424 memory.bandwidth.monitor.0.node.1.bytes.local=3D5850161152 memory.bandwidth.monitor.1.name=3Dvcpus_7 memory.bandwidth.monitor.1.vcpus=3D7 memory.bandwidth.monitor.1.node.count=3D2 memory.bandwidth.monitor.1.node.0.id=3D0 memory.bandwidth.monitor.1.node.0.bytes.total=3D853811200 memory.bandwidth.monitor.1.node.0.bytes.local=3D290701312 memory.bandwidth.monitor.1.node.1.id=3D1 memory.bandwidth.monitor.1.node.1.bytes.total=3D406044672 memory.bandwidth.monitor.1.node.1.bytes.local=3D229425152 Signed-off-by: Huaqiang --- include/libvirt/libvirt-domain.h | 1 + src/libvirt-domain.c | 21 +++++++ src/qemu/qemu_driver.c | 99 ++++++++++++++++++++++++++++++++ tools/virsh-domain-monitor.c | 7 +++ tools/virsh.pod | 23 +++++++- 5 files changed, 149 insertions(+), 2 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 22277b0a84..2b621ff162 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -2146,6 +2146,7 @@ typedef enum { VIR_DOMAIN_STATS_BLOCK =3D (1 << 5), /* return domain block info */ VIR_DOMAIN_STATS_PERF =3D (1 << 6), /* return domain perf event info */ VIR_DOMAIN_STATS_IOTHREAD =3D (1 << 7), /* return iothread poll info */ + VIR_DOMAIN_STATS_MEMORY=3D (1 << 8), /* return domain memory info */ } virDomainStatsTypes; =20 typedef enum { diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index dcab179e6e..c8c543ccde 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -11641,6 +11641,27 @@ virConnectGetDomainCapabilities(virConnectPtr conn, * hypervisor to choose how to shrink the * polling time. * + * VIR_DOMAIN_STATS_MEMORY: + * Return memory bandwidth statistics and the usage information. The t= yped + * parameter keys are in this format: + * + * "memory.bandwidth.monitor.count" - the number of memory bandwidth + * monitors for this domain + * "memory.bandwidth.monitor..name" - the name of monitor + * "memory.bandwidth.monitor..vcpus" - the vcpu list of monitor <= num> + * "memory.bandwidth.monitor..node.count" - the number of memory + * controller in monitor + * "memory.bandwidth.monitor..node..id" - host allocated m= emory + * controller id for contr= oller + * of monitor + * "memory.bandwidth.monitor..node..bytes.local" - the + * accumulative bytes consumed by @vcpus that passing + * through the memory controller in the same process= or + * that the scheduled host CPU belongs to. + * "memory.bandwidth.monitor..node..bytes.total" - the tot= al + * bytes consumed by @vcpus that passing through all + * memory controllers, either local or remote contro= ller. + * * Note that entire stats groups or individual stat fields may be missing = from * the output in case they are not supported by the given hypervisor, are = not * applicable for the current state of the guest domain, or their retrieval diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e396358871..37a986a1bd 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20496,6 +20496,9 @@ qemuDomainGetResctrlMonData(virQEMUDriverPtr driver, features =3D caps->host.cache.monitor->features; break; case VIR_RESCTRL_MONITOR_TYPE_MEMBW: + if (caps->host.memBW.monitor) + features =3D caps->host.memBW.monitor->features; + break; case VIR_RESCTRL_MONITOR_TYPE_UNSUPPORT: case VIR_RESCTRL_MONITOR_TYPE_LAST: virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", @@ -20548,6 +20551,90 @@ qemuDomainGetResctrlMonData(virQEMUDriverPtr drive= r, } =20 =20 +static int +qemuDomainGetStatsMemoryBandwidth(virQEMUDriverPtr driver, + virDomainObjPtr dom, + virTypedParamListPtr params) +{ + virQEMUResctrlMonDataPtr *resdata =3D NULL; + char **features =3D NULL; + size_t nresdata =3D 0; + size_t i =3D 0; + size_t j =3D 0; + size_t k =3D 0; + int ret =3D -1; + + if (!virDomainObjIsActive(dom)) + return 0; + + if (qemuDomainGetResctrlMonData(driver, dom, &resdata, &nresdata, + VIR_RESCTRL_MONITOR_TYPE_MEMBW) < 0) + goto cleanup; + + if (nresdata =3D=3D 0) + return 0; + + if (virTypedParamListAddUInt(params, nresdata, + "memory.bandwidth.monitor.count") < 0) + goto cleanup; + + for (i =3D 0; i < nresdata; i++) { + if (virTypedParamListAddString(params, resdata[i]->name, + "memory.bandwidth.monitor.%zu.name", + i) < 0) + goto cleanup; + + if (virTypedParamListAddString(params, resdata[i]->vcpus, + "memory.bandwidth.monitor.%zu.vcpus= ", + i) < 0) + goto cleanup; + + if (virTypedParamListAddUInt(params, resdata[i]->nstats, + "memory.bandwidth.monitor.%zu.node.co= unt", + i) < 0) + goto cleanup; + + + for (j =3D 0; j < resdata[i]->nstats; j++) { + if (virTypedParamListAddUInt(params, resdata[i]->stats[j]->id, + "memory.bandwidth.monitor.%zu." + "node.%zu.id", + i, j) < 0) + goto cleanup; + + + features =3D resdata[i]->stats[j]->features; + for (k =3D 0; features[k]; k++) { + if (STREQ(features[k], "mbm_local_bytes")) { + if (virTypedParamListAddULLong(params, + resdata[i]->stats[j]->v= als[k], + "memory.bandwidth.monit= or." + "%zu.node.%zu.bytes.loc= al", + i, j) < 0) + goto cleanup; + } + + if (STREQ(features[k], "mbm_total_bytes")) { + if (virTypedParamListAddULLong(params, + resdata[i]->stats[j]->v= als[k], + "memory.bandwidth.monit= or." + "%zu.node.%zu.bytes.tot= al", + i, j) < 0) + goto cleanup; + } + } + } + } + + ret =3D 0; + cleanup: + for (i =3D 0; i < nresdata; i++) + qemuDomainFreeResctrlMonData(resdata[i]); + VIR_FREE(resdata); + return ret; +} + + static int qemuDomainGetStatsCpuCache(virQEMUDriverPtr driver, virDomainObjPtr dom, @@ -20645,6 +20732,17 @@ qemuDomainGetStatsCpu(virQEMUDriverPtr driver, } =20 =20 +static int +qemuDomainGetStatsMemory(virQEMUDriverPtr driver, + virDomainObjPtr dom, + virTypedParamListPtr params, + unsigned int privflags G_GNUC_UNUSED) + +{ + return qemuDomainGetStatsMemoryBandwidth(driver, dom, params); +} + + static int qemuDomainGetStatsBalloon(virQEMUDriverPtr driver, virDomainObjPtr dom, @@ -21314,6 +21412,7 @@ static struct qemuDomainGetStatsWorker qemuDomainGe= tStatsWorkers[] =3D { { qemuDomainGetStatsBlock, VIR_DOMAIN_STATS_BLOCK, true }, { qemuDomainGetStatsPerf, VIR_DOMAIN_STATS_PERF, false }, { qemuDomainGetStatsIOThread, VIR_DOMAIN_STATS_IOTHREAD, true }, + { qemuDomainGetStatsMemory, VIR_DOMAIN_STATS_MEMORY, false }, { NULL, 0, false } }; =20 diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 034c913d5e..8abd0f2d0b 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -2111,6 +2111,10 @@ static const vshCmdOptDef opts_domstats[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("report domain IOThread information"), }, + {.name =3D "memory", + .type =3D VSH_OT_BOOL, + .help =3D N_("report domain memory usage"), + }, {.name =3D "list-active", .type =3D VSH_OT_BOOL, .help =3D N_("list only active domains"), @@ -2227,6 +2231,9 @@ cmdDomstats(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "iothread")) stats |=3D VIR_DOMAIN_STATS_IOTHREAD; =20 + if (vshCommandOptBool(cmd, "memory")) + stats |=3D VIR_DOMAIN_STATS_MEMORY; + if (vshCommandOptBool(cmd, "list-active")) flags |=3D VIR_CONNECT_GET_ALL_DOMAINS_STATS_ACTIVE; =20 diff --git a/tools/virsh.pod b/tools/virsh.pod index cf2798e71a..30effffcba 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1483,7 +1483,7 @@ reason for the state. =20 =3Ditem B [I<--raw>] [I<--enforce>] [I<--backing>] [I<--nowait>] [I<--state>] [I<--cpu-total>] [I<--balloon>] [I<--vcpu>] [I<--interface>] -[I<--block>] [I<--perf>] [I<--iothread>] +[I<--block>] [I<--perf>] [I<--iothread>] [I<--memory>] [[I<--list-active>] [I<--list-inactive>] [I<--list-persistent>] [I<--list-transient>] [I<--list-running>] [I<--list-paused>] [I<--list-shutoff>] [I<--list-other>]] | [I ...] @@ -1502,7 +1502,7 @@ behavior use the I<--raw> flag. The individual statistics groups are selectable via specific flags. By default all supported statistics groups are returned. Supported statistics groups flags are: I<--state>, I<--cpu-total>, I<--balloon>, -I<--vcpu>, I<--interface>, I<--block>, I<--perf>, I<--iothread>. +I<--vcpu>, I<--interface>, I<--block>, I<--perf>, I<--iothread>, I<--memor= y>. =20 Note that - depending on the hypervisor type and version or the domain sta= te - not all of the following statistics may be returned. @@ -1670,6 +1670,25 @@ not available for statistical purposes. 0 (zero) indicates shrink is managed by the hypervisor. =20 +I<--memory> returns: + + "memory.bandwidth.monitor.count" - the number of memory bandwidth + monitors for this domain + "memory.bandwidth.monitor..name" - the name of monitor + "memory.bandwidth.monitor..vcpus" - the vcpu list of monitor + "memory.bandwidth.monitor..node.count" - the number of memory + controller in monitor + "memory.bandwidth.monitor..node..id" - host allocated memory + controller id for controller + of monitor + "memory.bandwidth.monitor..node..bytes.local" - the accumulat= ive + bytes consumed by @vcpus that passing through + the memory controller in the same processor + that the scheduled host CPU belongs to. + "memory.bandwidth.monitor..node..bytes.total" - the total + bytes consumed by @vcpus that passing through all + memory controllers, either local or remote control= ler. + Selecting a specific statistics groups doesn't guarantee that the daemon supports the selected group of stats. Flag I<--enforce> forces the command to fail if the daemon doesn't support the --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list