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(a)redhat.com>
---
src/qemu/qemu_domain.c | 20 +++++++++++++++++++-
src/qemu/qemu_domain.h | 10 ++++++----
src/qemu/qemu_hotplug.c | 12 ++++++------
3 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index ab96688a65..85e43027d5 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -9224,7 +9224,7 @@ qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr disk,
*
* Returns 0 on success and -1 on error. Reports libvirt error.
*/
-int
+static int
qemuDomainStorageSourceChainAccessPrepare(virQEMUDriverPtr driver,
virDomainObjPtr vm,
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:
*
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 65b0e8c39d..f92f0dbc27 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -770,10 +770,12 @@ int qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr disk,
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK;
-int qemuDomainStorageSourceChainAccessPrepare(virQEMUDriverPtr driver,
- virDomainObjPtr vm,
- virStorageSourcePtr src,
- bool teardown);
+int qemuDomainStorageSourceChainAccessAllow(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ virStorageSourcePtr src);
+int qemuDomainStorageSourceChainAccessRevoke(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ virStorageSourcePtr src);
void qemuDomainStorageSourceAccessRevoke(virQEMUDriverPtr driver,
virDomainObjPtr vm,
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index dd5571aea3..ce5ca015ab 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -809,7 +809,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
if (qemuDomainPrepareDiskSource(disk, priv, cfg) < 0)
goto cleanup;
- if (qemuDomainStorageSourceChainAccessPrepare(driver, vm, newsrc, false) < 0)
+ if (qemuDomainStorageSourceChainAccessAllow(driver, vm, newsrc) < 0)
goto cleanup;
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 */
disk->src = oldsrc;
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 */
virObjectUnref(oldsrc);
@@ -843,7 +843,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
if (sharedAdded)
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 */
@@ -873,7 +873,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
char *devstr = NULL;
VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
- if (qemuDomainStorageSourceChainAccessPrepare(driver, vm, disk->src, false) <
0)
+ if (qemuDomainStorageSourceChainAccessAllow(driver, vm, disk->src) < 0)
goto cleanup;
if (qemuAssignDeviceDiskAlias(vm->def, disk, priv->qemuCaps) < 0)
@@ -935,7 +935,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
virDomainAuditDisk(vm, NULL, disk->src, "attach", false);
error:
- ignore_value(qemuDomainStorageSourceChainAccessPrepare(driver, vm, disk->src,
true));
+ ignore_value(qemuDomainStorageSourceChainAccessRevoke(driver, vm, disk->src));
goto cleanup;
}
@@ -4464,7 +4464,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
qemuDomainReleaseDeviceAddress(vm, &disk->info);
/* tear down disk security access */
- qemuDomainStorageSourceChainAccessPrepare(driver, vm, disk->src, true);
+ qemuDomainStorageSourceChainAccessRevoke(driver, vm, disk->src);
dev.type = VIR_DOMAIN_DEVICE_DISK;
dev.data.disk = disk;
--
2.20.1