numa: Introduce virDomainNumaNodeDistanceIsUsingDefaults

The function returns true/false depending on distance
configuration being present in the domain XML.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
Michal Privoznik 2017-11-14 14:28:11 +01:00
parent 0ededbb84e
commit ab9baab729
3 changed files with 26 additions and 0 deletions

View File

@ -1137,6 +1137,27 @@ virDomainNumaSetNodeCount(virDomainNumaPtr numa, size_t nmem_nodes)
return numa->nmem_nodes; return numa->nmem_nodes;
} }
bool
virDomainNumaNodeDistanceIsUsingDefaults(virDomainNumaPtr numa,
size_t node,
size_t sibling)
{
if (node >= numa->nmem_nodes ||
sibling >= numa->nmem_nodes)
return false;
if (!numa->mem_nodes[node].distances)
return true;
if (numa->mem_nodes[node].distances[sibling].value == LOCAL_DISTANCE ||
numa->mem_nodes[node].distances[sibling].value == REMOTE_DISTANCE)
return true;
return false;
}
size_t size_t
virDomainNumaGetNodeDistance(virDomainNumaPtr numa, virDomainNumaGetNodeDistance(virDomainNumaPtr numa,
size_t node, size_t node,

View File

@ -87,6 +87,10 @@ int virDomainNumatuneMaybeGetNodeset(virDomainNumaPtr numatune,
size_t virDomainNumaGetNodeCount(virDomainNumaPtr numa); size_t virDomainNumaGetNodeCount(virDomainNumaPtr numa);
bool virDomainNumaNodeDistanceIsUsingDefaults(virDomainNumaPtr numa,
size_t node,
size_t sibling)
ATTRIBUTE_NONNULL(1);
size_t virDomainNumaGetNodeDistance(virDomainNumaPtr numa, size_t virDomainNumaGetNodeDistance(virDomainNumaPtr numa,
size_t node, size_t node,
size_t sibling) size_t sibling)

View File

@ -726,6 +726,7 @@ virDomainNumaGetNodeDistance;
virDomainNumaGetNodeMemoryAccessMode; virDomainNumaGetNodeMemoryAccessMode;
virDomainNumaGetNodeMemorySize; virDomainNumaGetNodeMemorySize;
virDomainNumaNew; virDomainNumaNew;
virDomainNumaNodeDistanceIsUsingDefaults;
virDomainNumaSetNodeCount; virDomainNumaSetNodeCount;
virDomainNumaSetNodeCpumask; virDomainNumaSetNodeCpumask;
virDomainNumaSetNodeDistance; virDomainNumaSetNodeDistance;