Next patch will validate QEMU_CAPS_NUMA_DIST in a new qemu_domain.c function. The code to verify if a NUMA node distance is being set will still be needed in qemuBuildNumaArgStr() though. To avoid code repetition, let's put this logic in a helper to be used in qemuBuildNumaArgStr() and in the new function. Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx> --- src/conf/numa_conf.c | 19 +++++++++++++++++++ src/conf/numa_conf.h | 2 ++ src/libvirt_private.syms | 1 + src/qemu/qemu_command.c | 15 +-------------- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 4bc22ec7d9..6f1257fd8e 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -1188,6 +1188,25 @@ virDomainNumaNodeDistanceIsUsingDefaults(virDomainNumaPtr numa, } +bool +virDomainNumaNodesDistancesAreBeingSet(virDomainNumaPtr numa) +{ + size_t ncells = virDomainNumaGetNodeCount(numa); + size_t i, j; + + for (i = 0; i < ncells; i++) { + for (j = 0; j < ncells; j++) { + if (virDomainNumaNodeDistanceIsUsingDefaults(numa, i, j)) + continue; + + return true; + } + } + + return false; +} + + size_t virDomainNumaGetNodeDistance(virDomainNumaPtr numa, size_t node, diff --git a/src/conf/numa_conf.h b/src/conf/numa_conf.h index e76a09c20c..b1b8e3274d 100644 --- a/src/conf/numa_conf.h +++ b/src/conf/numa_conf.h @@ -89,6 +89,8 @@ bool virDomainNumaNodeDistanceIsUsingDefaults(virDomainNumaPtr numa, size_t node, size_t sibling) ATTRIBUTE_NONNULL(1); +bool virDomainNumaNodesDistancesAreBeingSet(virDomainNumaPtr numa) + ATTRIBUTE_NONNULL(1); size_t virDomainNumaGetNodeDistance(virDomainNumaPtr numa, size_t node, size_t sibling) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 5da5307fa3..df41eb3d16 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -812,6 +812,7 @@ virDomainNumaGetNodeMemoryAccessMode; virDomainNumaGetNodeMemorySize; virDomainNumaNew; virDomainNumaNodeDistanceIsUsingDefaults; +virDomainNumaNodesDistancesAreBeingSet; virDomainNumaSetNodeCount; virDomainNumaSetNodeCpumask; virDomainNumaSetNodeDistance; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 37339d6f0d..7849607b16 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7443,7 +7443,6 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg, int ret = -1; size_t ncells = virDomainNumaGetNodeCount(def->numa); const long system_page_size = virGetSystemPageSizeKB(); - bool numa_distances = false; if (virDomainNumatuneHasPerNodeBinding(def->numa) && !(virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM) || @@ -7537,19 +7536,7 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg, /* If NUMA node distance is specified for at least one pair * of nodes, we have to specify all the distances. Even * though they might be the default ones. */ - for (i = 0; i < ncells; i++) { - for (j = 0; j < ncells; j++) { - if (virDomainNumaNodeDistanceIsUsingDefaults(def->numa, i, j)) - continue; - - numa_distances = true; - break; - } - if (numa_distances) - break; - } - - if (numa_distances) { + if (virDomainNumaNodesDistancesAreBeingSet(def->numa)) { if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_NUMA_DIST)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("setting NUMA distances is not " -- 2.23.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list