mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 18:03:32 +00:00
qemu: Allow forcing read-only mode in qemuDomainStorageSourceAccessModify
Add a new flag which will set the image as read-only even if the image data allows writing. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
3decae00e9
commit
3bb1423883
@ -9216,6 +9216,8 @@ typedef enum {
|
||||
QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_REVOKE = 1 << 0,
|
||||
/* operate on full backing chain rather than single image */
|
||||
QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_CHAIN = 1 << 1,
|
||||
/* force permissions to read-only when allowing */
|
||||
QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_READ_ONLY = 1 << 2,
|
||||
} qemuDomainStorageSourceAccessFlags;
|
||||
|
||||
|
||||
@ -9243,6 +9245,10 @@ qemuDomainStorageSourceAccessModify(virQEMUDriverPtr driver,
|
||||
virErrorPtr orig_err = NULL;
|
||||
bool chain = flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_CHAIN;
|
||||
int rc;
|
||||
bool was_readonly = src->readonly;
|
||||
|
||||
if (flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_READ_ONLY)
|
||||
src->readonly = true;
|
||||
|
||||
/* just tear down the disk access */
|
||||
if (flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_REVOKE) {
|
||||
@ -9292,6 +9298,7 @@ qemuDomainStorageSourceAccessModify(virQEMUDriverPtr driver,
|
||||
VIR_WARN("Unable to release lock on %s", srcstr);
|
||||
|
||||
cleanup:
|
||||
src->readonly = was_readonly;
|
||||
virErrorRestore(&orig_err);
|
||||
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user