[libvirt] [PATCH] qemu: mkdir memory_backing_dir on startup

Michal Privoznik posted 1 patch 6 years, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/ba21af2683481f59b0d0585a520d8c02b9f79af7.1495881897.git.mprivozn@redhat.com
src/qemu/qemu_driver.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
[libvirt] [PATCH] qemu: mkdir memory_backing_dir on startup
Posted by Michal Privoznik 6 years, 11 months ago
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>
---
 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 67f54282a..fcab7ddf8 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.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: mkdir memory_backing_dir on startup
Posted by Andrea Bolognani 6 years, 10 months ago
On Sat, 2017-05-27 at 12:45 +0200, Michal Privoznik wrote:
> 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>
> ---
>  src/qemu/qemu_driver.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)

ACK and safe for freeze.

Wouldn't mind it if you provided a very brief entry in the
release notes, too ;)

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: mkdir memory_backing_dir on startup
Posted by Michal Privoznik 6 years, 10 months ago
On 05/31/2017 03:00 PM, Andrea Bolognani wrote:
> On Sat, 2017-05-27 at 12:45 +0200, Michal Privoznik wrote:
>> 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>
>> ---
>>   src/qemu/qemu_driver.c | 12 ++++++++++++
>>   1 file changed, 12 insertions(+)
> 
> ACK and safe for freeze.
> 
> Wouldn't mind it if you provided a very brief entry in the
> release notes, too ;)
> 

Ah, good point. Keep forgetting about those. Fixed and pushed. Thanks!

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: mkdir memory_backing_dir on startup
Posted by Peter Krempa 6 years, 10 months ago
On Wed, May 31, 2017 at 15:17:24 +0200, Michal Privoznik wrote:
> On 05/31/2017 03:00 PM, Andrea Bolognani wrote:
> > On Sat, 2017-05-27 at 12:45 +0200, Michal Privoznik wrote:
> >> 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>
> >> ---
> >>   src/qemu/qemu_driver.c | 12 ++++++++++++
> >>   1 file changed, 12 insertions(+)
> > 
> > ACK and safe for freeze.
> > 
> > Wouldn't mind it if you provided a very brief entry in the
> > release notes, too ;)
> > 
> 
> Ah, good point. Keep forgetting about those. Fixed and pushed. Thanks!

Please note that we've explicitly stated that changes to the news.xml
file should be in separate patches, which you've ignored.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list