render / rpms / libvirt

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