1
0
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:
Peter Krempa 2015-02-12 09:37:13 +01:00
parent a3673b225d
commit 6b6166329f
6 changed files with 21 additions and 10 deletions

View File

@ -155,7 +155,6 @@ virCPUDefCopy(const virCPUDef *cpu)
if (!copy->cells[i].cpumask)
goto error;
}
copy->cells_cpus = cpu->cells_cpus;
}
return copy;

View File

@ -117,7 +117,6 @@ struct _virCPUDef {
virCPUFeatureDefPtr features;
size_t ncells;
virCellDefPtr cells;
unsigned int cells_cpus;
};

View File

@ -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"));

View File

@ -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;
}

View File

@ -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__ */

View File

@ -244,7 +244,6 @@ virCapsPtr testQemuCapsInit(void)
host_cpu_features, /* features */
0, /* ncells */
NULL, /* cells */
0, /* cells_cpus */
};
if ((caps = virCapabilitiesNew(host_cpu.arch,