From nobody Mon Feb 9 17:34:40 2026 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