l3data and l3code type of cache banks should be configured pairs.
Signed-off-by: Eli Qiao <liyong.qiao(a)intel.com>
---
src/conf/domain_conf.c | 19 +++++++++++++++++++
src/util/virresctrl.c | 1 -
src/util/virresctrl.h | 2 ++
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 430c451..0f7f331 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15619,9 +15619,13 @@ virDomainCacheTuneDefParseXML(virDomainDefPtr def,
int type = -1;
virDomainCacheBankPtr bank = NULL;
virResCtrlPtr resctrl;
+ /* A Array to make sure l3code and l3data are pairs*/
+ int* sem = NULL;
if (VIR_ALLOC_N(bank, n) < 0)
goto cleanup;
+ if (VIR_ALLOC_N(sem, MAX_CPU_SOCKET_NUM) < 0)
+ goto cleanup;
for (i = 0; i < n; i++) {
if (!(tmp = virXMLPropString(nodes[i], "id"))) {
@@ -15669,6 +15673,12 @@ virDomainCacheTuneDefParseXML(virDomainDefPtr def,
goto cleanup;
}
+ /* VIR_RDT_RESOURCE_L3DATA and VIR_RDT_RESOURCE_L3CODE should be pair */
+ if (type == VIR_RDT_RESOURCE_L3DATA)
+ sem[bank[i].host_id] ++;
+ else if (type == VIR_RDT_RESOURCE_L3CODE)
+ sem[bank[i].host_id] --;
+
resctrl = virResCtrlGet(type);
if (resctrl == NULL || !resctrl->enabled) {
@@ -15717,6 +15727,14 @@ virDomainCacheTuneDefParseXML(virDomainDefPtr def,
}
}
+ for (i = 0; i < MAX_CPU_SOCKET_NUM; i ++) {
+ if (sem[i] != 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("'l3code and l3data shoud be show up pairs on bank
%zu'"),
+ i);
+ goto cleanup;
+ }
+ }
def->cachetune.cache_banks = bank;
def->cachetune.n_banks = n;
return 0;
@@ -15724,6 +15742,7 @@ virDomainCacheTuneDefParseXML(virDomainDefPtr def,
cleanup:
VIR_FREE(bank);
VIR_FREE(tmp);
+ VIR_FREE(sem);
return -1;
}
diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
index 3ca3600..d15e985 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -40,7 +40,6 @@
VIR_LOG_INIT("util.resctrl");
#define VIR_FROM_THIS VIR_FROM_RESCTRL
-#define MAX_CPU_SOCKET_NUM 8
#define MAX_CBM_BIT_LEN 32
#define MAX_SCHEMATA_LEN 1024
#define MAX_FILE_LEN ( 10 * 1024 * 1024)
diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h
index ba5697e..ee7e115 100644
--- a/src/util/virresctrl.h
+++ b/src/util/virresctrl.h
@@ -28,6 +28,8 @@
# include "virbitmap.h"
# include "domain_conf.h"
+#define MAX_CPU_SOCKET_NUM 8
+
enum {
VIR_RDT_RESOURCE_L3,
VIR_RDT_RESOURCE_L3DATA,
--
1.9.1