qemu: blockcopy: sanitize permission handling for 'mirror'

At the point when we want to modify the permissions for the 'mirror' we
know whether it is supposed to have a backing chain or no. Given that
mirror->backingStore is populated only when we'd need to touch it ayways
we can use qemuDomainStorageSourceChainAccessAllow even in place of
qemuDomainStorageSourceAccessAllow used for other cases to simplify the
code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2019-05-15 17:19:11 +02:00
parent 32ec5fee02
commit 47d610e960

View File

@ -17773,17 +17773,8 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
qemuDomainDetermineDiskChain(driver, vm, disk, mirror, true) < 0) qemuDomainDetermineDiskChain(driver, vm, disk, mirror, true) < 0)
goto endjob; goto endjob;
if (flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT &&
virStorageSourceHasBacking(mirror)) {
/* note that we don't really know whether a part of the backing chain
* is shared so rolling this back is not as easy. Thus we do it only
* if there's a backing chain */
if (qemuDomainStorageSourceChainAccessAllow(driver, vm, mirror) < 0) if (qemuDomainStorageSourceChainAccessAllow(driver, vm, mirror) < 0)
goto endjob; goto endjob;
} else {
if (qemuDomainStorageSourceAccessAllow(driver, vm, mirror, false, true) < 0)
goto endjob;
}
if (!(job = qemuBlockJobDiskNew(disk, QEMU_BLOCKJOB_TYPE_COPY, device))) if (!(job = qemuBlockJobDiskNew(disk, QEMU_BLOCKJOB_TYPE_COPY, device)))
goto endjob; goto endjob;
@ -17800,7 +17791,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
if (qemuDomainObjExitMonitor(driver, vm) < 0) if (qemuDomainObjExitMonitor(driver, vm) < 0)
ret = -1; ret = -1;
if (ret < 0) { if (ret < 0) {
qemuDomainStorageSourceAccessRevoke(driver, vm, mirror); qemuDomainStorageSourceChainAccessRevoke(driver, vm, mirror);
goto endjob; goto endjob;
} }