提交 711a8688 编写于 作者: D Daniel Henrique Barboza 提交者: Michal Privoznik

numa_conf.c: add helper functions for cpumap operations

These helpers will be used in an auto-fill feature for incomplete
NUMA topologies in the next patch.
Signed-off-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 4e6e1e2a
......@@ -1372,3 +1372,34 @@ virDomainNumaGetMemorySize(virDomainNumaPtr numa)
return ret;
}
int
virDomainNumaFillCPUsInNode(virDomainNumaPtr numa,
size_t node,
unsigned int maxCpus)
{
g_autoptr(virBitmap) maxCPUsBitmap = virBitmapNew(maxCpus);
size_t i;
if (node >= virDomainNumaGetNodeCount(numa))
return -1;
virBitmapSetAll(maxCPUsBitmap);
for (i = 0; i < numa->nmem_nodes; i++) {
virBitmapPtr nodeCpus = virDomainNumaGetNodeCpumask(numa, i);
if (i == node)
continue;
virBitmapSubtract(maxCPUsBitmap, nodeCpus);
}
if (!virBitmapEqual(numa->mem_nodes[node].cpumask, maxCPUsBitmap)) {
virBitmapFree(numa->mem_nodes[node].cpumask);
numa->mem_nodes[node].cpumask = g_steal_pointer(&maxCPUsBitmap);
}
return 0;
}
......@@ -185,3 +185,6 @@ int virDomainNumaDefCPUParseXML(virDomainNumaPtr def, xmlXPathContextPtr ctxt);
int virDomainNumaDefCPUFormatXML(virBufferPtr buf, virDomainNumaPtr def);
unsigned int virDomainNumaGetCPUCountTotal(virDomainNumaPtr numa);
int virDomainNumaFillCPUsInNode(virDomainNumaPtr numa, size_t node,
unsigned int maxCpus);
......@@ -834,6 +834,7 @@ virDomainMemoryAccessTypeFromString;
virDomainMemoryAccessTypeToString;
virDomainNumaCheckABIStability;
virDomainNumaEquals;
virDomainNumaFillCPUsInNode;
virDomainNumaFree;
virDomainNumaGetCPUCountTotal;
virDomainNumaGetMaxCPUID;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册