提交 b83556d8 编写于 作者: J John Ferlan

qemu: Add source pool auth info to virDomainDiskDef for iSCSI

During qemuTranslateDiskSourcePool() execution, if the srcpool has been
defined with authentication information, then for iSCSI pools copy the
authentication and host information to virDomainDiskDef.
上级 29c2208c
......@@ -1186,6 +1186,58 @@ cleanup:
return ret;
}
static int
qemuTranslateDiskSourcePoolAuth(virDomainDiskDefPtr def,
virStoragePoolDefPtr pooldef)
{
int ret = -1;
/* Only necessary when authentication set */
if (pooldef->source.authType == VIR_STORAGE_POOL_AUTH_NONE) {
ret = 0;
goto cleanup;
}
/* Copy the authentication information from the storage pool
* into the virDomainDiskDef
*/
if (pooldef->source.authType == VIR_STORAGE_POOL_AUTH_CHAP) {
if (VIR_STRDUP(def->auth.username,
pooldef->source.auth.chap.username) < 0)
goto cleanup;
if (pooldef->source.auth.chap.secret.uuidUsable) {
def->auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_UUID;
memcpy(def->auth.secret.uuid,
pooldef->source.auth.chap.secret.uuid,
VIR_UUID_BUFLEN);
} else {
if (VIR_STRDUP(def->auth.secret.usage,
pooldef->source.auth.chap.secret.usage) < 0)
goto cleanup;
def->auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_USAGE;
}
} else if (pooldef->source.authType == VIR_STORAGE_POOL_AUTH_CEPHX) {
if (VIR_STRDUP(def->auth.username,
pooldef->source.auth.cephx.username) < 0)
goto cleanup;
if (pooldef->source.auth.cephx.secret.uuidUsable) {
def->auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_UUID;
memcpy(def->auth.secret.uuid,
pooldef->source.auth.cephx.secret.uuid,
VIR_UUID_BUFLEN);
} else {
if (VIR_STRDUP(def->auth.secret.usage,
pooldef->source.auth.cephx.secret.usage) < 0)
goto cleanup;
def->auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_USAGE;
}
}
ret = 0;
cleanup:
return ret;
}
int
qemuTranslateDiskSourcePool(virConnectPtr conn,
virDomainDiskDefPtr def)
......@@ -1254,6 +1306,9 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
if (!(def->src = virStorageVolGetPath(vol)))
goto cleanup;
}
if (qemuTranslateDiskSourcePoolAuth(def, pooldef) < 0)
goto cleanup;
} else {
if (!(def->src = virStorageVolGetPath(vol)))
goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册