render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
404507
From 8af3d229190faed68beda2a1493badc1eb78e108 Mon Sep 17 00:00:00 2001
404507
Message-Id: <8af3d229190faed68beda2a1493badc1eb78e108@dist-git>
404507
From: Michal Privoznik <mprivozn@redhat.com>
404507
Date: Mon, 4 Dec 2017 13:38:50 +0100
404507
Subject: [PATCH] numa: Introduce virDomainNumaNodeDistanceIsUsingDefaults
404507
404507
https://bugzilla.redhat.com/show_bug.cgi?id=1454889
404507
404507
The function returns true/false depending on distance
404507
configuration being present in the domain XML.
404507
404507
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
404507
Reviewed-by: John Ferlan <jferlan@redhat.com>
404507
(cherry picked from commit ab9baab7290a4a009e4e8ddfb63a2ddd19bb8091)
404507
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
404507
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
404507
---
404507
 src/conf/numa_conf.c     | 21 +++++++++++++++++++++
404507
 src/conf/numa_conf.h     |  4 ++++
404507
 src/libvirt_private.syms |  1 +
404507
 3 files changed, 26 insertions(+)
404507
404507
diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c
404507
index c2f0d1ca8c..8fc3b0a196 100644
404507
--- a/src/conf/numa_conf.c
404507
+++ b/src/conf/numa_conf.c
404507
@@ -1137,6 +1137,27 @@ virDomainNumaSetNodeCount(virDomainNumaPtr numa, size_t nmem_nodes)
404507
     return numa->nmem_nodes;
404507
 }
404507
 
404507
+
404507
+bool
404507
+virDomainNumaNodeDistanceIsUsingDefaults(virDomainNumaPtr numa,
404507
+                                         size_t node,
404507
+                                         size_t sibling)
404507
+{
404507
+    if (node >= numa->nmem_nodes ||
404507
+        sibling >= numa->nmem_nodes)
404507
+        return false;
404507
+
404507
+    if (!numa->mem_nodes[node].distances)
404507
+        return true;
404507
+
404507
+    if (numa->mem_nodes[node].distances[sibling].value == LOCAL_DISTANCE ||
404507
+        numa->mem_nodes[node].distances[sibling].value == REMOTE_DISTANCE)
404507
+        return true;
404507
+
404507
+    return false;
404507
+}
404507
+
404507
+
404507
 size_t
404507
 virDomainNumaGetNodeDistance(virDomainNumaPtr numa,
404507
                              size_t node,
404507
diff --git a/src/conf/numa_conf.h b/src/conf/numa_conf.h
404507
index 4655de3aa7..7947fdb219 100644
404507
--- a/src/conf/numa_conf.h
404507
+++ b/src/conf/numa_conf.h
404507
@@ -87,6 +87,10 @@ int virDomainNumatuneMaybeGetNodeset(virDomainNumaPtr numatune,
404507
 
404507
 size_t virDomainNumaGetNodeCount(virDomainNumaPtr numa);
404507
 
404507
+bool virDomainNumaNodeDistanceIsUsingDefaults(virDomainNumaPtr numa,
404507
+                                              size_t node,
404507
+                                              size_t sibling)
404507
+    ATTRIBUTE_NONNULL(1);
404507
 size_t virDomainNumaGetNodeDistance(virDomainNumaPtr numa,
404507
                                     size_t node,
404507
                                     size_t sibling)
404507
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
404507
index 19543e06ae..0449b0185f 100644
404507
--- a/src/libvirt_private.syms
404507
+++ b/src/libvirt_private.syms
404507
@@ -727,6 +727,7 @@ virDomainNumaGetNodeDistance;
404507
 virDomainNumaGetNodeMemoryAccessMode;
404507
 virDomainNumaGetNodeMemorySize;
404507
 virDomainNumaNew;
404507
+virDomainNumaNodeDistanceIsUsingDefaults;
404507
 virDomainNumaSetNodeCount;
404507
 virDomainNumaSetNodeCpumask;
404507
 virDomainNumaSetNodeDistance;
404507
-- 
404507
2.15.1
404507