提交 6074f831 编写于 作者: K Kothapally Madhu Pavan 提交者: Michal Privoznik

virsh: Fix to list online cpus using virsh capabilities

Virsh capabilities will list offline cpus as online when
libvirt is compiled with numactl option disabled. This
fix will list correct set of online cpus.
上级 61139c44
...@@ -1641,26 +1641,36 @@ nodeCapsInitNUMAFake(virCapsPtr caps ATTRIBUTE_UNUSED) ...@@ -1641,26 +1641,36 @@ nodeCapsInitNUMAFake(virCapsPtr caps ATTRIBUTE_UNUSED)
virCapsHostNUMACellCPUPtr cpus; virCapsHostNUMACellCPUPtr cpus;
int ncpus; int ncpus;
int s, c, t; int s, c, t;
int id; int id, cid;
int onlinecpus ATTRIBUTE_UNUSED;
if (nodeGetInfo(&nodeinfo) < 0) if (nodeGetInfo(&nodeinfo) < 0)
return -1; return -1;
ncpus = VIR_NODEINFO_MAXCPUS(nodeinfo); ncpus = VIR_NODEINFO_MAXCPUS(nodeinfo);
onlinecpus = nodeinfo.cpus;
if (VIR_ALLOC_N(cpus, ncpus) < 0) if (VIR_ALLOC_N(cpus, ncpus) < 0)
return -1; return -1;
id = 0; id = cid = 0;
for (s = 0; s < nodeinfo.sockets; s++) { for (s = 0; s < nodeinfo.sockets; s++) {
for (c = 0; c < nodeinfo.cores; c++) { for (c = 0; c < nodeinfo.cores; c++) {
for (t = 0; t < nodeinfo.threads; t++) { for (t = 0; t < nodeinfo.threads; t++) {
cpus[id].id = id; #ifdef __linux__
cpus[id].socket_id = s; if (virNodeGetCpuValue(SYSFS_CPU_PATH, id, "online", 1)) {
cpus[id].core_id = c; #endif
if (!(cpus[id].siblings = virBitmapNew(ncpus))) cpus[cid].id = id;
goto error; cpus[cid].socket_id = s;
ignore_value(virBitmapSetBit(cpus[id].siblings, id)); cpus[cid].core_id = c;
if (!(cpus[cid].siblings = virBitmapNew(ncpus)))
goto error;
ignore_value(virBitmapSetBit(cpus[cid].siblings, id));
cid++;
#ifdef __linux__
}
#endif
id++; id++;
} }
} }
...@@ -1668,7 +1678,11 @@ nodeCapsInitNUMAFake(virCapsPtr caps ATTRIBUTE_UNUSED) ...@@ -1668,7 +1678,11 @@ nodeCapsInitNUMAFake(virCapsPtr caps ATTRIBUTE_UNUSED)
if (virCapabilitiesAddHostNUMACell(caps, 0, if (virCapabilitiesAddHostNUMACell(caps, 0,
nodeinfo.memory, nodeinfo.memory,
#ifdef __linux__
onlinecpus, cpus,
#else
ncpus, cpus, ncpus, cpus,
#endif
0, NULL, 0, NULL,
0, NULL) < 0) 0, NULL) < 0)
goto error; goto error;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册