diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index d32277d7fd57dc975fe0c8cdb12e26b33f30116c..6f9c7071c926799812829f44d3fd71f86e8bc63c 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -2671,6 +2671,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; @@ -2697,6 +2703,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;