Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/conf/domain_conf.c | 39 +++++++++++++++++++++++++++++++++++++++
src/conf/domain_conf.h | 4 ++++
src/libvirt_private.syms | 1 +
3 files changed, 44 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 352ba92..fef956c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19879,3 +19879,42 @@ virDomainObjSetMetadata(virDomainObjPtr vm,
return 0;
}
+
+int
+virDomainGetMemsForGuestCpu(virDomainDefPtr def,
+ size_t cpuid,
+ char **nodemask)
+{
+ ssize_t i = 0;
+
+ *nodemask = NULL;
+
+ /* nothing to do with no per-node settings */
+ if (!def->numatune.nmem_nodes)
+ return 0;
+
+ /* !!(def->numatune.nmem_nodes) -> !!(def->cpu) */
+ for (i = 0; i < def->cpu->ncells; i++) {
+ bool result = false;
+
+ if (virBitmapGetBit(def->cpu->cells[i].cpumask, cpuid, &result) < 0)
{
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Problem accessing domain's "
+ "NUMA cell information"));
+ return -1;
+ }
+ if (!result)
+ continue;
+
+ if (def->numatune.mem_nodes[i].mode != VIR_DOMAIN_NUMATUNE_MEM_STRICT)
+ return 0;
+
+ *nodemask = virBitmapFormat(def->numatune.mem_nodes[i].nodemask);
+ if (!*nodemask)
+ return -1;
+
+ return 0;
+ }
+
+ return 0;
+}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 2de807d..b6e0765 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2711,4 +2711,8 @@ int virDomainObjSetMetadata(virDomainObjPtr vm,
const char *configDir,
unsigned int flags);
+int virDomainGetMemsForGuestCpu(virDomainDefPtr def,
+ size_t cpuid,
+ char **nodemask);
+
#endif /* __DOMAIN_CONF_H */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index d73a9f5..88eae2f 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -244,6 +244,7 @@ virDomainFSTypeToString;
virDomainFSWrpolicyTypeFromString;
virDomainFSWrpolicyTypeToString;
virDomainGetFilesystemForTarget;
+virDomainGetMemsForGuestCpu;
virDomainGraphicsAuthConnectedTypeFromString;
virDomainGraphicsAuthConnectedTypeToString;
virDomainGraphicsDefFree;
--
2.0.0