Now libvirt supports to parse the iser element in source. It will be used to enable the iSCSI iSER. Signed-off-by: Han Han <hhan@xxxxxxxxxx> --- src/conf/domain_conf.c | 10 ++++++++++ src/util/virstoragefile.c | 17 ++++++++++++++--- src/util/virstoragefile.h | 2 ++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c201fc90..9008eead 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9488,6 +9488,7 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, g_autofree char *haveTLS = NULL; g_autofree char *tlsCfg = NULL; g_autofree char *sslverifystr = NULL; + int iscsiIser = 0; xmlNodePtr tmpnode; if (!(protocol = virXMLPropString(node, "protocol"))) { @@ -9598,6 +9599,12 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, } } + if (src->protocol == VIR_STORAGE_NET_PROTOCOL_ISCSI) { + if ((iscsiIser = virXPathBoolean("boolean(./iser)", ctxt)) == -1) + return -1; + src->iscsiIser = (bool)iscsiIser; + } + return 0; } @@ -24944,6 +24951,9 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf, virStorageSourceInitiatorFormatXML(&src->initiator, childBuf); + if (src->iscsiIser) + virBufferAddLit(childBuf, "<iser/>\n"); + if (src->sslverify != VIR_TRISTATE_BOOL_ABSENT) { virBufferAsprintf(childBuf, "<ssl verify='%s'/>\n", virTristateBoolTypeToString(src->sslverify)); diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 535a94e2..fd687e62 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2805,8 +2805,15 @@ virStorageSourceParseBackingURI(virStorageSourcePtr src, if (!(scheme = virStringSplit(uri->scheme, "+", 2))) return -1; + src->protocol = virStorageNetProtocolTypeFromString(scheme[0]); + + if (STREQ(scheme[0], "iser")) { + src->protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI; + src->iscsiIser = true; + } + if (!scheme[0] || - (src->protocol = virStorageNetProtocolTypeFromString(scheme[0])) < 0) { + src->protocol < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid backing protocol '%s'"), NULLSTR(scheme[0])); @@ -3509,12 +3516,16 @@ virStorageSourceParseBackingJSONiSCSI(virStorageSourcePtr src, src->nhosts = 1; - if (STRNEQ_NULLABLE(transport, "tcp")) { + if (STRNEQ_NULLABLE(transport, "tcp") && + STRNEQ_NULLABLE(transport, "iser")) { virReportError(VIR_ERR_INVALID_ARG, "%s", - _("only TCP transport is supported for iSCSI volumes")); + _("only TCP or iSER transport is supported for iSCSI volumes")); return -1; } + if (STREQ(transport, "iser")) + src->iscsiIser = true; + src->hosts->transport = VIR_STORAGE_NET_HOST_TRANS_TCP; if (!portal) { diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index c68bdc96..e1773ba0 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -383,6 +383,8 @@ struct _virStorageSource { /* these must not be used apart from formatting the output JSON in the qemu driver */ char *ssh_user; bool ssh_host_key_check_disabled; + + bool iscsiIser; /* An optional setting for iSCSI iSER transport*/ }; G_DEFINE_AUTOPTR_CLEANUP_FUNC(virStorageSource, virObjectUnref); -- 2.25.0