qemu: process: Setup disk secrets when preparing disks

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.
This commit is contained in:
Peter Krempa 2017-11-08 21:11:47 +01:00
parent 2c82fddca9
commit acc15025ed
2 changed files with 10 additions and 9 deletions

View File

@ -1647,10 +1647,7 @@ qemuDomainSecretPrepare(virConnectPtr conn,
size_t i; size_t i;
int ret = -1; int ret = -1;
for (i = 0; i < vm->def->ndisks; i++) { /* disk secrets are prepared when preparing disks */
if (qemuDomainSecretDiskPrepare(conn, priv, vm->def->disks[i]) < 0)
goto cleanup;
}
for (i = 0; i < vm->def->nhostdevs; i++) { for (i = 0; i < vm->def->nhostdevs; i++) {
if (qemuDomainSecretHostdevPrepare(conn, priv, if (qemuDomainSecretHostdevPrepare(conn, priv,

View File

@ -5343,6 +5343,7 @@ static int
qemuProcessPrepareDomainStorage(virConnectPtr conn, qemuProcessPrepareDomainStorage(virConnectPtr conn,
virQEMUDriverPtr driver, virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
qemuDomainObjPrivatePtr priv,
virQEMUDriverConfigPtr cfg, virQEMUDriverConfigPtr cfg,
unsigned int flags) unsigned int flags)
{ {
@ -5363,6 +5364,9 @@ qemuProcessPrepareDomainStorage(virConnectPtr conn,
if (qemuDomainPrepareDiskSourceTLS(disk->src, cfg) < 0) if (qemuDomainPrepareDiskSourceTLS(disk->src, cfg) < 0)
return -1; return -1;
if (qemuDomainSecretDiskPrepare(conn, priv, disk) < 0)
return -1;
} }
return 0; return 0;
@ -5467,18 +5471,18 @@ qemuProcessPrepareDomain(virConnectPtr conn,
if (qemuProcessSetupGraphics(driver, vm, flags) < 0) if (qemuProcessSetupGraphics(driver, vm, flags) < 0)
goto cleanup; goto cleanup;
VIR_DEBUG("Setting up storage");
if (qemuProcessPrepareDomainStorage(conn, driver, vm, cfg, flags) < 0)
goto cleanup;
VIR_DEBUG("Create domain masterKey"); VIR_DEBUG("Create domain masterKey");
if (qemuDomainMasterKeyCreate(vm) < 0) if (qemuDomainMasterKeyCreate(vm) < 0)
goto cleanup; 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"); VIR_DEBUG("Prepare chardev source backends for TLS");
qemuDomainPrepareChardevSource(vm->def, cfg); 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) if (qemuDomainSecretPrepare(conn, driver, vm) < 0)
goto cleanup; goto cleanup;