render / rpms / libvirt

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