mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
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.
This commit is contained in:
parent
61139c4438
commit
6074f8316c
@ -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)
|
|||||||
|
|
||||||
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user