mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 19:41:16 +00:00
conf: numa: Add helper to get guest NUMA node count and refactor users
Add an accessor so that a later refactor is simpler.
This commit is contained in:
parent
ba2183a331
commit
be22d07315
@ -13531,7 +13531,7 @@ virDomainDefParseXML(xmlDocPtr xml,
|
|||||||
if (virDomainNumatuneParseXML(def->numa,
|
if (virDomainNumatuneParseXML(def->numa,
|
||||||
def->placement_mode ==
|
def->placement_mode ==
|
||||||
VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC,
|
VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC,
|
||||||
def->cpu ? def->cpu->ncells : 0,
|
virDomainNumaGetNodeCount(def->cpu),
|
||||||
ctxt) < 0)
|
ctxt) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -760,14 +760,15 @@ virDomainNumaDefCPUFormat(virBufferPtr buf,
|
|||||||
{
|
{
|
||||||
virNumaMemAccess memAccess;
|
virNumaMemAccess memAccess;
|
||||||
char *cpustr;
|
char *cpustr;
|
||||||
|
size_t ncells = virDomainNumaGetNodeCount(def);
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (def->ncells == 0)
|
if (ncells == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
virBufferAddLit(buf, "<numa>\n");
|
virBufferAddLit(buf, "<numa>\n");
|
||||||
virBufferAdjustIndent(buf, 2);
|
virBufferAdjustIndent(buf, 2);
|
||||||
for (i = 0; i < def->ncells; i++) {
|
for (i = 0; i < ncells; i++) {
|
||||||
memAccess = def->cells[i].memAccess;
|
memAccess = def->cells[i].memAccess;
|
||||||
|
|
||||||
if (!(cpustr = virBitmapFormat(def->cells[i].cpumask)))
|
if (!(cpustr = virBitmapFormat(def->cells[i].cpumask)))
|
||||||
@ -813,3 +814,13 @@ virDomainNumaNew(void)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
size_t
|
||||||
|
virDomainNumaGetNodeCount(virCPUDefPtr numa)
|
||||||
|
{
|
||||||
|
if (!numa)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return numa->ncells;
|
||||||
|
}
|
||||||
|
@ -86,6 +86,9 @@ int virDomainNumatuneMaybeGetNodeset(virDomainNumaPtr numatune,
|
|||||||
virBitmapPtr *retNodeset,
|
virBitmapPtr *retNodeset,
|
||||||
int cellid);
|
int cellid);
|
||||||
|
|
||||||
|
size_t virDomainNumaGetNodeCount(virCPUDefPtr numa)
|
||||||
|
ATTRIBUTE_NONNULL(1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Formatters
|
* Formatters
|
||||||
*/
|
*/
|
||||||
|
@ -629,6 +629,7 @@ virNodeDeviceObjUnlock;
|
|||||||
# conf/numa_conf.h
|
# conf/numa_conf.h
|
||||||
virDomainNumaEquals;
|
virDomainNumaEquals;
|
||||||
virDomainNumaFree;
|
virDomainNumaFree;
|
||||||
|
virDomainNumaGetNodeCount;
|
||||||
virDomainNumaNew;
|
virDomainNumaNew;
|
||||||
virDomainNumatuneFormatNodeset;
|
virDomainNumatuneFormatNodeset;
|
||||||
virDomainNumatuneFormatXML;
|
virDomainNumatuneFormatXML;
|
||||||
|
@ -7121,7 +7121,7 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
|
|||||||
bool needBackend = false;
|
bool needBackend = false;
|
||||||
int rc;
|
int rc;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
size_t ncells = def->cpu->ncells;
|
size_t ncells = virDomainNumaGetNodeCount(def->cpu);
|
||||||
const long system_page_size = virGetSystemPageSizeKB();
|
const long system_page_size = virGetSystemPageSizeKB();
|
||||||
|
|
||||||
if (virDomainNumatuneHasPerNodeBinding(def->numa) &&
|
if (virDomainNumatuneHasPerNodeBinding(def->numa) &&
|
||||||
@ -8318,7 +8318,7 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|||||||
virCommandAddArg(cmd, "-m");
|
virCommandAddArg(cmd, "-m");
|
||||||
def->mem.max_balloon = VIR_DIV_UP(def->mem.max_balloon, 1024) * 1024;
|
def->mem.max_balloon = VIR_DIV_UP(def->mem.max_balloon, 1024) * 1024;
|
||||||
virCommandAddArgFormat(cmd, "%llu", def->mem.max_balloon / 1024);
|
virCommandAddArgFormat(cmd, "%llu", def->mem.max_balloon / 1024);
|
||||||
if (def->mem.nhugepages && (!def->cpu || !def->cpu->ncells)) {
|
if (def->mem.nhugepages && !virDomainNumaGetNodeCount(def->cpu)) {
|
||||||
const long system_page_size = virGetSystemPageSizeKB();
|
const long system_page_size = virGetSystemPageSizeKB();
|
||||||
char *mem_path = NULL;
|
char *mem_path = NULL;
|
||||||
|
|
||||||
@ -8398,7 +8398,7 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (def->cpu && def->cpu->ncells)
|
if (virDomainNumaGetNodeCount(def->cpu))
|
||||||
if (qemuBuildNumaArgStr(cfg, def, cmd, qemuCaps, nodeset) < 0)
|
if (qemuBuildNumaArgStr(cfg, def, cmd, qemuCaps, nodeset) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user