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