From 8eebceef43e376b46c279a0d70f789af610dd5bf Mon Sep 17 00:00:00 2001 From: Han Han Date: Tue, 25 Aug 2020 11:50:33 +0800 Subject: [PATCH] virsh: Add source-initiator opt to build the initiator of pool XML For iscsi-direct pool, the initiator is necessary for pool defining: ... ... Add --source-initiator to fill the initiator iqn for pool-create-as/pool-define-as subcommands. https://bugzilla.redhat.com/show_bug.cgi?id=1658082 Signed-off-by: Han Han Signed-off-by: Michal Privoznik Reviewed-by: Michal Privoznik --- docs/manpages/virsh.rst | 5 +++++ tools/virsh-pool.c | 21 +++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 9187037a56..0482fe8b26 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -5732,6 +5732,7 @@ pool-create-as pool-create-as name type [--source-host hostname] [--source-path path] [--source-dev path] [--source-name name] [--target path] [--source-format format] + [--source-initiator initiator-iqn] [--auth-type authtype --auth-username username [--secret-usage usage | --secret-uuid uuid]] [--source-protocol-ver ver] @@ -5769,6 +5770,9 @@ the host file system. [*--source-format format*] provides information about the format of the pool (pool types fs, netfs, disk, logical). +[*--source-initiator initiator-iqn*] provides the initiator iqn for iscsi +connection of the pool (pool type iscsi-direct). + [*--auth-type authtype* *--auth-username username* [*--secret-usage usage* | *--secret-uuid uuid*]] provides the elements required to generate authentication credentials for @@ -5831,6 +5835,7 @@ pool-define-as pool-define-as name type [--source-host hostname] [--source-path path] [--source-dev path] [*--source-name name*] [*--target path*] [*--source-format format*] + [--source-initiator initiator-iqn] [*--auth-type authtype* *--auth-username username* [*--secret-usage usage* | *--secret-uuid uuid*]] [*--source-protocol-ver ver*] diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index fd43d3bb62..9fac590ec3 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -141,6 +141,10 @@ {.name = "source-protocol-ver", \ .type = VSH_OT_STRING, \ .help = N_("nfsvers value for NFS pool mount option") \ + }, \ + {.name = "source-initiator", \ + .type = VSH_OT_STRING, \ + .help = N_("initiator iqn for underlying storage") \ } virStoragePoolPtr @@ -324,7 +328,8 @@ virshBuildPoolXML(vshControl *ctl, *secretUsage = NULL, *adapterName = NULL, *adapterParent = NULL, *adapterWwnn = NULL, *adapterWwpn = NULL, *secretUUID = NULL, *adapterParentWwnn = NULL, *adapterParentWwpn = NULL, - *adapterParentFabricWwn = NULL, *protoVer = NULL; + *adapterParentFabricWwn = NULL, *protoVer = NULL, + *srcInitiator = NULL; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; VSH_EXCLUSIVE_OPTIONS("secret-usage", "secret-uuid"); @@ -352,15 +357,16 @@ virshBuildPoolXML(vshControl *ctl, vshCommandOptStringReq(ctl, cmd, "adapter-parent-wwnn", &adapterParentWwnn) < 0 || vshCommandOptStringReq(ctl, cmd, "adapter-parent-wwpn", &adapterParentWwpn) < 0 || vshCommandOptStringReq(ctl, cmd, "adapter-parent-fabric-wwn", &adapterParentFabricWwn) < 0 || - vshCommandOptStringReq(ctl, cmd, "source-protocol-ver", &protoVer) < 0) { + vshCommandOptStringReq(ctl, cmd, "source-protocol-ver", &protoVer) < 0 || + vshCommandOptStringReq(ctl, cmd, "source-initiator", &srcInitiator) < 0) { return false; } virBufferAsprintf(&buf, "\n", type); virBufferAdjustIndent(&buf, 2); virBufferAsprintf(&buf, "%s\n", name); - if (srcHost || srcPath || srcDev || srcFormat || srcName || - (adapterWwnn && adapterWwpn) || adapterName) { + if (srcHost || srcPath || srcDev || srcInitiator || srcFormat || + srcName || (adapterWwnn && adapterWwpn) || adapterName) { virBufferAddLit(&buf, "\n"); virBufferAdjustIndent(&buf, 2); @@ -370,6 +376,13 @@ virshBuildPoolXML(vshControl *ctl, virBufferAsprintf(&buf, "\n", srcPath); if (srcDev) virBufferAsprintf(&buf, "\n", srcDev); + if (srcInitiator) { + virBufferAddLit(&buf, "\n"); + virBufferAdjustIndent(&buf, 2); + virBufferAsprintf(&buf, "\n", srcInitiator); + virBufferAdjustIndent(&buf, -2); + virBufferAddLit(&buf, "\n"); + } if (adapterWwnn && adapterWwpn) { virBufferAddLit(&buf, "