[libvirt] [PATCH] qemu: snapshot: Mark file becoming backingStore as read-only

Peter Krempa posted 1 patch 4 years, 4 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/23d8b3ef814b0eab3b9f5c5d4f83d31dedd934d8.1575892235.git.pkrempa@redhat.com
src/qemu/qemu_driver.c | 2 ++
1 file changed, 2 insertions(+)
[libvirt] [PATCH] qemu: snapshot: Mark file becoming backingStore as read-only
Posted by Peter Krempa 4 years, 4 months ago
For any backing file we set 'read-only' to true, but didn't do this when
modifying the recorded backing store when creating external snapshots.

This meant that qemu would attempt to open the backing-file read-write.
This would fail for example when selinux is used as qemu doesn't have
write permission for the backing file.

https://bugzilla.redhat.com/show_bug.cgi?id=1781079

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_driver.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 738e8832cc..96e811a893 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -14659,6 +14659,7 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUDriverPtr driver,
             goto cleanup;

         if (virStorageSourceHasBacking(defdisk->src)) {
+            defdisk->src->readonly = true;
             newsrc->backingStore = g_steal_pointer(&defdisk->src);
         } else {
             virObjectUnref(defdisk->src);
@@ -15510,6 +15511,7 @@ qemuDomainSnapshotDiskUpdateSource(virQEMUDriverPtr driver,
         qemuDomainSnapshotDiskUpdateSourceRenumber(dd->disk->src);

     if (dd->persistdisk) {
+        dd->persistdisk->src->readonly = true;
         dd->persistsrc->backingStore = g_steal_pointer(&dd->persistdisk->src);
         dd->persistdisk->src = g_steal_pointer(&dd->persistsrc);
     }
-- 
2.23.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] qemu: snapshot: Mark file becoming backingStore as read-only
Posted by Ján Tomko 4 years, 4 months ago
On Mon, Dec 09, 2019 at 12:52:04PM +0100, Peter Krempa wrote:
>For any backing file we set 'read-only' to true, but didn't do this when
>modifying the recorded backing store when creating external snapshots.
>
>This meant that qemu would attempt to open the backing-file read-write.
>This would fail for example when selinux is used as qemu doesn't have
>write permission for the backing file.
>
>https://bugzilla.redhat.com/show_bug.cgi?id=1781079
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/qemu/qemu_driver.c | 2 ++
> 1 file changed, 2 insertions(+)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list