Separate it so that it deals only with single virStorageSource, so that it can later be reused for full backing chain support. Two aliases are passed since authentication is more relevant to the 'storage backend' whereas encryption is more relevant to the protocol layer. When using node names, the aliases will be different. --- src/qemu/qemu_domain.c | 49 +++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 24ed61bc2..4a2ba1761 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1368,27 +1368,19 @@ qemuDomainDiskHasEncryptionSecret(virStorageSourcePtr src) } -/* qemuDomainSecretDiskPrepare: - * @conn: Pointer to connection - * @priv: pointer to domain private object - * @disk: Pointer to a disk definition - * - * For the right disk, generate the qemuDomainSecretInfo structure. - * - * Returns 0 on success, -1 on failure - */ -int -qemuDomainSecretDiskPrepare(virConnectPtr conn, - qemuDomainObjPrivatePtr priv, - virDomainDiskDefPtr disk) +static int +qemuDomainSecretStorageSourcePrepare(virConnectPtr conn, + qemuDomainObjPrivatePtr priv, + virStorageSourcePtr src, + const char *authalias, + const char *encalias) { - virStorageSourcePtr src = disk->src; qemuDomainStorageSourcePrivatePtr srcPriv; - if (!(disk->src->privateData = qemuDomainStorageSourcePrivateNew())) + if (!(src->privateData = qemuDomainStorageSourcePrivateNew())) return -1; - srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src); + srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src); if (qemuDomainSecretDiskCapable(src)) { virSecretUsageType usageType = VIR_SECRET_USAGE_TYPE_ISCSI; @@ -1397,7 +1389,7 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn, usageType = VIR_SECRET_USAGE_TYPE_CEPH; if (!(srcPriv->secinfo = - qemuDomainSecretInfoNew(conn, priv, disk->info.alias, + qemuDomainSecretInfoNew(conn, priv, authalias, usageType, src->auth->username, &src->auth->seclookupdef, false))) return -1; @@ -1405,7 +1397,7 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn, if (qemuDomainDiskHasEncryptionSecret(src)) { if (!(srcPriv->encinfo = - qemuDomainSecretInfoNew(conn, priv, disk->info.alias, + qemuDomainSecretInfoNew(conn, priv, encalias, VIR_SECRET_USAGE_TYPE_VOLUME, NULL, &src->encryption->secrets[0]->seclookupdef, true))) @@ -1416,6 +1408,27 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn, } +/* qemuDomainSecretDiskPrepare: + * @conn: Pointer to connection + * @priv: pointer to domain private object + * @disk: Pointer to a disk definition + * + * For the right disk, generate the qemuDomainSecretInfo structure. + * + * Returns 0 on success, -1 on failure + */ + +int +qemuDomainSecretDiskPrepare(virConnectPtr conn, + qemuDomainObjPrivatePtr priv, + virDomainDiskDefPtr disk) +{ + return qemuDomainSecretStorageSourcePrepare(conn, priv, disk->src, + disk->info.alias, + disk->info.alias); +} + + /* qemuDomainSecretHostdevDestroy: * @disk: Pointer to a hostdev definition * -- 2.14.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list