render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
3e5111
From d68103f77527b1f7a5a3cf1fdc4029a9181e6799 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <d68103f77527b1f7a5a3cf1fdc4029a9181e6799@dist-git>
3e5111
From: Michal Privoznik <mprivozn@redhat.com>
3e5111
Date: Wed, 31 May 2017 15:20:17 +0200
3e5111
Subject: [PATCH] qemu: mkdir memory_backing_dir on startup
3e5111
3e5111
https://bugzilla.redhat.com/show_bug.cgi?id=1214369
3e5111
3e5111
In 48d9e6cdcc and friends we've allowed users to back guest
3e5111
memory by a file inside the host. And in order to keep things
3e5111
manageable the memory_backing_dir variable was introduced to
3e5111
qemu.conf to specify the directory where the files are kept.
3e5111
However, libvirt's policy is that directories are created on
3e5111
domain startup if they don't exist. We've missed this one.
3e5111
3e5111
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
3e5111
(cherry picked from commit 3bab51e05656332f7952958705e59046ce30daa3)
3e5111
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 src/qemu/qemu_driver.c | 12 ++++++++++++
3e5111
 1 file changed, 12 insertions(+)
3e5111
3e5111
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
3e5111
index c31d07a659..b741c1b5a6 100644
3e5111
--- a/src/qemu/qemu_driver.c
3e5111
+++ b/src/qemu/qemu_driver.c
3e5111
@@ -706,6 +706,11 @@ qemuStateInitialize(bool privileged,
3e5111
                              cfg->nvramDir);
3e5111
         goto error;
3e5111
     }
3e5111
+    if (virFileMakePath(cfg->memoryBackingDir) < 0) {
3e5111
+        virReportSystemError(errno, _("Failed to create memory backing dir %s"),
3e5111
+                             cfg->memoryBackingDir);
3e5111
+        goto error;
3e5111
+    }
3e5111
 
3e5111
     qemu_driver->qemuImgBinary = virFindFileInPath("qemu-img");
3e5111
 
3e5111
@@ -830,6 +835,13 @@ qemuStateInitialize(bool privileged,
3e5111
                                  (int) cfg->group);
3e5111
             goto error;
3e5111
         }
3e5111
+        if (chown(cfg->memoryBackingDir, cfg->user, cfg->group) < 0) {
3e5111
+            virReportSystemError(errno,
3e5111
+                                 _("unable to set ownership of '%s' to %d:%d"),
3e5111
+                                 cfg->memoryBackingDir, (int) cfg->user,
3e5111
+                                 (int) cfg->group);
3e5111
+            goto error;
3e5111
+        }
3e5111
 
3e5111
         run_uid = cfg->user;
3e5111
         run_gid = cfg->group;
3e5111
-- 
3e5111
2.13.1
3e5111