]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Move memPath generation from memoryBackingDir to a separate function
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 23 Oct 2017 09:33:06 +0000 (11:33 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 7 Nov 2017 12:43:06 +0000 (13:43 +0100)
In near future we will need more than just a plain VIR_STRDUP().
Better implement that in a separate function and in
qemuBuildMemoryBackendStr() which is complicated enough already.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_command.c
src/qemu/qemu_conf.c
src/qemu/qemu_conf.h

index 8708b79ed0f6f701ec6a0aae8584570f77212de0..175f21b13fd85b030a6356e9f8486626fafd66ce 100644 (file)
@@ -3439,7 +3439,7 @@ qemuBuildMemoryBackendStr(virJSONValuePtr *backendProps,
         } else {
             /* We can have both pagesize and mem source. If that's the case,
              * prefer hugepages as those are more specific. */
-            if (VIR_STRDUP(memPath, cfg->memoryBackingDir) < 0)
+            if (qemuGetMemoryBackingPath(cfg, &memPath) < 0)
                 goto cleanup;
         }
 
index 124d5b77d970e70d146786154f478f7048da7df1..f3cff150378ec7fddde0a637739b3ca1e97989d4 100644 (file)
@@ -1748,3 +1748,21 @@ qemuGetDomainHupageMemPath(const virDomainDef *def,
 
     return 0;
 }
+
+
+/**
+ * qemuGetMemoryBackingPath:
+ * @cfg: the driver config
+ * @memPath: constructed path
+ *
+ * Constructs path to memory backing dir and stores it at @memPath.
+ *
+ * Returns: 0 on success,
+ *          -1 otherwise (with error reported).
+ */
+int
+qemuGetMemoryBackingPath(virQEMUDriverConfigPtr cfg,
+                         char **memPath)
+{
+    return VIR_STRDUP(*memPath, cfg->memoryBackingDir);
+}
index 13b6f818a2de1ae655f5af56925682fb4e4ae19b..9d6866816fa9bba9425aeb81362a15a84551d285 100644 (file)
@@ -363,4 +363,7 @@ int qemuGetDomainHupageMemPath(const virDomainDef *def,
                                virQEMUDriverConfigPtr cfg,
                                unsigned long long pagesize,
                                char **memPath);
+
+int qemuGetMemoryBackingPath(virQEMUDriverConfigPtr cfg,
+                             char **memPath);
 #endif /* __QEMUD_CONF_H */