render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
b971b8
From 57493d29be457a3b2a9f0c781e2a82968ec3e01d Mon Sep 17 00:00:00 2001
b971b8
Message-Id: <57493d29be457a3b2a9f0c781e2a82968ec3e01d@dist-git>
b971b8
From: Peter Krempa <pkrempa@redhat.com>
b971b8
Date: Tue, 12 May 2020 17:24:09 +0200
b971b8
Subject: [PATCH] qemuBlockStorageSourceCreateFormat: Force write access when
b971b8
 formatting images
b971b8
MIME-Version: 1.0
b971b8
Content-Type: text/plain; charset=UTF-8
b971b8
Content-Transfer-Encoding: 8bit
b971b8
b971b8
We need qemu to be able to write the newly created images so that it can
b971b8
format them to the specified storage format.
b971b8
b971b8
Force write access by relabelling the images when formatting.
b971b8
b971b8
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
b971b8
Reviewed-by: Ján Tomko <jtomko@redhat.com>
b971b8
(cherry picked from commit 10d62782798cd6e4d472a764575c189247a263b3)
b971b8
b971b8
https://bugzilla.redhat.com/show_bug.cgi?id=1832204
b971b8
Message-Id: <0370c95a3990f94ef136d2de6df63d34989c672a.1589296861.git.pkrempa@redhat.com>
b971b8
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
b971b8
---
b971b8
 src/qemu/qemu_block.c | 12 ++++++++++++
b971b8
 1 file changed, 12 insertions(+)
b971b8
b971b8
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
b971b8
index 6790f05ff7..a44774c237 100644
b971b8
--- a/src/qemu/qemu_block.c
b971b8
+++ b/src/qemu/qemu_block.c
b971b8
@@ -2658,6 +2658,12 @@ qemuBlockStorageSourceCreate(virDomainObjPtr vm,
b971b8
         return -1;
b971b8
     }
b971b8
 
b971b8
+    /* grant write access to read-only images during formatting */
b971b8
+    if (src->readonly &&
b971b8
+        qemuDomainStorageSourceAccessAllow(priv->driver, vm, src, false,
b971b8
+                                           false, true) < 0)
b971b8
+        return -1;
b971b8
+
b971b8
     if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) < 0)
b971b8
         goto cleanup;
b971b8
 
b971b8
@@ -2684,6 +2690,12 @@ qemuBlockStorageSourceCreate(virDomainObjPtr vm,
b971b8
                                            asyncJob) < 0)
b971b8
         goto cleanup;
b971b8
 
b971b8
+    /* revoke write access to read-only images during formatting */
b971b8
+    if (src->readonly &&
b971b8
+        qemuDomainStorageSourceAccessAllow(priv->driver, vm, src, true,
b971b8
+                                           false, true) < 0)
b971b8
+        goto cleanup;
b971b8
+
b971b8
     if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) < 0)
b971b8
         goto cleanup;
b971b8
 
b971b8
-- 
b971b8
2.26.2
b971b8