This patch support l3 cache allocation compatible mode if cdp enabled
on host.
In this case l3code/l3data has same schemata.
Signed-off-by: Eli Qiao <liyong.qiao(a)intel.com>
---
src/conf/domain_conf.c | 15 +++++++++++++--
src/util/virresctrl.c | 10 ++++++++++
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8c340ea..81724d2 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15682,9 +15682,20 @@ virDomainCacheTuneDefParseXML(virDomainDefPtr def,
resctrl = virResCtrlGet(type);
if (resctrl == NULL || !resctrl->enabled) {
- virReportError(VIR_ERR_XML_ERROR,
+ /* support cdp compatible */
+ if (type == VIR_RDT_RESOURCE_L3) {
+ resctrl = virResCtrlGet(type + 1);
+ if (resctrl == NULL || !resctrl->enabled) {
+ virReportError(VIR_ERR_XML_ERROR,
_("'host doesn't enabled cache type '%s'"),
tmp);
- goto cleanup;
+ goto cleanup;
+ }
+ VIR_WARN("Use cdp compatible mode.");
+ } else {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("'host doesn't enabled cache type
'%s'"), tmp);
+ goto cleanup;
+ }
}
bool found_host_id = false;
diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
index d1a0af5..fe9214f 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -744,6 +744,7 @@ int virResCtrlSetCacheBanks(virDomainCachetunePtr cachetune,
char name[VIR_UUID_STRING_BUFLEN];
virResDomainPtr p;
int type;
+ int pair_type = -1;
int sid;
int schemata;
@@ -777,6 +778,13 @@ int virResCtrlSetCacheBanks(virDomainCachetunePtr cachetune,
cachetune->cache_banks[i].type);
continue;
}
+ /* use cdp compatible mode */
+ if (!VIR_RESCTRL_ENABLED(type) &&
+ (type == VIR_RDT_RESOURCE_L3) &&
+ VIR_RESCTRL_ENABLED(VIR_RDT_RESOURCE_L3DATA)) {
+ type = VIR_RDT_RESOURCE_L3DATA;
+ pair_type = VIR_RDT_RESOURCE_L3CODE;
+ }
if ((sid = virResCtrlGetSocketIdByHostID(
type, cachetune->cache_banks[i].host_id)) < 0) {
@@ -794,6 +802,8 @@ int virResCtrlSetCacheBanks(virDomainCachetunePtr cachetune,
}
p->schematas[type]->schemata_items[sid].schemata = schemata;
+ if (pair_type > 0)
+ p->schematas[pair_type]->schemata_items[sid].schemata = schemata;
}
for (i = 0; i < npid; i++)
--
1.9.1