mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
qemu: domain: Allow forcing images to read-write in qemuDomainStorageSourceAccessAllow
In commit 76b9aba2ba6 I refactored how the function treats the readonly flag which introduced a bug when we'd not allow to force read-write state for an image. This created problems with blockjobs where we need to temporarily force images to have read-write permissions. Rename QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_READ_ONLY to QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_ONLY and also introduce a complement QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_WRITE which will allow to force write access. https://bugzilla.redhat.com/show_bug.cgi?id=1717768 Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
9961e7799a
commit
4c4953fb37
@ -9305,12 +9305,14 @@ 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,
|
||||
/* force permissions to read-only/read-write when allowing */
|
||||
/* currently does not properly work with QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_CHAIN */
|
||||
QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_ONLY = 1 << 2,
|
||||
QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_WRITE = 1 << 3,
|
||||
/* don't revoke permissions when modification has failed */
|
||||
QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_SKIP_REVOKE = 1 << 3,
|
||||
QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_SKIP_REVOKE = 1 << 4,
|
||||
/* VM already has access to the source and we are just modifying it */
|
||||
QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_MODIFY_ACCESS = 1 << 4,
|
||||
QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_MODIFY_ACCESS = 1 << 5,
|
||||
} qemuDomainStorageSourceAccessFlags;
|
||||
|
||||
|
||||
@ -9344,9 +9346,12 @@ qemuDomainStorageSourceAccessModify(virQEMUDriverPtr driver,
|
||||
bool revoke_namespace = false;
|
||||
bool revoke_lockspace = false;
|
||||
|
||||
if (flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_READ_ONLY)
|
||||
if (flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_ONLY)
|
||||
src->readonly = true;
|
||||
|
||||
if (flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_WRITE)
|
||||
src->readonly = false;
|
||||
|
||||
/* just tear down the disk access */
|
||||
if (flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_REVOKE) {
|
||||
virErrorPreserveLast(&orig_err);
|
||||
@ -9491,7 +9496,9 @@ qemuDomainStorageSourceAccessAllow(virQEMUDriverPtr driver,
|
||||
qemuDomainStorageSourceAccessFlags flags = QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_SKIP_REVOKE;
|
||||
|
||||
if (readonly)
|
||||
flags |= QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_READ_ONLY;
|
||||
flags |= QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_ONLY;
|
||||
else
|
||||
flags |= QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_WRITE;
|
||||
|
||||
if (!newSource)
|
||||
flags |= QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_MODIFY_ACCESS;
|
||||
|
Loading…
x
Reference in New Issue
Block a user