From: John Ferlan Date: Fri, 19 Jul 2013 18:38:45 +0000 (-0400) Subject: qemu: Add source pool auth info to virDomainDiskDef for iSCSI X-Git-Tag: v1.1.1-rc1~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b83556d8e7aa4b2379ab88ea077aabee91e0c1db;p=thirdparty%2Flibvirt.git 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. --- diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 6e6163f677..3e7b78a30f 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -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;