render / rpms / libvirt

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