From: Pavel Hrdina Date: Mon, 6 Aug 2018 15:52:41 +0000 (+0200) Subject: conf: properly translate iscsi-direct storage pool X-Git-Tag: v4.7.0-rc1~279 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=60360e32eced091efa2ef0980737c2a76d1a8583;p=thirdparty%2Flibvirt.git conf: properly translate iscsi-direct storage pool We cannot simply used the same code as for iscsi storage pool because the default mode is 'host' which is not possible with iscsi-direct. Reviewed-by: Ján Tomko Signed-off-by: Pavel Hrdina --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index adcd8f41b9..b6035d45ab 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -30170,6 +30170,34 @@ virDomainDiskTranslateSourcePoolAuth(virDomainDiskDefPtr def, } +static int +virDomainDiskTranslateISCSIDirect(virDomainDiskDefPtr def, + virStoragePoolDefPtr pooldef) +{ + def->src->srcpool->actualtype = VIR_STORAGE_TYPE_NETWORK; + def->src->protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI; + + if (virDomainDiskTranslateSourcePoolAuth(def, + &pooldef->source) < 0) + return -1; + + /* 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) + return -1; + } + + if (virDomainDiskAddISCSIPoolSourceHost(def, pooldef) < 0) + return -1; + + return 0; +} + + int virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def) { @@ -30280,6 +30308,20 @@ virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def) break; case VIR_STORAGE_POOL_ISCSI_DIRECT: + if (def->startupPolicy) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'startupPolicy' is only valid for " + "'file' type volume")); + goto cleanup; + } + + def->src->srcpool->mode = VIR_STORAGE_SOURCE_POOL_MODE_DIRECT; + + if (virDomainDiskTranslateISCSIDirect(def, pooldef) < 0) + goto cleanup; + + break; + case VIR_STORAGE_POOL_ISCSI: if (def->startupPolicy) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -30300,24 +30342,7 @@ virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def) break; case VIR_STORAGE_SOURCE_POOL_MODE_DIRECT: - def->src->srcpool->actualtype = VIR_STORAGE_TYPE_NETWORK; - def->src->protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI; - - if (virDomainDiskTranslateSourcePoolAuth(def, - &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 (virDomainDiskAddISCSIPoolSourceHost(def, pooldef) < 0) + if (virDomainDiskTranslateISCSIDirect(def, pooldef) < 0) goto cleanup; break; }