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