render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
c480ed
From c59ebd3e7bd1307ef6907a830dc9617eb6fe39b2 Mon Sep 17 00:00:00 2001
c480ed
Message-Id: <c59ebd3e7bd1307ef6907a830dc9617eb6fe39b2@dist-git>
c480ed
From: Michal Privoznik <mprivozn@redhat.com>
c480ed
Date: Tue, 18 Dec 2018 11:47:35 +0100
c480ed
Subject: [PATCH] qemuBuildMemoryBackendProps: Pass @priv instead of its
c480ed
 individual members
c480ed
MIME-Version: 1.0
c480ed
Content-Type: text/plain; charset=UTF-8
c480ed
Content-Transfer-Encoding: 8bit
c480ed
c480ed
https://bugzilla.redhat.com/show_bug.cgi?id=1624223
c480ed
c480ed
So far we have two arguments that we are passing to
c480ed
qemuBuildMemoryBackendProps() and that are taken from domain
c480ed
private data: @qemuCaps and @autoNodeset. In the next commit I
c480ed
will use one more item from there. Therefore, instead of having
c480ed
it as yet another argument to the function, pass pointer to the
c480ed
private data object.
c480ed
c480ed
There is one change in qemuDomainAttachMemory() where previously
c480ed
@autoNodeset was NULL but now is priv->autoNodeset (which may be
c480ed
set). This is safe to do as @autoNodeset is advisory only.
c480ed
c480ed
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
c480ed
Reviewed-by: John Ferlan <jferlan@redhat.com>
c480ed
(cherry picked from commit 9923584c628e160705124ad81d782a7214aac8d3)
c480ed
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
c480ed
c480ed
Conflicts:
c480ed
src/qemu/qemu_command.c: Context mostly, as memfd backend is not
c480ed
                         backported (24b74d187ca).
c480ed
c480ed
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
c480ed
Message-Id: <71d56cdc7e5cdd0c9b664ded2a4cf93e3e9d38b0.1545129996.git.mprivozn@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
---
c480ed
 src/qemu/qemu_command.c | 28 +++++++++++++---------------
c480ed
 src/qemu/qemu_command.h |  3 +--
c480ed
 src/qemu/qemu_hotplug.c |  2 +-
c480ed
 3 files changed, 15 insertions(+), 18 deletions(-)
c480ed
c480ed
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
c480ed
index c06f396b44..fa2b904239 100644
c480ed
--- a/src/qemu/qemu_command.c
c480ed
+++ b/src/qemu/qemu_command.c
c480ed
@@ -3041,22 +3041,21 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
c480ed
  * @backendProps: [out] constructed object
c480ed
  * @alias: alias of the device
c480ed
  * @cfg: qemu driver config object
c480ed
- * @qemuCaps: qemu capabilities object
c480ed
+ * @priv: pointer to domain private object
c480ed
  * @def: domain definition object
c480ed
  * @mem: memory definition object
c480ed
- * @autoNodeset: fallback nodeset in case of automatic NUMA placement
c480ed
  * @force: forcibly use one of the backends
c480ed
  *
c480ed
  * Creates a configuration object that represents memory backend of given guest
c480ed
- * NUMA node (domain @def and @mem). Use @autoNodeset to fine tune the
c480ed
+ * NUMA node (domain @def and @mem). Use @priv->autoNodeset to fine tune the
c480ed
  * placement of the memory on the host NUMA nodes.
c480ed
  *
c480ed
  * By default, if no memory-backend-* object is necessary to fulfil the guest
c480ed
  * configuration value of 1 is returned. This behaviour can be suppressed by
c480ed
  * setting @force to true in which case 0 would be returned.
c480ed
  *
c480ed
- * Then, if one of the two memory-backend-* should be used, the @qemuCaps is
c480ed
- * consulted to check if qemu does support it.
c480ed
+ * Then, if one of the two memory-backend-* should be used, the @priv->qemuCaps
c480ed
+ * is consulted to check if qemu does support it.
c480ed
  *
c480ed
  * Returns: 0 on success,
c480ed
  *          1 on success and if there's no need to use memory-backend-*
c480ed
@@ -3066,10 +3065,9 @@ int
c480ed
 qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
c480ed
                             const char *alias,
c480ed
                             virQEMUDriverConfigPtr cfg,
c480ed
-                            virQEMUCapsPtr qemuCaps,
c480ed
+                            qemuDomainObjPrivatePtr priv,
c480ed
                             virDomainDefPtr def,
c480ed
                             virDomainMemoryDefPtr mem,
c480ed
-                            virBitmapPtr autoNodeset,
c480ed
                             bool force)
c480ed
 {
c480ed
     const char *backendType = "memory-backend-file";
c480ed
@@ -3207,7 +3205,7 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
c480ed
 
c480ed
         if (!mem->nvdimmPath &&
c480ed
             discard == VIR_TRISTATE_BOOL_YES) {
c480ed
-            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD)) {
c480ed
+            if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD)) {
c480ed
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
c480ed
                                _("this QEMU doesn't support memory discard"));
c480ed
                 goto cleanup;
c480ed
@@ -3244,7 +3242,7 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
c480ed
     if (mem->sourceNodes) {
c480ed
         nodemask = mem->sourceNodes;
c480ed
     } else {
c480ed
-        if (virDomainNumatuneMaybeGetNodeset(def->numa, autoNodeset,
c480ed
+        if (virDomainNumatuneMaybeGetNodeset(def->numa, priv->autoNodeset,
c480ed
                                              &nodemask, mem->targetNode) < 0)
c480ed
             goto cleanup;
c480ed
     }
c480ed
@@ -3270,13 +3268,13 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
c480ed
     } else {
c480ed
         /* otherwise check the required capability */
c480ed
         if (STREQ(backendType, "memory-backend-file") &&
c480ed
-            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE)) {
c480ed
+            !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE)) {
c480ed
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
c480ed
                            _("this qemu doesn't support the "
c480ed
                              "memory-backend-file object"));
c480ed
             goto cleanup;
c480ed
         } else if (STREQ(backendType, "memory-backend-ram") &&
c480ed
-                   !virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM)) {
c480ed
+                   !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM)) {
c480ed
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
c480ed
                            _("this qemu doesn't support the "
c480ed
                              "memory-backend-ram object"));
c480ed
@@ -3319,8 +3317,8 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def,
c480ed
     mem.targetNode = cell;
c480ed
     mem.info.alias = alias;
c480ed
 
c480ed
-    if ((rc = qemuBuildMemoryBackendProps(&props, alias, cfg, priv->qemuCaps,
c480ed
-                                          def, &mem, priv->autoNodeset, false)) < 0)
c480ed
+    if ((rc = qemuBuildMemoryBackendProps(&props, alias, cfg,
c480ed
+                                          priv, def, &mem, false)) < 0)
c480ed
         goto cleanup;
c480ed
 
c480ed
     if (virQEMUBuildObjectCommandlineFromJSON(buf, props) < 0)
c480ed
@@ -3356,8 +3354,8 @@ qemuBuildMemoryDimmBackendStr(virBufferPtr buf,
c480ed
     if (virAsprintf(&alias, "mem%s", mem->info.alias) < 0)
c480ed
         goto cleanup;
c480ed
 
c480ed
-    if (qemuBuildMemoryBackendProps(&props, alias, cfg, priv->qemuCaps,
c480ed
-                                    def, mem, priv->autoNodeset, true) < 0)
c480ed
+    if (qemuBuildMemoryBackendProps(&props, alias, cfg,
c480ed
+                                    priv, def, mem, true) < 0)
c480ed
         goto cleanup;
c480ed
 
c480ed
     if (virQEMUBuildObjectCommandlineFromJSON(buf, props) < 0)
c480ed
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
c480ed
index e8cd8ed04e..bf46bde48f 100644
c480ed
--- a/src/qemu/qemu_command.h
c480ed
+++ b/src/qemu/qemu_command.h
c480ed
@@ -125,10 +125,9 @@ int qemuBuildControllerDevStr(const virDomainDef *domainDef,
c480ed
 int qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
c480ed
                                 const char *alias,
c480ed
                                 virQEMUDriverConfigPtr cfg,
c480ed
-                                virQEMUCapsPtr qemuCaps,
c480ed
+                                qemuDomainObjPrivatePtr priv,
c480ed
                                 virDomainDefPtr def,
c480ed
                                 virDomainMemoryDefPtr mem,
c480ed
-                                virBitmapPtr autoNodeset,
c480ed
                                 bool force);
c480ed
 
c480ed
 char *qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem);
c480ed
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
c480ed
index 410cdca3c5..5b9a5683bb 100644
c480ed
--- a/src/qemu/qemu_hotplug.c
c480ed
+++ b/src/qemu/qemu_hotplug.c
c480ed
@@ -2121,7 +2121,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
c480ed
         goto cleanup;
c480ed
 
c480ed
     if (qemuBuildMemoryBackendProps(&props, objalias, cfg,
c480ed
-                                    priv->qemuCaps, vm->def, mem, NULL, true) < 0)
c480ed
+                                    priv, vm->def, mem, true) < 0)
c480ed
         goto cleanup;
c480ed
 
c480ed
     if (qemuProcessBuildDestroyMemoryPaths(driver, vm, mem, true) < 0)
c480ed
-- 
c480ed
2.22.0
c480ed