qemu: Split entry points to qemuDomainStorageSourceChainAccessPrepare

Introduce qemuDomainStorageSourceChainAccess(Allow|Revoke) as entry
points to qemuDomainStorageSourceChainAccessPrepare for symmetry with
the functions for single backing chain elements.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2019-04-18 10:18:51 +02:00
parent 3d36d666f8
commit 45b9ec5b09
3 changed files with 31 additions and 11 deletions

View File

@ -9224,7 +9224,7 @@ qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr disk,
* *
* Returns 0 on success and -1 on error. Reports libvirt error. * Returns 0 on success and -1 on error. Reports libvirt error.
*/ */
int static int
qemuDomainStorageSourceChainAccessPrepare(virQEMUDriverPtr driver, qemuDomainStorageSourceChainAccessPrepare(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virStorageSourcePtr src, virStorageSourcePtr src,
@ -9279,6 +9279,24 @@ qemuDomainStorageSourceChainAccessPrepare(virQEMUDriverPtr driver,
} }
int
qemuDomainStorageSourceChainAccessAllow(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virStorageSourcePtr src)
{
return qemuDomainStorageSourceChainAccessPrepare(driver, vm, src, false);
}
int
qemuDomainStorageSourceChainAccessRevoke(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virStorageSourcePtr src)
{
return qemuDomainStorageSourceChainAccessPrepare(driver, vm, src, true);
}
/** /**
* qemuDomainStorageSourceAccessRevoke: * qemuDomainStorageSourceAccessRevoke:
* *

View File

@ -770,10 +770,12 @@ int qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr disk,
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK; ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK;
int qemuDomainStorageSourceChainAccessPrepare(virQEMUDriverPtr driver, int qemuDomainStorageSourceChainAccessAllow(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virStorageSourcePtr src, virStorageSourcePtr src);
bool teardown); int qemuDomainStorageSourceChainAccessRevoke(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virStorageSourcePtr src);
void qemuDomainStorageSourceAccessRevoke(virQEMUDriverPtr driver, void qemuDomainStorageSourceAccessRevoke(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,

View File

@ -809,7 +809,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
if (qemuDomainPrepareDiskSource(disk, priv, cfg) < 0) if (qemuDomainPrepareDiskSource(disk, priv, cfg) < 0)
goto cleanup; goto cleanup;
if (qemuDomainStorageSourceChainAccessPrepare(driver, vm, newsrc, false) < 0) if (qemuDomainStorageSourceChainAccessAllow(driver, vm, newsrc) < 0)
goto cleanup; goto cleanup;
if (qemuHotplugAttachManagedPR(driver, vm, newsrc, QEMU_ASYNC_JOB_NONE) < 0) if (qemuHotplugAttachManagedPR(driver, vm, newsrc, QEMU_ASYNC_JOB_NONE) < 0)
@ -828,7 +828,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
/* remove the old source from shared device list */ /* remove the old source from shared device list */
disk->src = oldsrc; disk->src = oldsrc;
ignore_value(qemuRemoveSharedDisk(driver, disk, vm->def->name)); ignore_value(qemuRemoveSharedDisk(driver, disk, vm->def->name));
ignore_value(qemuDomainStorageSourceChainAccessPrepare(driver, vm, oldsrc, true)); ignore_value(qemuDomainStorageSourceChainAccessRevoke(driver, vm, oldsrc));
/* media was changed, so we can remove the old media definition now */ /* media was changed, so we can remove the old media definition now */
virObjectUnref(oldsrc); virObjectUnref(oldsrc);
@ -843,7 +843,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
if (sharedAdded) if (sharedAdded)
ignore_value(qemuRemoveSharedDisk(driver, disk, vm->def->name)); ignore_value(qemuRemoveSharedDisk(driver, disk, vm->def->name));
ignore_value(qemuDomainStorageSourceChainAccessPrepare(driver, vm, newsrc, true)); ignore_value(qemuDomainStorageSourceChainAccessRevoke(driver, vm, newsrc));
} }
/* remove PR manager object if unneeded */ /* remove PR manager object if unneeded */
@ -873,7 +873,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
char *devstr = NULL; char *devstr = NULL;
VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver); VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
if (qemuDomainStorageSourceChainAccessPrepare(driver, vm, disk->src, false) < 0) if (qemuDomainStorageSourceChainAccessAllow(driver, vm, disk->src) < 0)
goto cleanup; goto cleanup;
if (qemuAssignDeviceDiskAlias(vm->def, disk, priv->qemuCaps) < 0) if (qemuAssignDeviceDiskAlias(vm->def, disk, priv->qemuCaps) < 0)
@ -935,7 +935,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
virDomainAuditDisk(vm, NULL, disk->src, "attach", false); virDomainAuditDisk(vm, NULL, disk->src, "attach", false);
error: error:
ignore_value(qemuDomainStorageSourceChainAccessPrepare(driver, vm, disk->src, true)); ignore_value(qemuDomainStorageSourceChainAccessRevoke(driver, vm, disk->src));
goto cleanup; goto cleanup;
} }
@ -4476,7 +4476,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
qemuDomainReleaseDeviceAddress(vm, &disk->info); qemuDomainReleaseDeviceAddress(vm, &disk->info);
/* tear down disk security access */ /* tear down disk security access */
qemuDomainStorageSourceChainAccessPrepare(driver, vm, disk->src, true); qemuDomainStorageSourceChainAccessRevoke(driver, vm, disk->src);
dev.type = VIR_DOMAIN_DEVICE_DISK; dev.type = VIR_DOMAIN_DEVICE_DISK;
dev.data.disk = disk; dev.data.disk = disk;