diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 60d4d0751a880cb620fe53c6d316491709f311fb..ca559815f6baa69d2e699db2b77a43ee35243072 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6571,6 +6571,16 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, xmlStrEqual(cur->name, BAD_CAST "auth")) { if (!(authdef = virStorageAuthDefParse(node->doc, cur))) goto error; + /* Shared processing code with storage pools can leave + * this empty, but disk formatting uses it as does command + * creation - so use the secretType to attempt to fill it in. + */ + if (!authdef->secrettype) { + const char *secrettype = + virSecretUsageTypeToString(authdef->secretType); + if (VIR_STRDUP(authdef->secrettype, secrettype) < 0) + goto error; + } if ((auth_secret_usage = virSecretUsageTypeFromString(authdef->secrettype)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -6790,7 +6800,11 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, cur = cur->next; } - if (auth_secret_usage != -1 && auth_secret_usage != expected_secret_usage) { + /* Disk volume types will have authentication information handled in + * virStorageTranslateDiskSourcePool + */ + if (def->src->type != VIR_STORAGE_TYPE_VOLUME && + auth_secret_usage != -1 && auth_secret_usage != expected_secret_usage) { virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid secret type '%s'"), virSecretUsageTypeToString(auth_secret_usage)); diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index ab8675db8179db0e92c397ed4513a3a2016f1171..57060abc4d2f2e9ecc4575550f3748b0a0188299 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -3310,6 +3310,16 @@ virStorageTranslateDiskSourcePool(virConnectPtr conn, &pooldef->source) < 0) goto cleanup; + /* Source pool may not fill in the secrettype field, + * so we need to do so here + */ + if (def->src->auth && !def->src->auth->secrettype) { + const char *secrettype = + virSecretUsageTypeToString(VIR_SECRET_USAGE_TYPE_ISCSI); + if (VIR_STRDUP(def->src->auth->secrettype, secrettype) < 0) + goto cleanup; + } + if (virStorageAddISCSIPoolSourceHost(def, pooldef) < 0) goto cleanup; break;