[PATCH v2 1/7] qemu: command: Make qemuBuildMemoryBackendStr usable without NUMA

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
---
 src/qemu/qemu_command.c | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 792ada3..5e1e04e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -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;
+        }

-    if (!(props = virJSONValueNewObject()))
-        return -1;
+        memAccess = virDomainNumaGetNodeMemoryAccessMode(def->numa, guestNode);
+    }

-    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
-- 
2.6.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]