Blame SOURCES/libvirt-qemu-Move-memPath-generation-from-memoryBackingDir-to-a-separate-function.patch

404507
From f6772178504ef0c3f02a3d18208bf7ab88402f81 Mon Sep 17 00:00:00 2001
404507
Message-Id: <f6772178504ef0c3f02a3d18208bf7ab88402f81@dist-git>
404507
From: Michal Privoznik <mprivozn@redhat.com>
404507
Date: Thu, 9 Nov 2017 16:06:43 +0100
404507
Subject: [PATCH] qemu: Move memPath generation from memoryBackingDir to a
404507
 separate function
404507
404507
https://bugzilla.redhat.com/show_bug.cgi?id=1461214
404507
404507
In near future we will need more than just a plain VIR_STRDUP().
404507
Better implement that in a separate function and in
404507
qemuBuildMemoryBackendStr() which is complicated enough already.
404507
404507
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
404507
Reviewed-by: John Ferlan <jferlan@redhat.com>
404507
(cherry picked from commit ae1b5d47e5f032a9a11688105e70198a0a160a50)
404507
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
404507
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
404507
---
404507
 src/qemu/qemu_command.c |  2 +-
404507
 src/qemu/qemu_conf.c    | 18 ++++++++++++++++++
404507
 src/qemu/qemu_conf.h    |  3 +++
404507
 3 files changed, 22 insertions(+), 1 deletion(-)
404507
404507
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
404507
index 365555ca87..9f346c3649 100644
404507
--- a/src/qemu/qemu_command.c
404507
+++ b/src/qemu/qemu_command.c
404507
@@ -3439,7 +3439,7 @@ qemuBuildMemoryBackendStr(virJSONValuePtr *backendProps,
404507
         } else {
404507
             /* We can have both pagesize and mem source. If that's the case,
404507
              * prefer hugepages as those are more specific. */
404507
-            if (VIR_STRDUP(memPath, cfg->memoryBackingDir) < 0)
404507
+            if (qemuGetMemoryBackingPath(cfg, &memPath) < 0)
404507
                 goto cleanup;
404507
         }
404507
 
404507
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
404507
index 66f9761eea..3b670a68c5 100644
404507
--- a/src/qemu/qemu_conf.c
404507
+++ b/src/qemu/qemu_conf.c
404507
@@ -1765,3 +1765,21 @@ qemuGetDomainHupageMemPath(const virDomainDef *def,
404507
 
404507
     return 0;
404507
 }
404507
+
404507
+
404507
+/**
404507
+ * qemuGetMemoryBackingPath:
404507
+ * @cfg: the driver config
404507
+ * @memPath: constructed path
404507
+ *
404507
+ * Constructs path to memory backing dir and stores it at @memPath.
404507
+ *
404507
+ * Returns: 0 on success,
404507
+ *          -1 otherwise (with error reported).
404507
+ */
404507
+int
404507
+qemuGetMemoryBackingPath(virQEMUDriverConfigPtr cfg,
404507
+                         char **memPath)
404507
+{
404507
+    return VIR_STRDUP(*memPath, cfg->memoryBackingDir);
404507
+}
404507
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
404507
index 13b6f818a2..9d6866816f 100644
404507
--- a/src/qemu/qemu_conf.h
404507
+++ b/src/qemu/qemu_conf.h
404507
@@ -363,4 +363,7 @@ int qemuGetDomainHupageMemPath(const virDomainDef *def,
404507
                                virQEMUDriverConfigPtr cfg,
404507
                                unsigned long long pagesize,
404507
                                char **memPath);
404507
+
404507
+int qemuGetMemoryBackingPath(virQEMUDriverConfigPtr cfg,
404507
+                             char **memPath);
404507
 #endif /* __QEMUD_CONF_H */
404507
-- 
404507
2.15.0
404507