提交 990f4df3 编写于 作者: D Daniel Henrique Barboza 提交者: Cole Robinson

numa_conf: add virDomainNumaNodesDistancesAreBeingSet() helper

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.
Reviewed-by: NCole Robinson <crobinso@redhat.com>
Signed-off-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
上级 2453950d
......@@ -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,
......
......@@ -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)
......
......@@ -820,6 +820,7 @@ virDomainNumaGetNodeMemoryAccessMode;
virDomainNumaGetNodeMemorySize;
virDomainNumaNew;
virDomainNumaNodeDistanceIsUsingDefaults;
virDomainNumaNodesDistancesAreBeingSet;
virDomainNumaSetNodeCount;
virDomainNumaSetNodeCpumask;
virDomainNumaSetNodeDistance;
......
......@@ -7448,7 +7448,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) ||
......@@ -7542,19 +7541,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 "
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册