1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

qemu: command: Make qemuBuildMemoryBackendStr usable without NUMA

Make the function usable so that -1 can be passed to it as cell ID so
that we can later enable memory hotplug on non-NUMA guests for certain
architectures.
This commit is contained in:
Peter Krempa 2015-10-07 14:17:43 +02:00
parent ba08d16d6c
commit 0621f15ac7

View File

@ -4965,7 +4965,8 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
* qemuBuildMemoryBackendStr:
* @size: size of the memory device in kibibytes
* @pagesize: size of the requested memory page in KiB, 0 for default
* @guestNode: NUMA node in the guest that the memory object will be attached to
* @guestNode: NUMA node in the guest that the memory object will be attached
* to, or -1 if NUMA is not used in the guest
* @hostNodes: map of host nodes to alloc the memory in, NULL for default
* @autoNodeset: fallback nodeset in case of automatic numa placement
* @def: domain definition object
@ -5011,19 +5012,19 @@ qemuBuildMemoryBackendStr(unsigned long long size,
*backendProps = NULL;
*backendType = NULL;
/* memory devices could provide a invalid guest node */
if (guestNode >= virDomainNumaGetNodeCount(def->numa)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("can't add memory backend for guest node '%d' as "
"the guest has only '%zu' NUMA nodes configured"),
guestNode, virDomainNumaGetNodeCount(def->numa));
return -1;
if (guestNode >= 0) {
/* memory devices could provide a invalid guest node */
if (guestNode >= virDomainNumaGetNodeCount(def->numa)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("can't add memory backend for guest node '%d' as "
"the guest has only '%zu' NUMA nodes configured"),
guestNode, virDomainNumaGetNodeCount(def->numa));
return -1;
}
memAccess = virDomainNumaGetNodeMemoryAccessMode(def->numa, guestNode);
}
if (!(props = virJSONValueNewObject()))
return -1;
memAccess = virDomainNumaGetNodeMemoryAccessMode(def->numa, guestNode);
if (virDomainNumatuneGetMode(def->numa, guestNode, &mode) < 0 &&
virDomainNumatuneGetMode(def->numa, -1, &mode) < 0)
mode = VIR_DOMAIN_NUMATUNE_MEM_STRICT;
@ -5040,6 +5041,10 @@ qemuBuildMemoryBackendStr(unsigned long long size,
continue;
}
/* just find the master hugepage in case we don't use NUMA */
if (guestNode < 0)
continue;
if (virBitmapGetBit(hugepage->nodemask, guestNode,
&thisHugepage) < 0) {
/* Ignore this error. It's not an error after all. Well,
@ -5073,6 +5078,9 @@ qemuBuildMemoryBackendStr(unsigned long long size,
hugepage = NULL;
}
if (!(props = virJSONValueNewObject()))
return -1;
if (pagesize || hugepage) {
if (pagesize) {
/* Now lets see, if the huge page we want to use is even mounted