Use qemuDomainStorageSourceAccessModify with correct flags to do the
job.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_domain.c | 30 ++++++------------------------
1 file changed, 6 insertions(+), 24 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 75d0b34e42..c2b96b825e 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -9399,33 +9399,15 @@ qemuDomainStorageSourceAccessAllow(virQEMUDriverPtr driver,
bool readonly,
bool newSource)
{
- bool was_readonly = elem->readonly;
- virQEMUDriverConfigPtr cfg = NULL;
- int ret = -1;
-
- cfg = virQEMUDriverGetConfig(driver);
-
- elem->readonly = readonly;
-
- if (virDomainLockImageAttach(driver->lockManager, cfg->uri, vm, elem) < 0)
- goto cleanup;
-
- if (newSource &&
- qemuDomainNamespaceSetupDisk(vm, elem) < 0)
- goto cleanup;
-
- if (qemuSetupImageCgroup(vm, elem) < 0)
- goto cleanup;
+ qemuDomainStorageSourceAccessFlags flags =
QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_SKIP_REVOKE;
- if (qemuSecuritySetImageLabel(driver, vm, elem, false) < 0)
- goto cleanup;
+ if (readonly)
+ flags &= QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_READ_ONLY;
- ret = 0;
+ if (!newSource)
+ flags &= QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_MODIFY_ACCESS;
- cleanup:
- elem->readonly = was_readonly;
- virObjectUnref(cfg);
- return ret;
+ return qemuDomainStorageSourceAccessModify(driver, vm, elem, flags);
}
--
2.20.1