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 652f4ca..86c292d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15760,9 +15760,13 @@ virDomainCacheTuneDefParseXML(virDomainDefPtr def,
int type = -1;
virDomainCacheBankPtr bank = NULL;
virResCtrlPtr resctrl;
+ /* An 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"))) {
@@ -15810,6 +15814,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) {
@@ -15858,6 +15868,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;
@@ -15865,6 +15883,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 e7376a0..ee5f043 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -34,7 +34,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 3a6fb95..d639de1 100644
--- a/src/util/virresctrl.h
+++ b/src/util/virresctrl.h
@@ -28,6 +28,8 @@
# include "virutil.h"
# include "conf/domain_conf.h"
+#define MAX_CPU_SOCKET_NUM 8
+
enum {
VIR_RDT_RESOURCE_L3,
VIR_RDT_RESOURCE_L3DATA,
--
1.9.1