[libvirt] [PATCH 0/4] Add auth and adapter to virsh pool-{create|define}-as

Recently while reviewing some documentation for iSCSI authentication description I found that virsh pool-{create|define}-as did not provide a mechanism to add the <auth> and/or <adapter> options on the command line - so I figured adding them would be simple. In the course of doing this I also noted a few typos on the formatstorage html page and (to say the last) a fairly incomplete or lacking man page description for pool-{create|define}-as. John Ferlan (4): docs: Fix a couple of typos on the storage pool html virsh.pod: Fix the pool-define-as and pool-create-as description virsh: Add auth options for pool-{create|define}-as virsh: Add adapter options for pool-{create|define}-as docs/formatstorage.html.in | 4 ++-- tools/virsh-pool.c | 59 ++++++++++++++++++++++++++++++++++++++++++++-- tools/virsh.pod | 53 ++++++++++++++++++++++++++++++++++++----- 3 files changed, 106 insertions(+), 10 deletions(-) -- 1.9.3

Fix format of the secret XML in the example. The XML had an extraneousof "type='iscsi'" (which is used by the <disk> definitions) The world wide node name had a typo in the acronym (wwwn). Signed-off-by: John Ferlan <jferlan@redhat.com> --- docs/formatstorage.html.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in index de786b8..0951daa 100644 --- a/docs/formatstorage.html.in +++ b/docs/formatstorage.html.in @@ -80,7 +80,7 @@ <host name="iscsi.example.com"/> <device path="demo-target"/> <auth type='chap' username='myname'> - <secret type='iscsi' usage='mycluster_myname'/> + <secret usage='mycluster_myname'/> </auth> <vendor name="Acme"/> <product name="model"/> @@ -179,7 +179,7 @@ </dd> </dl> <dl> - <dt><code>wwwn</code> and <code>wwpn</code></dt> + <dt><code>wwnn</code> and <code>wwpn</code></dt> <dd>The "World Wide Node Name" (<code>wwnn</code>) and "World Wide Port Name" (<code>wwpn</code>) are used by the "fc_host" adapter to uniquely identify the device in the Fibre Channel storage fabric -- 1.9.3

On 12/04/2014 07:45 AM, John Ferlan wrote:
Fix format of the secret XML in the example. The XML had an extraneousof
s/extraneousof/extraneous/
"type='iscsi'" (which is used by the <disk> definitions)
The world wide node name had a typo in the acronym (wwwn).
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Properly format the options and provide meaningful descriptions for the various options. Signed-off-by: John Ferlan <jferlan@redhat.com> --- tools/virsh.pod | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/tools/virsh.pod b/tools/virsh.pod index 7cde3fd..1b31597 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -2956,28 +2956,49 @@ data on the target device is overwritten unconditionally. Create and start a pool object from the XML I<file>. -=item B<pool-create-as> I<name> I<--print-xml> I<type> [I<source-host>] -[I<source-path>] [I<source-dev>] [I<source-name>] [<target>] -[I<--source-format format>] +=item B<pool-create-as> I<name> I<type> [I<--print-xml>] +[I<--source-host hostname>] [I<--source-path path>] [I<--source-dev path>] +[I<--source-name name>] [I<--target path>] [I<--source-format format>] Create and start a pool object I<name> from the raw parameters. If I<--print-xml> is specified, then print the XML of the pool object without creating the pool. Otherwise, the pool has the specified I<type>. +[I<--source-host hostname>] provides the source hostname for pools backed +by storage from a remote server (pool types netfs, iscsi, rbd, sheepdog, +gluster). + +[I<--source-path path>] provides the source directory path for pools backed +by directories (pool type dir). + +[I<--source-dev path>] provides the source path for pools backed by physical +devices (pool types fs, logical, disk, iscsi, zfs). + +[I<--source-name name>] provides the source name for pools backed by storage +from a named element (pool types logical, rbd, sheepdog, gluster). + +[I<--target path>] is the path for the mapping of the storage pool into +the host file system. + +[I<--source-format format>] provides information about the format of the +pool (pool types fs, netfs, disk, logical). + =item B<pool-define> I<file> Create, but do not start, a pool object from the XML I<file>. -=item B<pool-define-as> I<name> I<--print-xml> I<type> [I<source-host>] -[I<source-path>] [I<source-dev>] [I<source-name>] [<target>] -[I<--source-format format>] +=item B<pool-define-as> I<name> I<type> [I<--print-xml>] +[I<--source-host hostname>] [I<--source-path path>] [I<--source-dev path>] +[I<--source-name name>] [I<--target path>] [I<--source-format format>] Create, but do not start, a pool object I<name> from the raw parameters. If I<--print-xml> is specified, then print the XML of the pool object without defining the pool. Otherwise, the pool has the specified I<type>. +Use the same arguments as B<pool-define-as>. + =item B<pool-destroy> I<pool-or-uuid> Destroy (stop) a given I<pool> object. Libvirt will no longer manage the -- 1.9.3

Add 3 new optional options for the pool-create-as and pool-define-as command in order to define the 3 elements required in order to add an auth element, such as: <auth type='chap' username='myuser'> <secret usage='libvirtiscsi'/> </auth> Signed-off-by: John Ferlan <jferlan@redhat.com> --- tools/virsh-pool.c | 28 ++++++++++++++++++++++++++-- tools/virsh.pod | 7 +++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index cf7776c..bba7d68 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -223,6 +223,18 @@ static const vshCmdOptDef opts_pool_X_as[] = { .type = VSH_OT_STRING, .help = N_("format for underlying storage") }, + {.name = "auth-type", + .type = VSH_OT_STRING, + .help = N_("auth type to be used for underlying storage") + }, + {.name = "auth-username", + .type = VSH_OT_STRING, + .help = N_("auth username to be used for underlying storage") + }, + {.name = "secret-usage", + .type = VSH_OT_STRING, + .help = N_("auth secret usage to be used for underlying storage") + }, {.name = NULL} }; @@ -234,7 +246,8 @@ vshBuildPoolXML(vshControl *ctl, { const char *name = NULL, *type = NULL, *srcHost = NULL, *srcPath = NULL, *srcDev = NULL, *srcName = NULL, *srcFormat = NULL, - *target = NULL; + *target = NULL, *authType = NULL, *authUsername = NULL, + *secretUsage = NULL; virBuffer buf = VIR_BUFFER_INITIALIZER; if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0) @@ -247,7 +260,10 @@ vshBuildPoolXML(vshControl *ctl, vshCommandOptStringReq(ctl, cmd, "source-dev", &srcDev) < 0 || vshCommandOptStringReq(ctl, cmd, "source-name", &srcName) < 0 || vshCommandOptStringReq(ctl, cmd, "source-format", &srcFormat) < 0 || - vshCommandOptStringReq(ctl, cmd, "target", &target) < 0) + vshCommandOptStringReq(ctl, cmd, "target", &target) < 0 || + vshCommandOptStringReq(ctl, cmd, "auth-type", &authType) < 0 || + vshCommandOptStringReq(ctl, cmd, "auth-username", &authUsername) < 0 || + vshCommandOptStringReq(ctl, cmd, "secret-usage", &secretUsage) < 0) goto cleanup; virBufferAsprintf(&buf, "<pool type='%s'>\n", type); @@ -263,6 +279,14 @@ vshBuildPoolXML(vshControl *ctl, virBufferAsprintf(&buf, "<dir path='%s'/>\n", srcPath); if (srcDev) virBufferAsprintf(&buf, "<device path='%s'/>\n", srcDev); + if (authType && authUsername && secretUsage) { + virBufferAsprintf(&buf, "<auth type='%s' username='%s'>\n", + authType, authUsername); + virBufferAdjustIndent(&buf, 2); + virBufferAsprintf(&buf, "<secret usage='%s'/>\n", secretUsage); + virBufferAdjustIndent(&buf, -2); + virBufferAddLit(&buf, "</auth>\n"); + } if (srcFormat) virBufferAsprintf(&buf, "<format type='%s'/>\n", srcFormat); if (srcName) diff --git a/tools/virsh.pod b/tools/virsh.pod index 1b31597..45dd924 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -2959,6 +2959,7 @@ Create and start a pool object from the XML I<file>. =item B<pool-create-as> I<name> I<type> [I<--print-xml>] [I<--source-host hostname>] [I<--source-path path>] [I<--source-dev path>] [I<--source-name name>] [I<--target path>] [I<--source-format format>] +[I<--auth-type authtype> I<--auth-username username> I<--secret-usage usage>] Create and start a pool object I<name> from the raw parameters. If I<--print-xml> is specified, then print the XML of the pool object @@ -2984,6 +2985,11 @@ the host file system. [I<--source-format format>] provides information about the format of the pool (pool types fs, netfs, disk, logical). +[I<--auth-type authtype> I<--auth-username username> I<--secret-usage usage>] +provides the elements required to generate authentication credentials for +the storage pool. The I<authtype> is either chap for iscsi I<type> pools or +ceph for rbd I<type> pools. + =item B<pool-define> I<file> Create, but do not start, a pool object from the XML I<file>. @@ -2991,6 +2997,7 @@ Create, but do not start, a pool object from the XML I<file>. =item B<pool-define-as> I<name> I<type> [I<--print-xml>] [I<--source-host hostname>] [I<--source-path path>] [I<--source-dev path>] [I<--source-name name>] [I<--target path>] [I<--source-format format>] +[I<--auth-type authtype> I<--auth-username username> I<--secret-usage usage>] Create, but do not start, a pool object I<name> from the raw parameters. If I<--print-xml> is specified, then print the XML of the pool object -- 1.9.3

Add the optional adapter options for pool create/define. Results in either: <adapter type='scsi_host' name='scsi_host2'/> or (on one line) <adapter type='fc_host' parent='scsi_host5' wwnn='20000000c9831b4b' wwpn='10000000c9831b4b'/> being generated. Signed-off-by: John Ferlan <jferlan@redhat.com> --- tools/virsh-pool.c | 35 +++++++++++++++++++++++++++++++++-- tools/virsh.pod | 13 +++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index bba7d68..a9482c4 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -235,6 +235,22 @@ static const vshCmdOptDef opts_pool_X_as[] = { .type = VSH_OT_STRING, .help = N_("auth secret usage to be used for underlying storage") }, + {.name = "adapter-name", + .type = VSH_OT_STRING, + .help = N_("adapter name to be used for underlying storage") + }, + {.name = "adapter-wwnn", + .type = VSH_OT_STRING, + .help = N_("adapter wwnn to be used for underlying storage") + }, + {.name = "adapter-wwpn", + .type = VSH_OT_STRING, + .help = N_("adapter wwpn to be used for underlying storage") + }, + {.name = "adapter-parent", + .type = VSH_OT_STRING, + .help = N_("adapter parent to be used for underlying storage") + }, {.name = NULL} }; @@ -247,7 +263,8 @@ vshBuildPoolXML(vshControl *ctl, const char *name = NULL, *type = NULL, *srcHost = NULL, *srcPath = NULL, *srcDev = NULL, *srcName = NULL, *srcFormat = NULL, *target = NULL, *authType = NULL, *authUsername = NULL, - *secretUsage = NULL; + *secretUsage = NULL, *adapterName = NULL, *adapterParent = NULL, + *adapterWwnn = NULL, *adapterWwpn = NULL; virBuffer buf = VIR_BUFFER_INITIALIZER; if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0) @@ -263,7 +280,11 @@ vshBuildPoolXML(vshControl *ctl, vshCommandOptStringReq(ctl, cmd, "target", &target) < 0 || vshCommandOptStringReq(ctl, cmd, "auth-type", &authType) < 0 || vshCommandOptStringReq(ctl, cmd, "auth-username", &authUsername) < 0 || - vshCommandOptStringReq(ctl, cmd, "secret-usage", &secretUsage) < 0) + vshCommandOptStringReq(ctl, cmd, "secret-usage", &secretUsage) < 0 || + vshCommandOptStringReq(ctl, cmd, "adapter-name", &adapterName) < 0 || + vshCommandOptStringReq(ctl, cmd, "adapter-wwnn", &adapterWwnn) < 0 || + vshCommandOptStringReq(ctl, cmd, "adapter-wwpn", &adapterWwpn) < 0 || + vshCommandOptStringReq(ctl, cmd, "adapter-parent", &adapterParent) < 0) goto cleanup; virBufferAsprintf(&buf, "<pool type='%s'>\n", type); @@ -279,6 +300,16 @@ vshBuildPoolXML(vshControl *ctl, virBufferAsprintf(&buf, "<dir path='%s'/>\n", srcPath); if (srcDev) virBufferAsprintf(&buf, "<device path='%s'/>\n", srcDev); + if (adapterWwnn && adapterWwpn) { + virBufferAddLit(&buf, "<adapter type='fc_host'"); + if (adapterParent) + virBufferAsprintf(&buf, " parent='%s'", adapterParent); + virBufferAsprintf(&buf, " wwnn='%s' wwpn='%s'/>\n", + adapterWwnn, adapterWwpn); + } else if (adapterName) { + virBufferAsprintf(&buf, "<adapter type='scsi_host' name='%s'/>\n", + adapterName); + } if (authType && authUsername && secretUsage) { virBufferAsprintf(&buf, "<auth type='%s' username='%s'>\n", authType, authUsername); diff --git a/tools/virsh.pod b/tools/virsh.pod index 45dd924..c070261 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -2960,6 +2960,9 @@ Create and start a pool object from the XML I<file>. [I<--source-host hostname>] [I<--source-path path>] [I<--source-dev path>] [I<--source-name name>] [I<--target path>] [I<--source-format format>] [I<--auth-type authtype> I<--auth-username username> I<--secret-usage usage>] +[[I<--adapter-name name>] | [I<--adapter-wwnn> I<--adapter-wwpn>] +[I<--adapter-parent parent>]] + Create and start a pool object I<name> from the raw parameters. If I<--print-xml> is specified, then print the XML of the pool object @@ -2990,6 +2993,14 @@ provides the elements required to generate authentication credentials for the storage pool. The I<authtype> is either chap for iscsi I<type> pools or ceph for rbd I<type> pools. +[I<--adapter-name name>] defines the scsi_hostN adapter name to be used for +the scsi_host adapter type pool. + +[I<--adapter-wwnn> I<--adapter-wwpn> [I<--adapter-parent parent>]] defines +the wwnn and wwpn to be used for the fc_host adapter type pool. The parent +optionally provides the name of the scsi_hostN node device to be used for +the vHBA. + =item B<pool-define> I<file> Create, but do not start, a pool object from the XML I<file>. @@ -2998,6 +3009,8 @@ Create, but do not start, a pool object from the XML I<file>. [I<--source-host hostname>] [I<--source-path path>] [I<--source-dev path>] [I<--source-name name>] [I<--target path>] [I<--source-format format>] [I<--auth-type authtype> I<--auth-username username> I<--secret-usage usage>] +[[I<--adapter-name name>] | [I<--adapter-wwnn> I<--adapter-wwpn>] +[I<--adapter-parent parent>]] Create, but do not start, a pool object I<name> from the raw parameters. If I<--print-xml> is specified, then print the XML of the pool object -- 1.9.3

On 04.12.2014 15:45, John Ferlan wrote:
Recently while reviewing some documentation for iSCSI authentication description I found that virsh pool-{create|define}-as did not provide a mechanism to add the <auth> and/or <adapter> options on the command line - so I figured adding them would be simple. In the course of doing this I also noted a few typos on the formatstorage html page and (to say the last) a fairly incomplete or lacking man page description for pool-{create|define}-as.
John Ferlan (4): docs: Fix a couple of typos on the storage pool html virsh.pod: Fix the pool-define-as and pool-create-as description virsh: Add auth options for pool-{create|define}-as virsh: Add adapter options for pool-{create|define}-as
docs/formatstorage.html.in | 4 ++-- tools/virsh-pool.c | 59 ++++++++++++++++++++++++++++++++++++++++++++-- tools/virsh.pod | 53 ++++++++++++++++++++++++++++++++++++----- 3 files changed, 106 insertions(+), 10 deletions(-)
ACK series Michal

On 12/05/2014 08:53 AM, Michal Privoznik wrote:
On 04.12.2014 15:45, John Ferlan wrote:
Recently while reviewing some documentation for iSCSI authentication description I found that virsh pool-{create|define}-as did not provide a mechanism to add the <auth> and/or <adapter> options on the command line - so I figured adding them would be simple. In the course of doing this I also noted a few typos on the formatstorage html page and (to say the last) a fairly incomplete or lacking man page description for pool-{create|define}-as.
John Ferlan (4): docs: Fix a couple of typos on the storage pool html virsh.pod: Fix the pool-define-as and pool-create-as description virsh: Add auth options for pool-{create|define}-as virsh: Add adapter options for pool-{create|define}-as
docs/formatstorage.html.in | 4 ++-- tools/virsh-pool.c | 59 ++++++++++++++++++++++++++++++++++++++++++++-- tools/virsh.pod | 53 ++++++++++++++++++++++++++++++++++++----- 3 files changed, 106 insertions(+), 10 deletions(-)
ACK series
Michal
Tks - now pushed (with a fix for noted typo in 1/4 commit message) John
participants (3)
-
Eric Blake
-
John Ferlan
-
Michal Privoznik