mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
conf: numa: Recalculate rather than remember total NUMA cpu count
It's easier to recalculate the number in the one place it's used as having a separate variable to track it. It will also help with moving the NUMA code to the separate module.
This commit is contained in:
parent
a3673b225d
commit
6b6166329f
@ -155,7 +155,6 @@ virCPUDefCopy(const virCPUDef *cpu)
|
||||
if (!copy->cells[i].cpumask)
|
||||
goto error;
|
||||
}
|
||||
copy->cells_cpus = cpu->cells_cpus;
|
||||
}
|
||||
|
||||
return copy;
|
||||
|
@ -117,7 +117,6 @@ struct _virCPUDef {
|
||||
virCPUFeatureDefPtr features;
|
||||
size_t ncells;
|
||||
virCellDefPtr cells;
|
||||
unsigned int cells_cpus;
|
||||
};
|
||||
|
||||
|
||||
|
@ -13501,7 +13501,7 @@ virDomainDefParseXML(xmlDocPtr xml,
|
||||
goto error;
|
||||
|
||||
if (def->cpu &&
|
||||
def->cpu->cells_cpus > def->maxvcpus) {
|
||||
virDomainNumaGetCPUCountTotal(def->cpu) > def->maxvcpus) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Number of CPUs in <numa> exceeds the"
|
||||
" <vcpu> count"));
|
||||
|
@ -713,7 +713,7 @@ virDomainNumaDefCPUParseXML(virCPUDefPtr def,
|
||||
def->ncells = n;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
int rc, ncpus = 0;
|
||||
int rc;
|
||||
unsigned int cur_cell = i;
|
||||
|
||||
/* cells are in order of parsing or explicitly numbered */
|
||||
@ -748,12 +748,10 @@ virDomainNumaDefCPUParseXML(virCPUDefPtr def,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ncpus = virBitmapParse(tmp, 0, &def->cells[cur_cell].cpumask,
|
||||
VIR_DOMAIN_CPUMASK_LEN);
|
||||
|
||||
if (ncpus <= 0)
|
||||
if (virBitmapParse(tmp, 0, &def->cells[cur_cell].cpumask,
|
||||
VIR_DOMAIN_CPUMASK_LEN) <= 0)
|
||||
goto cleanup;
|
||||
def->cells_cpus += ncpus;
|
||||
|
||||
VIR_FREE(tmp);
|
||||
|
||||
ctxt->node = nodes[i];
|
||||
@ -819,3 +817,16 @@ virDomainNumaDefCPUFormat(virBufferPtr buf,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
unsigned int
|
||||
virDomainNumaGetCPUCountTotal(virCPUDefPtr numa)
|
||||
{
|
||||
size_t i;
|
||||
unsigned int ret = 0;
|
||||
|
||||
for (i = 0; i < numa->ncells; i++)
|
||||
ret += virBitmapCountBits(numa->cells[i].cpumask);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -128,4 +128,7 @@ bool virDomainNumatuneNodeSpecified(virDomainNumaPtr numatune,
|
||||
int virDomainNumaDefCPUParseXML(virCPUDefPtr def, xmlXPathContextPtr ctxt);
|
||||
int virDomainNumaDefCPUFormat(virBufferPtr buf, virCPUDefPtr def);
|
||||
|
||||
unsigned int virDomainNumaGetCPUCountTotal(virCPUDefPtr numa);
|
||||
|
||||
|
||||
#endif /* __NUMA_CONF_H__ */
|
||||
|
@ -244,7 +244,6 @@ virCapsPtr testQemuCapsInit(void)
|
||||
host_cpu_features, /* features */
|
||||
0, /* ncells */
|
||||
NULL, /* cells */
|
||||
0, /* cells_cpus */
|
||||
};
|
||||
|
||||
if ((caps = virCapabilitiesNew(host_cpu.arch,
|
||||
|
Loading…
x
Reference in New Issue
Block a user