|
|
99cbc7 |
From 1240e6d5b3d53a34a94b308ddf2f10a12f2556f6 Mon Sep 17 00:00:00 2001
|
|
|
99cbc7 |
Message-Id: <1240e6d5b3d53a34a94b308ddf2f10a12f2556f6@dist-git>
|
|
|
99cbc7 |
From: Bing Niu <bing.niu@intel.com>
|
|
|
99cbc7 |
Date: Mon, 15 Apr 2019 17:32:58 +0200
|
|
|
99cbc7 |
Subject: [PATCH] conf: Add support for memorytune XML processing for resctrl
|
|
|
99cbc7 |
MBA
|
|
|
99cbc7 |
MIME-Version: 1.0
|
|
|
99cbc7 |
Content-Type: text/plain; charset=UTF-8
|
|
|
99cbc7 |
Content-Transfer-Encoding: 8bit
|
|
|
99cbc7 |
|
|
|
99cbc7 |
Introduce a new section memorytune to support memory bandwidth allocation.
|
|
|
99cbc7 |
This is consistent with existing cachetune. As the example:
|
|
|
99cbc7 |
below:
|
|
|
99cbc7 |
<cputune>
|
|
|
99cbc7 |
......
|
|
|
99cbc7 |
<memorytune vcpus='0'>
|
|
|
99cbc7 |
<node id='0' bandwidth='30'/>
|
|
|
99cbc7 |
</memorytune>
|
|
|
99cbc7 |
</cputune>
|
|
|
99cbc7 |
|
|
|
99cbc7 |
vpus --- vpus subjected to this memory bandwidth.
|
|
|
99cbc7 |
id --- on which node memory bandwidth to be set.
|
|
|
99cbc7 |
bandwidth --- the memory bandwidth percent to set.
|
|
|
99cbc7 |
|
|
|
99cbc7 |
Signed-off-by: Bing Niu <bing.niu@intel.com>
|
|
|
99cbc7 |
Reviewed-by: John Ferlan <jferlan@redhat.com>
|
|
|
99cbc7 |
(cherry picked from commit 6956b7eedce4cb6dc2f95684fc3e10c163dfc6fc)
|
|
|
99cbc7 |
|
|
|
99cbc7 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1468650
|
|
|
99cbc7 |
|
|
|
99cbc7 |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
99cbc7 |
Message-Id: <3139e3b8f3c3d66891847b5a99bd9125ec01f00b.1555342313.git.phrdina@redhat.com>
|
|
|
99cbc7 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
99cbc7 |
---
|
|
|
99cbc7 |
docs/formatdomain.html.in | 39 +++-
|
|
|
99cbc7 |
docs/schemas/domaincommon.rng | 17 ++
|
|
|
99cbc7 |
src/conf/domain_conf.c | 200 ++++++++++++++++++
|
|
|
99cbc7 |
.../memorytune-colliding-allocs.xml | 30 +++
|
|
|
99cbc7 |
.../memorytune-colliding-cachetune.xml | 32 +++
|
|
|
99cbc7 |
tests/genericxml2xmlindata/memorytune.xml | 33 +++
|
|
|
99cbc7 |
tests/genericxml2xmltest.c | 5 +
|
|
|
99cbc7 |
7 files changed, 355 insertions(+), 1 deletion(-)
|
|
|
99cbc7 |
create mode 100644 tests/genericxml2xmlindata/memorytune-colliding-allocs.xml
|
|
|
99cbc7 |
create mode 100644 tests/genericxml2xmlindata/memorytune-colliding-cachetune.xml
|
|
|
99cbc7 |
create mode 100644 tests/genericxml2xmlindata/memorytune.xml
|
|
|
99cbc7 |
|
|
|
99cbc7 |
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
|
|
|
99cbc7 |
index 42acf7a828..8cf2c12524 100644
|
|
|
99cbc7 |
--- a/docs/formatdomain.html.in
|
|
|
99cbc7 |
+++ b/docs/formatdomain.html.in
|
|
|
99cbc7 |
@@ -757,6 +757,10 @@
|
|
|
99cbc7 |
<cache id='0' level='3' type='both' size='3' unit='MiB'/>
|
|
|
99cbc7 |
<cache id='1' level='3' type='both' size='3' unit='MiB'/>
|
|
|
99cbc7 |
</cachetune>
|
|
|
99cbc7 |
+ <memorytune vcpus='0-3'>
|
|
|
99cbc7 |
+ <node id='0' bandwidth='60'/>
|
|
|
99cbc7 |
+ </memorytune>
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
</cputune>
|
|
|
99cbc7 |
...
|
|
|
99cbc7 |
</domain>
|
|
|
99cbc7 |
@@ -910,7 +914,9 @@
|
|
|
99cbc7 |
size and required granularity are reported as well. The required
|
|
|
99cbc7 |
attribute vcpus specifies to which vCPUs this allocation
|
|
|
99cbc7 |
applies. A vCPU can only be member of one cachetune element
|
|
|
99cbc7 |
- allocations. Supported subelements are:
|
|
|
99cbc7 |
+ allocation. The vCPUs specified by cachetune can be identical with those
|
|
|
99cbc7 |
+ in memorytune, however they are not allowed to overlap.
|
|
|
99cbc7 |
+ Supported subelements are:
|
|
|
99cbc7 |
|
|
|
99cbc7 |
cache
|
|
|
99cbc7 |
|
|
|
99cbc7 |
@@ -950,7 +956,38 @@
|
|
|
99cbc7 |
|
|
|
99cbc7 |
|
|
|
99cbc7 |
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
|
|
|
99cbc7 |
+ memorytune Since 4.7.0
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ Optional memorytune element can control allocations for
|
|
|
99cbc7 |
+ memory bandwidth using the resctrl on the host. Whether or not is this
|
|
|
99cbc7 |
+ supported can be gathered from capabilities where some limitations like
|
|
|
99cbc7 |
+ minimum bandwidth and required granularity are reported as well. The
|
|
|
99cbc7 |
+ required attribute vcpus specifies to which vCPUs this
|
|
|
99cbc7 |
+ allocation applies. A vCPU can only be member of one
|
|
|
99cbc7 |
+ memorytune element allocation. The vcpus specified
|
|
|
99cbc7 |
+ by memorytune can be identical to those specified by
|
|
|
99cbc7 |
+ cachetune . However they are not allowed to overlap each other.
|
|
|
99cbc7 |
+ Supported subelements are:
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ node
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ This element controls the allocation of CPU memory bandwidth and has the
|
|
|
99cbc7 |
+ following attributes:
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ id
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ Host node id from which to allocate memory bandwidth.
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ bandwidth
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ The memory bandwidth to allocate from this node. The value by default
|
|
|
99cbc7 |
+ is in percentage.
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
|
|
|
99cbc7 |
|
|
|
99cbc7 |
|
|
|
99cbc7 |
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
|
|
|
99cbc7 |
index ac04af51a1..48f0637cad 100644
|
|
|
99cbc7 |
--- a/docs/schemas/domaincommon.rng
|
|
|
99cbc7 |
+++ b/docs/schemas/domaincommon.rng
|
|
|
99cbc7 |
@@ -983,6 +983,23 @@
|
|
|
99cbc7 |
</oneOrMore>
|
|
|
99cbc7 |
</element>
|
|
|
99cbc7 |
</zeroOrMore>
|
|
|
99cbc7 |
+ <zeroOrMore>
|
|
|
99cbc7 |
+ <element name="memorytune">
|
|
|
99cbc7 |
+ <attribute name="vcpus">
|
|
|
99cbc7 |
+ <ref name='cpuset'/>
|
|
|
99cbc7 |
+ </attribute>
|
|
|
99cbc7 |
+ <oneOrMore>
|
|
|
99cbc7 |
+ <element name="node">
|
|
|
99cbc7 |
+ <attribute name="id">
|
|
|
99cbc7 |
+ <ref name='unsignedInt'/>
|
|
|
99cbc7 |
+ </attribute>
|
|
|
99cbc7 |
+ <attribute name="bandwidth">
|
|
|
99cbc7 |
+ <ref name='unsignedInt'/>
|
|
|
99cbc7 |
+ </attribute>
|
|
|
99cbc7 |
+ </element>
|
|
|
99cbc7 |
+ </oneOrMore>
|
|
|
99cbc7 |
+ </element>
|
|
|
99cbc7 |
+ </zeroOrMore>
|
|
|
99cbc7 |
</interleave>
|
|
|
99cbc7 |
</element>
|
|
|
99cbc7 |
</define>
|
|
|
99cbc7 |
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
|
99cbc7 |
index 44bfd75b72..2f56c077a9 100644
|
|
|
99cbc7 |
--- a/src/conf/domain_conf.c
|
|
|
99cbc7 |
+++ b/src/conf/domain_conf.c
|
|
|
99cbc7 |
@@ -19296,6 +19296,129 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
|
|
|
99cbc7 |
}
|
|
|
99cbc7 |
|
|
|
99cbc7 |
|
|
|
99cbc7 |
+static int
|
|
|
99cbc7 |
+virDomainMemorytuneDefParseMemory(xmlXPathContextPtr ctxt,
|
|
|
99cbc7 |
+ xmlNodePtr node,
|
|
|
99cbc7 |
+ virResctrlAllocPtr alloc)
|
|
|
99cbc7 |
+{
|
|
|
99cbc7 |
+ xmlNodePtr oldnode = ctxt->node;
|
|
|
99cbc7 |
+ unsigned int id;
|
|
|
99cbc7 |
+ unsigned int bandwidth;
|
|
|
99cbc7 |
+ char *tmp = NULL;
|
|
|
99cbc7 |
+ int ret = -1;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ ctxt->node = node;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ tmp = virXMLPropString(node, "id");
|
|
|
99cbc7 |
+ if (!tmp) {
|
|
|
99cbc7 |
+ virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
99cbc7 |
+ _("Missing memorytune attribute 'id'"));
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+ }
|
|
|
99cbc7 |
+ if (virStrToLong_uip(tmp, NULL, 10, &id) < 0) {
|
|
|
99cbc7 |
+ virReportError(VIR_ERR_XML_ERROR,
|
|
|
99cbc7 |
+ _("Invalid memorytune attribute 'id' value '%s'"),
|
|
|
99cbc7 |
+ tmp);
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+ }
|
|
|
99cbc7 |
+ VIR_FREE(tmp);
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ tmp = virXMLPropString(node, "bandwidth");
|
|
|
99cbc7 |
+ if (!tmp) {
|
|
|
99cbc7 |
+ virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
99cbc7 |
+ _("Missing memorytune attribute 'bandwidth'"));
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+ }
|
|
|
99cbc7 |
+ if (virStrToLong_uip(tmp, NULL, 10, &bandwidth) < 0) {
|
|
|
99cbc7 |
+ virReportError(VIR_ERR_XML_ERROR,
|
|
|
99cbc7 |
+ _("Invalid memorytune attribute 'bandwidth' value '%s'"),
|
|
|
99cbc7 |
+ tmp);
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+ }
|
|
|
99cbc7 |
+ VIR_FREE(tmp);
|
|
|
99cbc7 |
+ if (virResctrlAllocSetMemoryBandwidth(alloc, id, bandwidth) < 0)
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ ret = 0;
|
|
|
99cbc7 |
+ cleanup:
|
|
|
99cbc7 |
+ ctxt->node = oldnode;
|
|
|
99cbc7 |
+ VIR_FREE(tmp);
|
|
|
99cbc7 |
+ return ret;
|
|
|
99cbc7 |
+}
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+static int
|
|
|
99cbc7 |
+virDomainMemorytuneDefParse(virDomainDefPtr def,
|
|
|
99cbc7 |
+ xmlXPathContextPtr ctxt,
|
|
|
99cbc7 |
+ xmlNodePtr node,
|
|
|
99cbc7 |
+ unsigned int flags)
|
|
|
99cbc7 |
+{
|
|
|
99cbc7 |
+ xmlNodePtr oldnode = ctxt->node;
|
|
|
99cbc7 |
+ xmlNodePtr *nodes = NULL;
|
|
|
99cbc7 |
+ virBitmapPtr vcpus = NULL;
|
|
|
99cbc7 |
+ virResctrlAllocPtr alloc = NULL;
|
|
|
99cbc7 |
+ ssize_t i = 0;
|
|
|
99cbc7 |
+ int n;
|
|
|
99cbc7 |
+ int ret = -1;
|
|
|
99cbc7 |
+ bool new_alloc = false;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ ctxt->node = node;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ if (virDomainResctrlParseVcpus(def, node, &vcpus) < 0)
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ if (virBitmapIsAllClear(vcpus)) {
|
|
|
99cbc7 |
+ ret = 0;
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+ }
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ if ((n = virXPathNodeSet("./node", ctxt, &nodes)) < 0) {
|
|
|
99cbc7 |
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
99cbc7 |
+ _("Cannot extract memory nodes under memorytune"));
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+ }
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ if (virDomainResctrlVcpuMatch(def, vcpus, &alloc) < 0)
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ if (!alloc) {
|
|
|
99cbc7 |
+ alloc = virResctrlAllocNew();
|
|
|
99cbc7 |
+ if (!alloc)
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+ new_alloc = true;
|
|
|
99cbc7 |
+ } else {
|
|
|
99cbc7 |
+ alloc = virObjectRef(alloc);
|
|
|
99cbc7 |
+ }
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ for (i = 0; i < n; i++) {
|
|
|
99cbc7 |
+ if (virDomainMemorytuneDefParseMemory(ctxt, nodes[i], alloc) < 0)
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+ }
|
|
|
99cbc7 |
+ if (virResctrlAllocIsEmpty(alloc)) {
|
|
|
99cbc7 |
+ ret = 0;
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+ }
|
|
|
99cbc7 |
+ /*
|
|
|
99cbc7 |
+ * If this is a new allocation, format ID and append to resctrl, otherwise
|
|
|
99cbc7 |
+ * just update the existing alloc information, which is done in above
|
|
|
99cbc7 |
+ * virDomainMemorytuneDefParseMemory */
|
|
|
99cbc7 |
+ if (new_alloc) {
|
|
|
99cbc7 |
+ if (virDomainResctrlAppend(def, node, alloc, vcpus, flags) < 0)
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+ vcpus = NULL;
|
|
|
99cbc7 |
+ alloc = NULL;
|
|
|
99cbc7 |
+ }
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ ret = 0;
|
|
|
99cbc7 |
+ cleanup:
|
|
|
99cbc7 |
+ ctxt->node = oldnode;
|
|
|
99cbc7 |
+ virObjectUnref(alloc);
|
|
|
99cbc7 |
+ virBitmapFree(vcpus);
|
|
|
99cbc7 |
+ VIR_FREE(nodes);
|
|
|
99cbc7 |
+ return ret;
|
|
|
99cbc7 |
+}
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
static virDomainDefPtr
|
|
|
99cbc7 |
virDomainDefParseXML(xmlDocPtr xml,
|
|
|
99cbc7 |
xmlNodePtr root,
|
|
|
99cbc7 |
@@ -19856,6 +19979,18 @@ virDomainDefParseXML(xmlDocPtr xml,
|
|
|
99cbc7 |
}
|
|
|
99cbc7 |
VIR_FREE(nodes);
|
|
|
99cbc7 |
|
|
|
99cbc7 |
+ if ((n = virXPathNodeSet("./cputune/memorytune", ctxt, &nodes)) < 0) {
|
|
|
99cbc7 |
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
99cbc7 |
+ _("cannot extract memorytune nodes"));
|
|
|
99cbc7 |
+ goto error;
|
|
|
99cbc7 |
+ }
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ for (i = 0; i < n; i++) {
|
|
|
99cbc7 |
+ if (virDomainMemorytuneDefParse(def, ctxt, nodes[i], flags) < 0)
|
|
|
99cbc7 |
+ goto error;
|
|
|
99cbc7 |
+ }
|
|
|
99cbc7 |
+ VIR_FREE(nodes);
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
if (virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST, &def->cpu) < 0)
|
|
|
99cbc7 |
goto error;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
@@ -27162,6 +27297,68 @@ virDomainCachetuneDefFormat(virBufferPtr buf,
|
|
|
99cbc7 |
}
|
|
|
99cbc7 |
|
|
|
99cbc7 |
|
|
|
99cbc7 |
+static int
|
|
|
99cbc7 |
+virDomainMemorytuneDefFormatHelper(unsigned int id,
|
|
|
99cbc7 |
+ unsigned int bandwidth,
|
|
|
99cbc7 |
+ void *opaque)
|
|
|
99cbc7 |
+{
|
|
|
99cbc7 |
+ virBufferPtr buf = opaque;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ virBufferAsprintf(buf,
|
|
|
99cbc7 |
+ "<node id='%u' bandwidth='%u'/>\n",
|
|
|
99cbc7 |
+ id, bandwidth);
|
|
|
99cbc7 |
+ return 0;
|
|
|
99cbc7 |
+}
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+static int
|
|
|
99cbc7 |
+virDomainMemorytuneDefFormat(virBufferPtr buf,
|
|
|
99cbc7 |
+ virDomainResctrlDefPtr resctrl,
|
|
|
99cbc7 |
+ unsigned int flags)
|
|
|
99cbc7 |
+{
|
|
|
99cbc7 |
+ virBuffer childrenBuf = VIR_BUFFER_INITIALIZER;
|
|
|
99cbc7 |
+ char *vcpus = NULL;
|
|
|
99cbc7 |
+ int ret = -1;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ virBufferSetChildIndent(&childrenBuf, buf);
|
|
|
99cbc7 |
+ if (virResctrlAllocForeachMemory(resctrl->alloc,
|
|
|
99cbc7 |
+ virDomainMemorytuneDefFormatHelper,
|
|
|
99cbc7 |
+ &childrenBuf) < 0)
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ if (virBufferCheckError(&childrenBuf) < 0)
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ if (!virBufferUse(&childrenBuf)) {
|
|
|
99cbc7 |
+ ret = 0;
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+ }
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ vcpus = virBitmapFormat(resctrl->vcpus);
|
|
|
99cbc7 |
+ if (!vcpus)
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ virBufferAsprintf(buf, "
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ if (!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) {
|
|
|
99cbc7 |
+ const char *alloc_id = virResctrlAllocGetID(resctrl->alloc);
|
|
|
99cbc7 |
+ if (!alloc_id)
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ virBufferAsprintf(buf, " id='%s'", alloc_id);
|
|
|
99cbc7 |
+ }
|
|
|
99cbc7 |
+ virBufferAddLit(buf, ">\n");
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ virBufferAddBuffer(buf, &childrenBuf);
|
|
|
99cbc7 |
+ virBufferAddLit(buf, "</memorytune>\n");
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ ret = 0;
|
|
|
99cbc7 |
+ cleanup:
|
|
|
99cbc7 |
+ virBufferFreeAndReset(&childrenBuf);
|
|
|
99cbc7 |
+ VIR_FREE(vcpus);
|
|
|
99cbc7 |
+ return ret;
|
|
|
99cbc7 |
+}
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
static int
|
|
|
99cbc7 |
virDomainCputuneDefFormat(virBufferPtr buf,
|
|
|
99cbc7 |
virDomainDefPtr def,
|
|
|
99cbc7 |
@@ -27267,6 +27464,9 @@ virDomainCputuneDefFormat(virBufferPtr buf,
|
|
|
99cbc7 |
for (i = 0; i < def->nresctrls; i++)
|
|
|
99cbc7 |
virDomainCachetuneDefFormat(&childrenBuf, def->resctrls[i], flags);
|
|
|
99cbc7 |
|
|
|
99cbc7 |
+ for (i = 0; i < def->nresctrls; i++)
|
|
|
99cbc7 |
+ virDomainMemorytuneDefFormat(&childrenBuf, def->resctrls[i], flags);
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
if (virBufferCheckError(&childrenBuf) < 0)
|
|
|
99cbc7 |
return -1;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
diff --git a/tests/genericxml2xmlindata/memorytune-colliding-allocs.xml b/tests/genericxml2xmlindata/memorytune-colliding-allocs.xml
|
|
|
99cbc7 |
new file mode 100644
|
|
|
99cbc7 |
index 0000000000..9b8ebaa084
|
|
|
99cbc7 |
--- /dev/null
|
|
|
99cbc7 |
+++ b/tests/genericxml2xmlindata/memorytune-colliding-allocs.xml
|
|
|
99cbc7 |
@@ -0,0 +1,30 @@
|
|
|
99cbc7 |
+<domain type='qemu'>
|
|
|
99cbc7 |
+ <name>QEMUGuest1</name>
|
|
|
99cbc7 |
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
|
|
99cbc7 |
+ <memory unit='KiB'>219136</memory>
|
|
|
99cbc7 |
+ <currentMemory unit='KiB'>219136</currentMemory>
|
|
|
99cbc7 |
+ <vcpu placement='static'>4</vcpu>
|
|
|
99cbc7 |
+ <cputune>
|
|
|
99cbc7 |
+ <memorytune vcpus='0'>
|
|
|
99cbc7 |
+ <node id='0' bandwidth='50'/>
|
|
|
99cbc7 |
+ <node id='0' bandwidth='50'/>
|
|
|
99cbc7 |
+ </memorytune>
|
|
|
99cbc7 |
+ </cputune>
|
|
|
99cbc7 |
+ <os>
|
|
|
99cbc7 |
+ <type arch='i686' machine='pc'>hvm</type>
|
|
|
99cbc7 |
+ <boot dev='hd'/>
|
|
|
99cbc7 |
+ </os>
|
|
|
99cbc7 |
+ <clock offset='utc'/>
|
|
|
99cbc7 |
+ <on_poweroff>destroy</on_poweroff>
|
|
|
99cbc7 |
+ <on_reboot>restart</on_reboot>
|
|
|
99cbc7 |
+ <on_crash>destroy</on_crash>
|
|
|
99cbc7 |
+ <devices>
|
|
|
99cbc7 |
+ <emulator>/usr/bin/qemu-system-i686</emulator>
|
|
|
99cbc7 |
+ <controller type='usb' index='0'/>
|
|
|
99cbc7 |
+ <controller type='ide' index='0'/>
|
|
|
99cbc7 |
+ <controller type='pci' index='0' model='pci-root'/>
|
|
|
99cbc7 |
+ <input type='mouse' bus='ps2'/>
|
|
|
99cbc7 |
+ <input type='keyboard' bus='ps2'/>
|
|
|
99cbc7 |
+ <memballoon model='virtio'/>
|
|
|
99cbc7 |
+ </devices>
|
|
|
99cbc7 |
+</domain>
|
|
|
99cbc7 |
diff --git a/tests/genericxml2xmlindata/memorytune-colliding-cachetune.xml b/tests/genericxml2xmlindata/memorytune-colliding-cachetune.xml
|
|
|
99cbc7 |
new file mode 100644
|
|
|
99cbc7 |
index 0000000000..5416870de2
|
|
|
99cbc7 |
--- /dev/null
|
|
|
99cbc7 |
+++ b/tests/genericxml2xmlindata/memorytune-colliding-cachetune.xml
|
|
|
99cbc7 |
@@ -0,0 +1,32 @@
|
|
|
99cbc7 |
+<domain type='qemu'>
|
|
|
99cbc7 |
+ <name>QEMUGuest1</name>
|
|
|
99cbc7 |
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
|
|
99cbc7 |
+ <memory unit='KiB'>219136</memory>
|
|
|
99cbc7 |
+ <currentMemory unit='KiB'>219136</currentMemory>
|
|
|
99cbc7 |
+ <vcpu placement='static'>4</vcpu>
|
|
|
99cbc7 |
+ <cputune>
|
|
|
99cbc7 |
+ <cachetune vcpus='0-1'>
|
|
|
99cbc7 |
+ <cache id='0' level='3' type='code' size='12' unit='KiB'/>
|
|
|
99cbc7 |
+ </cachetune>
|
|
|
99cbc7 |
+ <memorytune vcpus='0'>
|
|
|
99cbc7 |
+ <node id='0' bandwidth='50'/>
|
|
|
99cbc7 |
+ </memorytune>
|
|
|
99cbc7 |
+ </cputune>
|
|
|
99cbc7 |
+ <os>
|
|
|
99cbc7 |
+ <type arch='i686' machine='pc'>hvm</type>
|
|
|
99cbc7 |
+ <boot dev='hd'/>
|
|
|
99cbc7 |
+ </os>
|
|
|
99cbc7 |
+ <clock offset='utc'/>
|
|
|
99cbc7 |
+ <on_poweroff>destroy</on_poweroff>
|
|
|
99cbc7 |
+ <on_reboot>restart</on_reboot>
|
|
|
99cbc7 |
+ <on_crash>destroy</on_crash>
|
|
|
99cbc7 |
+ <devices>
|
|
|
99cbc7 |
+ <emulator>/usr/bin/qemu-system-i686</emulator>
|
|
|
99cbc7 |
+ <controller type='usb' index='0'/>
|
|
|
99cbc7 |
+ <controller type='ide' index='0'/>
|
|
|
99cbc7 |
+ <controller type='pci' index='0' model='pci-root'/>
|
|
|
99cbc7 |
+ <input type='mouse' bus='ps2'/>
|
|
|
99cbc7 |
+ <input type='keyboard' bus='ps2'/>
|
|
|
99cbc7 |
+ <memballoon model='virtio'/>
|
|
|
99cbc7 |
+ </devices>
|
|
|
99cbc7 |
+</domain>
|
|
|
99cbc7 |
diff --git a/tests/genericxml2xmlindata/memorytune.xml b/tests/genericxml2xmlindata/memorytune.xml
|
|
|
99cbc7 |
new file mode 100644
|
|
|
99cbc7 |
index 0000000000..ea03e22fc2
|
|
|
99cbc7 |
--- /dev/null
|
|
|
99cbc7 |
+++ b/tests/genericxml2xmlindata/memorytune.xml
|
|
|
99cbc7 |
@@ -0,0 +1,33 @@
|
|
|
99cbc7 |
+<domain type='qemu'>
|
|
|
99cbc7 |
+ <name>QEMUGuest1</name>
|
|
|
99cbc7 |
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
|
|
99cbc7 |
+ <memory unit='KiB'>219136</memory>
|
|
|
99cbc7 |
+ <currentMemory unit='KiB'>219136</currentMemory>
|
|
|
99cbc7 |
+ <vcpu placement='static'>4</vcpu>
|
|
|
99cbc7 |
+ <cputune>
|
|
|
99cbc7 |
+ <memorytune vcpus='0-1'>
|
|
|
99cbc7 |
+ <node id='0' bandwidth='20'/>
|
|
|
99cbc7 |
+ <node id='1' bandwidth='30'/>
|
|
|
99cbc7 |
+ </memorytune>
|
|
|
99cbc7 |
+ <memorytune vcpus='3'>
|
|
|
99cbc7 |
+ <node id='0' bandwidth='50'/>
|
|
|
99cbc7 |
+ </memorytune>
|
|
|
99cbc7 |
+ </cputune>
|
|
|
99cbc7 |
+ <os>
|
|
|
99cbc7 |
+ <type arch='i686' machine='pc'>hvm</type>
|
|
|
99cbc7 |
+ <boot dev='hd'/>
|
|
|
99cbc7 |
+ </os>
|
|
|
99cbc7 |
+ <clock offset='utc'/>
|
|
|
99cbc7 |
+ <on_poweroff>destroy</on_poweroff>
|
|
|
99cbc7 |
+ <on_reboot>restart</on_reboot>
|
|
|
99cbc7 |
+ <on_crash>destroy</on_crash>
|
|
|
99cbc7 |
+ <devices>
|
|
|
99cbc7 |
+ <emulator>/usr/bin/qemu-system-i686</emulator>
|
|
|
99cbc7 |
+ <controller type='usb' index='0'/>
|
|
|
99cbc7 |
+ <controller type='ide' index='0'/>
|
|
|
99cbc7 |
+ <controller type='pci' index='0' model='pci-root'/>
|
|
|
99cbc7 |
+ <input type='mouse' bus='ps2'/>
|
|
|
99cbc7 |
+ <input type='keyboard' bus='ps2'/>
|
|
|
99cbc7 |
+ <memballoon model='virtio'/>
|
|
|
99cbc7 |
+ </devices>
|
|
|
99cbc7 |
+</domain>
|
|
|
99cbc7 |
diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c
|
|
|
99cbc7 |
index 7a4fc1eb7a..e6d4ef2a7f 100644
|
|
|
99cbc7 |
--- a/tests/genericxml2xmltest.c
|
|
|
99cbc7 |
+++ b/tests/genericxml2xmltest.c
|
|
|
99cbc7 |
@@ -140,6 +140,11 @@ mymain(void)
|
|
|
99cbc7 |
TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
|
|
|
99cbc7 |
DO_TEST_FULL("cachetune-colliding-types", false, true,
|
|
|
99cbc7 |
TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
|
|
|
99cbc7 |
+ DO_TEST("memorytune");
|
|
|
99cbc7 |
+ DO_TEST_FULL("memorytune-colliding-allocs", false, true,
|
|
|
99cbc7 |
+ TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
|
|
|
99cbc7 |
+ DO_TEST_FULL("memorytune-colliding-cachetune", false, true,
|
|
|
99cbc7 |
+ TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
|
|
|
99cbc7 |
|
|
|
99cbc7 |
DO_TEST("tseg");
|
|
|
99cbc7 |
|
|
|
99cbc7 |
--
|
|
|
99cbc7 |
2.21.0
|
|
|
99cbc7 |
|