render / rpms / libvirt

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