Setup everything related to disks in one place rather than calling in
from various places.
The change to ordering of the setup steps is necessary since secrets
need the master key to be present.
---
src/qemu/qemu_domain.c | 5 +----
src/qemu/qemu_process.c | 14 +++++++++-----
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index db5af1019..fd78e43e3 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1647,10 +1647,7 @@ qemuDomainSecretPrepare(virConnectPtr conn,
size_t i;
int ret = -1;
- for (i = 0; i < vm->def->ndisks; i++) {
- if (qemuDomainSecretDiskPrepare(conn, priv, vm->def->disks[i]) < 0)
- goto cleanup;
- }
+ /* disk aliases are prepared when preparing disks */
for (i = 0; i < vm->def->nhostdevs; i++) {
if (qemuDomainSecretHostdevPrepare(conn, priv,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 18dd3aa46..6d242b1b5 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5343,6 +5343,7 @@ static int
qemuProcessPrepareDomainStorage(virConnectPtr conn,
virQEMUDriverPtr driver,
virDomainObjPtr vm,
+ qemuDomainObjPrivatePtr priv,
virQEMUDriverConfigPtr cfg,
unsigned int flags)
{
@@ -5363,6 +5364,9 @@ qemuProcessPrepareDomainStorage(virConnectPtr conn,
if (qemuDomainPrepareDiskSourceTLS(disk->src, cfg) < 0)
return -1;
+
+ if (qemuDomainSecretDiskPrepare(conn, priv, disk) < 0)
+ return -1;
}
return 0;
@@ -5467,18 +5471,18 @@ qemuProcessPrepareDomain(virConnectPtr conn,
if (qemuProcessSetupGraphics(driver, vm, flags) < 0)
goto cleanup;
- VIR_DEBUG("Setting up storage");
- if (qemuProcessPrepareDomainStorage(conn, driver, vm, cfg, flags) < 0)
- goto cleanup;
-
VIR_DEBUG("Create domain masterKey");
if (qemuDomainMasterKeyCreate(vm) < 0)
goto cleanup;
+ VIR_DEBUG("Setting up storage");
+ if (qemuProcessPrepareDomainStorage(conn, driver, vm, priv, cfg, flags) < 0)
+ goto cleanup;
+
VIR_DEBUG("Prepare chardev source backends for TLS");
qemuDomainPrepareChardevSource(vm->def, cfg);
- VIR_DEBUG("Add secrets to disks, hostdevs, and chardevs");
+ VIR_DEBUG("Add secrets to hostdevs and chardevs");
if (qemuDomainSecretPrepare(conn, driver, vm) < 0)
goto cleanup;
--
2.14.3