]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: mkdir memory_backing_dir on startup
authorMichal Privoznik <mprivozn@redhat.com>
Sat, 27 May 2017 10:24:30 +0000 (12:24 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 31 May 2017 13:13:38 +0000 (15:13 +0200)
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>
docs/news.xml
src/qemu/qemu_driver.c

index 649350a904d3b1951df66627fc89b4c4cc2e1571..8ef9da78b72a813101a110de4a7310c8ef5e0bea 100644 (file)
       </change>
     </section>
     <section title="Bug fixes">
+      <change>
+        <summary>
+          qemu: Create memory_backing_dir on startup
+        </summary>
+        <description>
+          Libvirt's policy is that directories are created on startup if
+          they don't exist. We've missed this one.
+        </description>
+      </change>
     </section>
   </release>
   <release version="v3.3.0" date="2017-05-05">
index 67f54282a07857b42150010a87ca8196b1102290..fcab7ddf82edd2bb5f3e0cb1123fa7140e3deffb 100644 (file)
@@ -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;