提交 be50137a 编写于 作者: P Peter Krempa

qemu: domain: Unify disk source prepare steps

Aggregate setup of various aspects of a disk source (secrets, TLS, ...)
into one function so that we don't need to call multiple across the code
base.
上级 7aa8a9a6
......@@ -1450,7 +1450,7 @@ qemuDomainSecretStorageSourcePrepare(virConnectPtr conn,
* Returns 0 on success, -1 on failure
*/
int
static int
qemuDomainSecretDiskPrepare(virConnectPtr conn,
qemuDomainObjPrivatePtr priv,
virDomainDiskDefPtr disk)
......@@ -8008,7 +8008,7 @@ qemuDomainPrepareChardevSource(virDomainDefPtr def,
*
* Returns 0 on success, -1 on bad config/failure
*/
int
static int
qemuDomainPrepareDiskSourceTLS(virStorageSourcePtr src,
virQEMUDriverConfigPtr cfg)
{
......@@ -10506,3 +10506,19 @@ qemuDomainCheckMigrationCapabilities(virQEMUDriverPtr driver,
virStringListFree(caps);
return ret;
}
int
qemuDomainPrepareDiskSource(virConnectPtr conn,
virDomainDiskDefPtr disk,
qemuDomainObjPrivatePtr priv,
virQEMUDriverConfigPtr cfg)
{
if (qemuDomainPrepareDiskSourceTLS(disk->src, cfg) < 0)
return -1;
if (qemuDomainSecretDiskPrepare(conn, priv, disk) < 0)
return -1;
return 0;
}
......@@ -839,11 +839,6 @@ qemuDomainSecretInfoTLSNew(virConnectPtr conn,
const char *srcAlias,
const char *secretUUID);
int qemuDomainSecretDiskPrepare(virConnectPtr conn,
qemuDomainObjPrivatePtr priv,
virDomainDiskDefPtr disk)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
void qemuDomainSecretHostdevDestroy(virDomainHostdevDefPtr disk)
ATTRIBUTE_NONNULL(1);
......@@ -886,11 +881,6 @@ void qemuDomainPrepareChardevSource(virDomainDefPtr def,
virQEMUDriverConfigPtr cfg)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
int
qemuDomainPrepareDiskSourceTLS(virStorageSourcePtr src,
virQEMUDriverConfigPtr cfg)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
int qemuDomainPrepareShmemChardev(virDomainShmemDefPtr shmem)
ATTRIBUTE_NONNULL(1);
......@@ -1011,4 +1001,10 @@ qemuDomainCheckMigrationCapabilities(virQEMUDriverPtr driver,
virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob);
int
qemuDomainPrepareDiskSource(virConnectPtr conn,
virDomainDiskDefPtr disk,
qemuDomainObjPrivatePtr priv,
virQEMUDriverConfigPtr cfg);
#endif /* __QEMU_DOMAIN_H__ */
......@@ -384,7 +384,7 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn,
if (qemuAssignDeviceDiskAlias(vm->def, disk, priv->qemuCaps) < 0)
goto error;
if (qemuDomainSecretDiskPrepare(conn, priv, disk) < 0)
if (qemuDomainPrepareDiskSource(conn, disk, priv, cfg) < 0)
goto error;
srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
......@@ -401,9 +401,6 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn,
if (encinfo && qemuBuildSecretInfoProps(encinfo, &encobjProps) < 0)
goto error;
if (qemuDomainPrepareDiskSourceTLS(disk->src, cfg) < 0)
goto error;
if (disk->src->haveTLS &&
qemuDomainAddDiskSrcTLSObject(driver, vm, disk->src,
disk->info.alias) < 0)
......
......@@ -5388,10 +5388,7 @@ qemuProcessPrepareDomainStorage(virConnectPtr conn,
continue;
}
if (qemuDomainPrepareDiskSourceTLS(disk->src, cfg) < 0)
return -1;
if (qemuDomainSecretDiskPrepare(conn, priv, disk) < 0)
if (qemuDomainPrepareDiskSource(conn, disk, priv, cfg) < 0)
return -1;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册