提交 76b9aba2 编写于 作者: P Peter Krempa

qemu: Refactor/simplify qemuDomainStorageSourceAccessAllow

Use qemuDomainStorageSourceAccessModify with correct flags to do the
job.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 b1fe51c4
......@@ -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);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册