Prepare the full backing chain by instantiating authentication and TLS
transport secrets and other necessary objects so that we can add the
full backing chain explicitly to qemu. This also includes allocation of
nodenames for the individual backing chain members.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_domain.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 74 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index c98be208f1..526634d819 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -137,6 +137,14 @@ static virClassPtr qemuDomainSaveCookieClass;
static void qemuDomainLogContextDispose(void *obj);
static void qemuDomainSaveCookieDispose(void *obj);
+
+static int
+qemuDomainPrepareStorageSourceBlockdev(virDomainDiskDefPtr disk,
+ virStorageSourcePtr src,
+ qemuDomainObjPrivatePtr priv,
+ virQEMUDriverConfigPtr cfg);
+
+
static int
qemuDomainOnceInit(void)
{
@@ -8638,6 +8646,10 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
if (qemuDomainPrepareDiskSourceData(disk, n, cfg, priv->qemuCaps) < 0)
goto cleanup;
+
+ if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV) &&
+ qemuDomainPrepareStorageSourceBlockdev(disk, n, priv, cfg) < 0)
+ goto cleanup;
}
ret = 0;
@@ -13085,6 +13097,61 @@ qemuDomainPrepareDiskSourceLegacy(virDomainDiskDefPtr disk,
}
+static int
+qemuDomainPrepareStorageSourceBlockdev(virDomainDiskDefPtr disk,
+ virStorageSourcePtr src,
+ qemuDomainObjPrivatePtr priv,
+ virQEMUDriverConfigPtr cfg)
+{
+ src->id = qemuDomainStorageIdNew(priv);
+
+ if (virAsprintf(&src->nodestorage, "libvirt-%u-storage", src->id)
< 0 ||
+ virAsprintf(&src->nodeformat, "libvirt-%u-format", src->id)
< 0)
+ return -1;
+
+ if (qemuDomainValidateStorageSource(src, priv->qemuCaps) < 0)
+ return -1;
+
+ if (qemuDomainPrepareDiskSourceData(disk, src, cfg, priv->qemuCaps) < 0)
+ return -1;
+
+ if (qemuDomainSecretStorageSourcePrepare(priv, src,
+ src->nodestorage,
+ src->nodeformat) < 0)
+ return -1;
+
+ if (qemuDomainPrepareStorageSourcePR(disk->src, priv, src->nodestorage) <
0)
+ return -1;
+
+ if (qemuDomainPrepareStorageSourceTLS(disk->src, cfg, src->nodestorage,
+ priv->qemuCaps) < 0)
+ return -1;
+
+ return 0;
+}
+
+
+static int
+qemuDomainPrepareDiskSourceBlockdev(virDomainDiskDefPtr disk,
+ qemuDomainObjPrivatePtr priv,
+ virQEMUDriverConfigPtr cfg)
+{
+ qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
+ virStorageSourcePtr n;
+
+ if (disk->copy_on_read == VIR_TRISTATE_SWITCH_ON &&
+ virAsprintf(&diskPriv->nodeCopyOnRead, "libvirt-CoR-%s",
disk->dst) < 0)
+ return -1;
+
+ for (n = disk->src; virStorageSourceIsBacking(n); n = n->backingStore) {
+ if (qemuDomainPrepareStorageSourceBlockdev(disk, n, priv, cfg) < 0)
+ return -1;
+ }
+
+ return 0;
+}
+
+
int
qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk,
qemuDomainObjPrivatePtr priv,
@@ -13092,8 +13159,13 @@ qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk,
{
qemuDomainPrepareDiskCachemode(disk);
- if (qemuDomainPrepareDiskSourceLegacy(disk, priv, cfg) < 0)
- return -1;
+ if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) {
+ if (qemuDomainPrepareDiskSourceBlockdev(disk, priv, cfg) < 0)
+ return -1;
+ } else {
+ if (qemuDomainPrepareDiskSourceLegacy(disk, priv, cfg) < 0)
+ return -1;
+ }
return 0;
}
--
2.16.2