|
|
79b470 |
From 0ae283a1cb5224f3eb4fa32706e9b9c212577e51 Mon Sep 17 00:00:00 2001
|
|
|
79b470 |
Message-Id: <0ae283a1cb5224f3eb4fa32706e9b9c212577e51@dist-git>
|
|
|
79b470 |
From: Michal Privoznik <mprivozn@redhat.com>
|
|
|
79b470 |
Date: Wed, 7 Oct 2020 18:45:40 +0200
|
|
|
79b470 |
Subject: [PATCH] conf: Validate NUMA HMAT configuration
|
|
|
79b470 |
MIME-Version: 1.0
|
|
|
79b470 |
Content-Type: text/plain; charset=UTF-8
|
|
|
79b470 |
Content-Transfer-Encoding: 8bit
|
|
|
79b470 |
|
|
|
79b470 |
There are several restrictions, for instance @initiator and
|
|
|
79b470 |
@target have to refer to existing NUMA nodes (daa), @cache has to
|
|
|
79b470 |
refer to a defined cache level and so on.
|
|
|
79b470 |
|
|
|
79b470 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
79b470 |
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
|
|
|
79b470 |
(cherry picked from commit f0611fe8830543d03d1871422f8c542453f0c8db)
|
|
|
79b470 |
|
|
|
79b470 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1749518
|
|
|
79b470 |
|
|
|
79b470 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
79b470 |
Message-Id: <e8488a2e49fa251dd0e2ab51f5ab627e3b265440.1602087923.git.mprivozn@redhat.com>
|
|
|
79b470 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
79b470 |
---
|
|
|
79b470 |
src/conf/domain_conf.c | 3 ++
|
|
|
79b470 |
src/conf/numa_conf.c | 99 ++++++++++++++++++++++++++++++++++++++++++
|
|
|
79b470 |
src/conf/numa_conf.h | 1 +
|
|
|
79b470 |
3 files changed, 103 insertions(+)
|
|
|
79b470 |
|
|
|
79b470 |
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
|
79b470 |
index 3229d5ec95..f41559f33e 100644
|
|
|
79b470 |
--- a/src/conf/domain_conf.c
|
|
|
79b470 |
+++ b/src/conf/domain_conf.c
|
|
|
79b470 |
@@ -7144,6 +7144,9 @@ virDomainDefValidateInternal(const virDomainDef *def,
|
|
|
79b470 |
if (virDomainDefCputuneValidate(def) < 0)
|
|
|
79b470 |
return -1;
|
|
|
79b470 |
|
|
|
79b470 |
+ if (virDomainNumaDefValidate(def->numa) < 0)
|
|
|
79b470 |
+ return -1;
|
|
|
79b470 |
+
|
|
|
79b470 |
return 0;
|
|
|
79b470 |
}
|
|
|
79b470 |
|
|
|
79b470 |
diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c
|
|
|
79b470 |
index 5c764190c3..c90fb01bb6 100644
|
|
|
79b470 |
--- a/src/conf/numa_conf.c
|
|
|
79b470 |
+++ b/src/conf/numa_conf.c
|
|
|
79b470 |
@@ -1365,6 +1365,105 @@ virDomainNumaDefFormatXML(virBufferPtr buf,
|
|
|
79b470 |
}
|
|
|
79b470 |
|
|
|
79b470 |
|
|
|
79b470 |
+int
|
|
|
79b470 |
+virDomainNumaDefValidate(const virDomainNuma *def)
|
|
|
79b470 |
+{
|
|
|
79b470 |
+ size_t i;
|
|
|
79b470 |
+ size_t j;
|
|
|
79b470 |
+
|
|
|
79b470 |
+ if (!def)
|
|
|
79b470 |
+ return 0;
|
|
|
79b470 |
+
|
|
|
79b470 |
+ for (i = 0; i < def->nmem_nodes; i++) {
|
|
|
79b470 |
+ const virDomainNumaNode *node = &def->mem_nodes[i];
|
|
|
79b470 |
+ g_autoptr(virBitmap) levelsSeen = virBitmapNewEmpty();
|
|
|
79b470 |
+
|
|
|
79b470 |
+ for (j = 0; j < node->ncaches; j++) {
|
|
|
79b470 |
+ const virDomainNumaCache *cache = &node->caches[j];
|
|
|
79b470 |
+
|
|
|
79b470 |
+ /* Relax this if there's ever fourth layer of cache */
|
|
|
79b470 |
+ if (cache->level > 3) {
|
|
|
79b470 |
+ virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
79b470 |
+ _("Ain't nobody heard of that much cache level"));
|
|
|
79b470 |
+ return -1;
|
|
|
79b470 |
+ }
|
|
|
79b470 |
+
|
|
|
79b470 |
+ if (virBitmapIsBitSet(levelsSeen, cache->level)) {
|
|
|
79b470 |
+ virReportError(VIR_ERR_XML_ERROR,
|
|
|
79b470 |
+ _("Cache level '%u' already defined"),
|
|
|
79b470 |
+ cache->level);
|
|
|
79b470 |
+ return -1;
|
|
|
79b470 |
+ }
|
|
|
79b470 |
+
|
|
|
79b470 |
+ if (virBitmapSetBitExpand(levelsSeen, cache->level))
|
|
|
79b470 |
+ return -1;
|
|
|
79b470 |
+ }
|
|
|
79b470 |
+ }
|
|
|
79b470 |
+
|
|
|
79b470 |
+ for (i = 0; i < def->ninterconnects; i++) {
|
|
|
79b470 |
+ const virDomainNumaInterconnect *l = &def->interconnects[i];
|
|
|
79b470 |
+
|
|
|
79b470 |
+ if (l->initiator >= def->nmem_nodes) {
|
|
|
79b470 |
+ virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
79b470 |
+ _("'initiator' refers to a non-existent NUMA node"));
|
|
|
79b470 |
+ return -1;
|
|
|
79b470 |
+ }
|
|
|
79b470 |
+
|
|
|
79b470 |
+ if (l->target >= def->nmem_nodes) {
|
|
|
79b470 |
+ virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
79b470 |
+ _("'target' refers to a non-existent NUMA node"));
|
|
|
79b470 |
+ return -1;
|
|
|
79b470 |
+ }
|
|
|
79b470 |
+
|
|
|
79b470 |
+ if (!def->mem_nodes[l->initiator].cpumask) {
|
|
|
79b470 |
+ virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
79b470 |
+ _("NUMA nodes without CPUs can't be initiator"));
|
|
|
79b470 |
+ return -1;
|
|
|
79b470 |
+ }
|
|
|
79b470 |
+
|
|
|
79b470 |
+ if (l->cache > 0) {
|
|
|
79b470 |
+ for (j = 0; j < def->mem_nodes[l->target].ncaches; j++) {
|
|
|
79b470 |
+ const virDomainNumaCache *cache = def->mem_nodes[l->target].caches;
|
|
|
79b470 |
+
|
|
|
79b470 |
+ if (l->cache == cache->level)
|
|
|
79b470 |
+ break;
|
|
|
79b470 |
+ }
|
|
|
79b470 |
+
|
|
|
79b470 |
+ if (j == def->mem_nodes[l->target].ncaches) {
|
|
|
79b470 |
+ virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
79b470 |
+ _("'cache' refers to a non-existent NUMA node cache"));
|
|
|
79b470 |
+ return -1;
|
|
|
79b470 |
+ }
|
|
|
79b470 |
+ }
|
|
|
79b470 |
+
|
|
|
79b470 |
+ for (j = 0; j < i; j++) {
|
|
|
79b470 |
+ const virDomainNumaInterconnect *ll = &def->interconnects[j];
|
|
|
79b470 |
+
|
|
|
79b470 |
+ if (l->type == ll->type &&
|
|
|
79b470 |
+ l->initiator == ll->initiator &&
|
|
|
79b470 |
+ l->target == ll->target &&
|
|
|
79b470 |
+ l->cache == ll->cache &&
|
|
|
79b470 |
+ l->accessType == ll->accessType) {
|
|
|
79b470 |
+ virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
79b470 |
+ _("Duplicate info for NUMA latencies"));
|
|
|
79b470 |
+ return -1;
|
|
|
79b470 |
+ }
|
|
|
79b470 |
+
|
|
|
79b470 |
+
|
|
|
79b470 |
+ if (l->initiator != l->target &&
|
|
|
79b470 |
+ l->initiator == ll->target &&
|
|
|
79b470 |
+ l->target == ll->initiator) {
|
|
|
79b470 |
+ virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
79b470 |
+ _("Link already defined"));
|
|
|
79b470 |
+ return -1;
|
|
|
79b470 |
+ }
|
|
|
79b470 |
+ }
|
|
|
79b470 |
+ }
|
|
|
79b470 |
+
|
|
|
79b470 |
+ return 0;
|
|
|
79b470 |
+}
|
|
|
79b470 |
+
|
|
|
79b470 |
+
|
|
|
79b470 |
unsigned int
|
|
|
79b470 |
virDomainNumaGetCPUCountTotal(virDomainNumaPtr numa)
|
|
|
79b470 |
{
|
|
|
79b470 |
diff --git a/src/conf/numa_conf.h b/src/conf/numa_conf.h
|
|
|
79b470 |
index 5043c5a6d4..2963004c94 100644
|
|
|
79b470 |
--- a/src/conf/numa_conf.h
|
|
|
79b470 |
+++ b/src/conf/numa_conf.h
|
|
|
79b470 |
@@ -217,5 +217,6 @@ bool virDomainNumatuneNodeSpecified(virDomainNumaPtr numatune,
|
|
|
79b470 |
|
|
|
79b470 |
int virDomainNumaDefParseXML(virDomainNumaPtr def, xmlXPathContextPtr ctxt);
|
|
|
79b470 |
int virDomainNumaDefFormatXML(virBufferPtr buf, virDomainNumaPtr def);
|
|
|
79b470 |
+int virDomainNumaDefValidate(const virDomainNuma *def);
|
|
|
79b470 |
|
|
|
79b470 |
unsigned int virDomainNumaGetCPUCountTotal(virDomainNumaPtr numa);
|
|
|
79b470 |
--
|
|
|
79b470 |
2.29.2
|
|
|
79b470 |
|