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.q...@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 0f7f331..ec11792 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 e6f9f30..3552761 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -941,6 +941,7 @@ int virResCtrlSetCacheBanks(virDomainCachetunePtr cachetune,
     char name[VIR_UUID_STRING_BUFLEN];
     virResDomainPtr p;
     int type;
+    int pair_type = -1;
     int sid;
     int schemata;
 
@@ -974,6 +975,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) {
@@ -991,6 +999,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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to