[libvirt] [PATCH v2 1/2] qemuBuildMemoryBackendProps: Pass @priv instead of its individual members

Michal Privoznik mprivozn at redhat.com
Wed Dec 12 12:58:03 UTC 2018


So far we have two arguments that we are passing to
qemuBuildMemoryBackendProps() and that are taken from domain
private data: @qemuCaps and @autoNodeset. In the next commit I
will use one more item from there. Therefore, instead of having
it as yet another argument to the function, pass pointer to the
private data object.

There is one change in qemuDomainAttachMemory() where previously
@autoNodeset was NULL but now is priv->autoNodeset (which may be
set). This is safe to do as @autoNodeset is advisory only.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/qemu/qemu_command.c | 30 ++++++++++++++----------------
 src/qemu/qemu_command.h |  3 +--
 src/qemu/qemu_hotplug.c |  2 +-
 3 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 32ed83f277..01a3141134 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3201,22 +3201,21 @@ qemuBuildMemoryBackendPropsShare(virJSONValuePtr props,
  * @backendProps: [out] constructed object
  * @alias: alias of the device
  * @cfg: qemu driver config object
- * @qemuCaps: qemu capabilities object
+ * @priv: pointer to domain private object
  * @def: domain definition object
  * @mem: memory definition object
- * @autoNodeset: fallback nodeset in case of automatic NUMA placement
  * @force: forcibly use one of the backends
  *
  * Creates a configuration object that represents memory backend of given guest
- * NUMA node (domain @def and @mem). Use @autoNodeset to fine tune the
+ * NUMA node (domain @def and @mem). Use @priv->autoNodeset to fine tune the
  * placement of the memory on the host NUMA nodes.
  *
  * By default, if no memory-backend-* object is necessary to fulfil the guest
  * configuration value of 1 is returned. This behaviour can be suppressed by
  * setting @force to true in which case 0 would be returned.
  *
- * Then, if one of the three memory-backend-* should be used, the @qemuCaps is
- * consulted to check if qemu does support it.
+ * Then, if one of the three memory-backend-* should be used, the @priv->qemuCaps
+ * is consulted to check if qemu does support it.
  *
  * Returns: 0 on success,
  *          1 on success and if there's no need to use memory-backend-*
@@ -3226,10 +3225,9 @@ int
 qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
                             const char *alias,
                             virQEMUDriverConfigPtr cfg,
-                            virQEMUCapsPtr qemuCaps,
+                            qemuDomainObjPrivatePtr priv,
                             virDomainDefPtr def,
                             virDomainMemoryDefPtr mem,
-                            virBitmapPtr autoNodeset,
                             bool force)
 {
     const char *backendType = "memory-backend-file";
@@ -3379,7 +3377,7 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
 
         if (!mem->nvdimmPath &&
             discard == VIR_TRISTATE_BOOL_YES) {
-            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD)) {
+            if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD)) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                                _("this QEMU doesn't support memory discard"));
                 goto cleanup;
@@ -3403,7 +3401,7 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
     if (mem->sourceNodes) {
         nodemask = mem->sourceNodes;
     } else {
-        if (virDomainNumatuneMaybeGetNodeset(def->numa, autoNodeset,
+        if (virDomainNumatuneMaybeGetNodeset(def->numa, priv->autoNodeset,
                                              &nodemask, mem->targetNode) < 0)
             goto cleanup;
     }
@@ -3431,19 +3429,19 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
     } else {
         /* otherwise check the required capability */
         if (STREQ(backendType, "memory-backend-file") &&
-            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE)) {
+            !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("this qemu doesn't support the "
                              "memory-backend-file object"));
             goto cleanup;
         } else if (STREQ(backendType, "memory-backend-ram") &&
-                   !virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM)) {
+                   !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("this qemu doesn't support the "
                              "memory-backend-ram object"));
             goto cleanup;
         } else if (STREQ(backendType, "memory-backend-memory") &&
-                   !virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_MEMFD)) {
+                   !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_MEMORY_MEMFD)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("this qemu doesn't support the "
                              "memory-backend-memfd object"));
@@ -3486,8 +3484,8 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def,
     mem.targetNode = cell;
     mem.info.alias = alias;
 
-    if ((rc = qemuBuildMemoryBackendProps(&props, alias, cfg, priv->qemuCaps,
-                                          def, &mem, priv->autoNodeset, false)) < 0)
+    if ((rc = qemuBuildMemoryBackendProps(&props, alias, cfg,
+                                          priv, def, &mem, false)) < 0)
         goto cleanup;
 
     if (virQEMUBuildObjectCommandlineFromJSON(buf, props) < 0)
@@ -3523,8 +3521,8 @@ qemuBuildMemoryDimmBackendStr(virBufferPtr buf,
     if (virAsprintf(&alias, "mem%s", mem->info.alias) < 0)
         goto cleanup;
 
-    if (qemuBuildMemoryBackendProps(&props, alias, cfg, priv->qemuCaps,
-                                    def, mem, priv->autoNodeset, true) < 0)
+    if (qemuBuildMemoryBackendProps(&props, alias, cfg,
+                                    priv, def, mem, true) < 0)
         goto cleanup;
 
     if (virQEMUBuildObjectCommandlineFromJSON(buf, props) < 0)
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index d382cd592a..5cd744b8bf 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -125,10 +125,9 @@ int qemuBuildControllerDevStr(const virDomainDef *domainDef,
 int qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
                                 const char *alias,
                                 virQEMUDriverConfigPtr cfg,
-                                virQEMUCapsPtr qemuCaps,
+                                qemuDomainObjPrivatePtr priv,
                                 virDomainDefPtr def,
                                 virDomainMemoryDefPtr mem,
-                                virBitmapPtr autoNodeset,
                                 bool force);
 
 char *qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem);
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index c455baeab6..4e795c7859 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2568,7 +2568,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
         goto cleanup;
 
     if (qemuBuildMemoryBackendProps(&props, objalias, cfg,
-                                    priv->qemuCaps, vm->def, mem, NULL, true) < 0)
+                                    priv, vm->def, mem, true) < 0)
         goto cleanup;
 
     if (qemuProcessBuildDestroyMemoryPaths(driver, vm, mem, true) < 0)
-- 
2.19.2




More information about the libvir-list mailing list