Move memory bandwidth capability nodes into one data structure,
this allows us to add a monitor for memory bandwidth.
Signed-off-by: Wang Huaqiang <huaqiang.wang(a)intel.com>
---
src/conf/capabilities.c | 22 ++++++++++------------
src/conf/capabilities.h | 10 ++++++++--
2 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 9149e10..66ad420 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -249,9 +249,9 @@ virCapsDispose(void *object)
virCapsHostCacheBankFree(caps->host.cache.banks[i]);
VIR_FREE(caps->host.cache.banks);
- for (i = 0; i < caps->host.nnodes; i++)
- virCapsHostMemBWNodeFree(caps->host.nodes[i]);
- VIR_FREE(caps->host.nodes);
+ for (i = 0; i < caps->host.memBW.nnodes; i++)
+ virCapsHostMemBWNodeFree(caps->host.memBW.nodes[i]);
+ VIR_FREE(caps->host.memBW.nodes);
VIR_FREE(caps->host.netprefix);
VIR_FREE(caps->host.pagesSize);
@@ -961,20 +961,19 @@ virCapabilitiesFormatCaches(virBufferPtr buf,
static int
virCapabilitiesFormatMemoryBandwidth(virBufferPtr buf,
- size_t nnodes,
- virCapsHostMemBWNodePtr *nodes)
+ virCapsHostMemBWPtr memBW)
{
size_t i = 0;
virBuffer childrenBuf = VIR_BUFFER_INITIALIZER;
- if (!nnodes)
+ if (!memBW->nnodes)
return 0;
virBufferAddLit(buf, "<memory_bandwidth>\n");
virBufferAdjustIndent(buf, 2);
- for (i = 0; i < nnodes; i++) {
- virCapsHostMemBWNodePtr node = nodes[i];
+ for (i = 0; i < memBW->nnodes; i++) {
+ virCapsHostMemBWNodePtr node = memBW->nodes[i];
virResctrlInfoMemBWPerNodePtr control = &node->control;
char *cpus_str = virBitmapFormat(node->cpus);
@@ -1113,8 +1112,7 @@ virCapabilitiesFormatXML(virCapsPtr caps)
if (virCapabilitiesFormatCaches(&buf, &caps->host.cache) < 0)
goto error;
- if (virCapabilitiesFormatMemoryBandwidth(&buf, caps->host.nnodes,
- caps->host.nodes) < 0)
+ if (virCapabilitiesFormatMemoryBandwidth(&buf, &caps->host.memBW) < 0)
goto error;
for (i = 0; i < caps->host.nsecModels; i++) {
@@ -1677,8 +1675,8 @@ virCapabilitiesInitResctrlMemory(virCapsPtr caps)
if (!(node->cpus = virBitmapNewCopy(bank->cpus)))
goto cleanup;
- if (VIR_APPEND_ELEMENT(caps->host.nodes,
- caps->host.nnodes, node) < 0) {
+ if (VIR_APPEND_ELEMENT(caps->host.memBW.nodes,
+ caps->host.memBW.nnodes, node) < 0) {
goto cleanup;
}
}
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index 744074b..694fd6b 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -166,6 +166,13 @@ struct _virCapsHostMemBWNode {
virResctrlInfoMemBWPerNode control;
};
+typedef struct _virCapsHostMemBW virCapsHostMemBW;
+typedef virCapsHostMemBW *virCapsHostMemBWPtr;
+struct _virCapsHostMemBW {
+ size_t nnodes;
+ virCapsHostMemBWNodePtr *nodes;
+};
+
typedef struct _virCapsHost virCapsHost;
typedef virCapsHost *virCapsHostPtr;
struct _virCapsHost {
@@ -189,8 +196,7 @@ struct _virCapsHost {
virCapsHostCache cache;
- size_t nnodes;
- virCapsHostMemBWNodePtr *nodes;
+ virCapsHostMemBW memBW;
size_t nsecModels;
virCapsHostSecModelPtr secModels;
--
2.7.4