Add an accessor so that a later refactor is simpler. --- src/conf/domain_conf.c | 2 +- src/conf/numa_conf.c | 15 +++++++++++++-- src/conf/numa_conf.h | 2 ++ src/libvirt_private.syms | 1 + src/qemu/qemu_command.c | 6 +++--- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ceaf092..d34b9c4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13531,7 +13531,7 @@ virDomainDefParseXML(xmlDocPtr xml, if (virDomainNumatuneParseXML(def->numa, def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC, - def->cpu ? def->cpu->ncells : 0, + virDomainNumaGetNodeCount(def->cpu), ctxt) < 0) goto error; diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 8adec6f..61dfea0 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -760,14 +760,15 @@ virDomainNumaDefCPUFormat(virBufferPtr buf, { virNumaMemAccess memAccess; char *cpustr; + size_t ncells = virDomainNumaGetNodeCount(def); size_t i; - if (def->ncells == 0) + if (ncells == 0) return 0; virBufferAddLit(buf, "<numa>\n"); virBufferAdjustIndent(buf, 2); - for (i = 0; i < def->ncells; i++) { + for (i = 0; i < ncells; i++) { memAccess = def->cells[i].memAccess; if (!(cpustr = virBitmapFormat(def->cells[i].cpumask))) @@ -813,3 +814,13 @@ virDomainNumaNew(void) return ret; } + + +size_t +virDomainNumaGetNodeCount(virCPUDefPtr numa) +{ + if (!numa) + return 0; + + return numa->ncells; +} diff --git a/src/conf/numa_conf.h b/src/conf/numa_conf.h index 69eccf2..55a9fbe 100644 --- a/src/conf/numa_conf.h +++ b/src/conf/numa_conf.h @@ -86,6 +86,8 @@ int virDomainNumatuneMaybeGetNodeset(virDomainNumaPtr numatune, virBitmapPtr *retNodeset, int cellid); +size_t virDomainNumaGetNodeCount(virCPUDefPtr numa); + /* * Formatters */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6a746cf..4ba5fd0 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -629,6 +629,7 @@ virNodeDeviceObjUnlock; # conf/numa_conf.h virDomainNumaEquals; virDomainNumaFree; +virDomainNumaGetNodeCount; virDomainNumaNew; virDomainNumatuneFormatNodeset; virDomainNumatuneFormatXML; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 65d8874..f009570 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7118,7 +7118,7 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg, bool needBackend = false; int rc; int ret = -1; - size_t ncells = def->cpu->ncells; + size_t ncells = virDomainNumaGetNodeCount(def->cpu); const long system_page_size = virGetSystemPageSizeKB(); if (virDomainNumatuneHasPerNodeBinding(def->numa) && @@ -8315,7 +8315,7 @@ qemuBuildCommandLine(virConnectPtr conn, virCommandAddArg(cmd, "-m"); def->mem.max_balloon = VIR_DIV_UP(def->mem.max_balloon, 1024) * 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(); char *mem_path = NULL; @@ -8395,7 +8395,7 @@ qemuBuildCommandLine(virConnectPtr conn, } } - if (def->cpu && def->cpu->ncells) + if (virDomainNumaGetNodeCount(def->cpu)) if (qemuBuildNumaArgStr(cfg, def, cmd, qemuCaps, nodeset) < 0) goto error; -- 2.2.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list