[libvirt] [PATCH 5/5] virISCSIScanTargets: Allow making targets persistent

Michal Privoznik posted 5 patches 6 years, 10 months ago
There is a newer version of this series
[libvirt] [PATCH 5/5] virISCSIScanTargets: Allow making targets persistent
Posted by Michal Privoznik 6 years, 10 months ago
After new iSCSI interface is successfully set up, we issue
sendtargets command. However, after 56057900dc53df490d we don't
update the host config which in turn makes login fail because
iscsiadm is unable to find any matching record for the interface.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/storage/storage_backend_iscsi.c |  1 +
 src/util/viriscsi.c                 | 21 ++++++++++++++++++---
 src/util/viriscsi.h                 |  1 +
 tests/viriscsitest.c                |  3 ++-
 4 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c
index 3b9dddb4fd..6242cd0fac 100644
--- a/src/storage/storage_backend_iscsi.c
+++ b/src/storage/storage_backend_iscsi.c
@@ -196,6 +196,7 @@ virStorageBackendISCSIFindPoolSources(const char *srcSpec,
 
     if (virISCSIScanTargets(portal,
                             source->initiator.iqn,
+                            false,
                             &ntargets, &targets) < 0)
         goto cleanup;
 
diff --git a/src/util/viriscsi.c b/src/util/viriscsi.c
index 365669aac2..baf41c5be1 100644
--- a/src/util/viriscsi.c
+++ b/src/util/viriscsi.c
@@ -43,6 +43,7 @@ VIR_LOG_INIT("util.iscsi");
 static int
 virISCSIScanTargetsInternal(const char *portal,
                             const char *ifacename,
+                            bool persist,
                             size_t *ntargetsret,
                             char ***targetsret);
 
@@ -295,8 +296,10 @@ virISCSIConnection(const char *portal,
              * portal. Without the sendtargets all that is received is a
              * "iscsiadm: No records found". However, we must ensure that
              * the command is issued over interface name we invented above.
+             * AND that targets are made persistent.
              */
-            if (virISCSIScanTargetsInternal(portal, ifacename, NULL, NULL) < 0)
+            if (virISCSIScanTargetsInternal(portal, ifacename,
+                                            true, NULL, NULL) < 0)
                 goto cleanup;
 
             break;
@@ -382,6 +385,7 @@ virISCSIGetTargets(char **const groups,
 static int
 virISCSIScanTargetsInternal(const char *portal,
                             const char *ifacename,
+                            bool persist,
                             size_t *ntargetsret,
                             char ***targetsret)
 {
@@ -406,9 +410,14 @@ virISCSIScanTargetsInternal(const char *portal,
                                              "--mode", "discovery",
                                              "--type", "sendtargets",
                                              "--portal", portal,
-                                             "--op", "nonpersistent",
                                              NULL);
 
+    if (!persist) {
+        virCommandAddArgList(cmd,
+                             "--op", "nonpersistent",
+                             NULL);
+    }
+
     if (ifacename) {
         virCommandAddArgList(cmd,
                              "--interface", ifacename,
@@ -445,6 +454,7 @@ virISCSIScanTargetsInternal(const char *portal,
  * virISCSIScanTargets:
  * @portal: iSCSI portal
  * @initiatoriqn: Initiator IQN
+ * @persists: whether scanned targets should be saved
  * @ntargets: number of items in @targetsret array
  * @targets: array of targets
  *
@@ -453,12 +463,16 @@ virISCSIScanTargetsInternal(const char *portal,
  * The targets are stored into @targets array and the size of
  * the array is stored into @ntargets.
  *
+ * If @persist is true, then targets returned by iSCSI portal are
+ * made persistent on the host (their config is saved).
+ *
  * Returns: 0 on success,
  *         -1 otherwise (with error reported)
  */
 int
 virISCSIScanTargets(const char *portal,
                     const char *initiatoriqn,
+                    bool persist,
                     size_t *ntargets,
                     char ***targets)
 {
@@ -485,7 +499,8 @@ virISCSIScanTargets(const char *portal,
         }
     }
 
-    ret = virISCSIScanTargetsInternal(portal, ifacename, ntargets, targets);
+    ret = virISCSIScanTargetsInternal(portal, ifacename,
+                                      persist, ntargets, targets);
     VIR_FREE(ifacename);
     return ret;
 }
diff --git a/src/util/viriscsi.h b/src/util/viriscsi.h
index 31b589dbf9..4da9becfb2 100644
--- a/src/util/viriscsi.h
+++ b/src/util/viriscsi.h
@@ -50,6 +50,7 @@ virISCSIRescanLUNs(const char *session)
 int
 virISCSIScanTargets(const char *portal,
                     const char *initiatoriqn,
+                    bool persist,
                     size_t *ntargetsret,
                     char ***targetsret)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
diff --git a/tests/viriscsitest.c b/tests/viriscsitest.c
index 4bdb782e36..3bb3993196 100644
--- a/tests/viriscsitest.c
+++ b/tests/viriscsitest.c
@@ -145,7 +145,8 @@ testISCSIScanTargets(const void *data)
 
     virCommandSetDryRun(NULL, testIscsiadmCb, NULL);
 
-    if (virISCSIScanTargets(info->portal, NULL, &ntargets, &targets) < 0)
+    if (virISCSIScanTargets(info->portal, NULL,
+                            false, &ntargets, &targets) < 0)
         goto cleanup;
 
     if (info->nexpected != ntargets) {
-- 
2.16.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 5/5] virISCSIScanTargets: Allow making targets persistent
Posted by John Ferlan 6 years, 10 months ago

On 06/29/2018 11:01 AM, Michal Privoznik wrote:
> After new iSCSI interface is successfully set up, we issue

s/new/a new/
s/issue/issue a/

> sendtargets command. However, after 56057900dc53df490d we don't
> update the host config which in turn makes login fail because
> iscsiadm is unable to find any matching record for the interface.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/storage/storage_backend_iscsi.c |  1 +
>  src/util/viriscsi.c                 | 21 ++++++++++++++++++---
>  src/util/viriscsi.h                 |  1 +
>  tests/viriscsitest.c                |  3 ++-
>  4 files changed, 22 insertions(+), 4 deletions(-)
> 

Like the previous patch - is there a specific bug or something that led
you down this path?  Can you show an example of the existing code that's
creating a bad command line and generating an error and then how this
fixes things.  It's not like we have tests and for this stuff it's
really nice to have plenty of examples.

> diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c
> index 3b9dddb4fd..6242cd0fac 100644
> --- a/src/storage/storage_backend_iscsi.c
> +++ b/src/storage/storage_backend_iscsi.c
> @@ -196,6 +196,7 @@ virStorageBackendISCSIFindPoolSources(const char *srcSpec,
>  
>      if (virISCSIScanTargets(portal,
>                              source->initiator.iqn,
> +                            false,
>                              &ntargets, &targets) < 0)
>          goto cleanup;
>  
> diff --git a/src/util/viriscsi.c b/src/util/viriscsi.c
> index 365669aac2..baf41c5be1 100644
> --- a/src/util/viriscsi.c
> +++ b/src/util/viriscsi.c
> @@ -43,6 +43,7 @@ VIR_LOG_INIT("util.iscsi");
>  static int
>  virISCSIScanTargetsInternal(const char *portal,
>                              const char *ifacename,
> +                            bool persist,
>                              size_t *ntargetsret,
>                              char ***targetsret);
>  
> @@ -295,8 +296,10 @@ virISCSIConnection(const char *portal,
>               * portal. Without the sendtargets all that is received is a
>               * "iscsiadm: No records found". However, we must ensure that
>               * the command is issued over interface name we invented above.

s/above./above/

> +             * AND that targets are made persistent.

s/AND/and/

Similar to previous - with minor adjustments and explanation,

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

>               */
> -            if (virISCSIScanTargetsInternal(portal, ifacename, NULL, NULL) < 0)
> +            if (virISCSIScanTargetsInternal(portal, ifacename,
> +                                            true, NULL, NULL) < 0)
>                  goto cleanup;
>  
>              break;
[...]

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 5/5] virISCSIScanTargets: Allow making targets persistent
Posted by Michal Prívozník 6 years, 10 months ago
On 07/03/2018 01:40 AM, John Ferlan wrote:
> 
> 
> On 06/29/2018 11:01 AM, Michal Privoznik wrote:
>> After new iSCSI interface is successfully set up, we issue
> 
> s/new/a new/
> s/issue/issue a/
> 
>> sendtargets command. However, after 56057900dc53df490d we don't
>> update the host config which in turn makes login fail because
>> iscsiadm is unable to find any matching record for the interface.
>>
>> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>> ---
>>  src/storage/storage_backend_iscsi.c |  1 +
>>  src/util/viriscsi.c                 | 21 ++++++++++++++++++---
>>  src/util/viriscsi.h                 |  1 +
>>  tests/viriscsitest.c                |  3 ++-
>>  4 files changed, 22 insertions(+), 4 deletions(-)
>>
> 
> Like the previous patch - is there a specific bug or something that led
> you down this path?  Can you show an example of the existing code that's
> creating a bad command line and generating an error and then how this
> fixes things.  It's not like we have tests and for this stuff it's
> really nice to have plenty of examples.

So here is the run without my patches:

debug : virCommandRunAsync:2476 : About to run iscsiadm --mode session
iscsiadm: No active sessions.
debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --targetname $TARGET --op new
debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --target $TARGET --op update --name node.session.auth.authmethod --value CHAP
debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --target $TARGET --op update --name node.session.auth.username --value $USER
debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --target $TARGET --op update --name node.session.auth.password --value $PASS
debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface
debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface --interface libvirt-iface-03316143 --op new
debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface --interface libvirt-iface-03316143 --op update --name iface.initiatorname --value $INITIATOR
debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface
debug : virCommandRunAsync:2476 : About to run iscsiadm --mode discovery --type sendtargets --portal $PORTAL:3260,1 --op nonpersistent
debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --targetname $TARGET --login --interface libvirt-iface-03316143
error : virCommandWait:2600 : internal error: Child process (iscsiadm --mode node --portal $PORTAL:3260,1 --targetname $TARGET --login --interface libvirt-iface-03316143) unexpected exit status 21:
iscsiadm: No records found
iscsiadm: No records found


And with my patches:

debug : virCommandRunAsync:2476 : About to run iscsiadm --mode session
iscsiadm: No active sessions.
debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --targetname $TARGET --op new
debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --target $TARGET --op update --name node.session.auth.authmethod --value CHAP
debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --target $TARGET --op update --name node.session.auth.username --value $USER
debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --target $TARGET --op update --name node.session.auth.password --value $PASS
debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface
debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface --interface libvirt-iface-28727243 --op new
debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface --interface libvirt-iface-28727243 --op update --name iface.initiatorname --value $INITIATOR
debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface
debug : virCommandRunAsync:2476 : About to run iscsiadm --mode discovery --type sendtargets --portal $PORTAL:3260,1 --interface libvirt-iface-28727243
debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --targetname $TARGET --login --interface libvirt-iface-28727243
debug : virCommandRunAsync:2476 : About to run iscsiadm --mode session
debug : virCommandRunAsync:2476 : About to run iscsiadm --mode session -r 1 -R


Thanks,
Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 5/5] virISCSIScanTargets: Allow making targets persistent
Posted by John Ferlan 6 years, 10 months ago

On 07/03/2018 01:08 AM, Michal Prívozník wrote:
> On 07/03/2018 01:40 AM, John Ferlan wrote:
>>
>>
>> On 06/29/2018 11:01 AM, Michal Privoznik wrote:
>>> After new iSCSI interface is successfully set up, we issue
>>
>> s/new/a new/
>> s/issue/issue a/
>>
>>> sendtargets command. However, after 56057900dc53df490d we don't
>>> update the host config which in turn makes login fail because
>>> iscsiadm is unable to find any matching record for the interface.
>>>
>>> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>>> ---
>>>  src/storage/storage_backend_iscsi.c |  1 +
>>>  src/util/viriscsi.c                 | 21 ++++++++++++++++++---
>>>  src/util/viriscsi.h                 |  1 +
>>>  tests/viriscsitest.c                |  3 ++-
>>>  4 files changed, 22 insertions(+), 4 deletions(-)
>>>
>>
>> Like the previous patch - is there a specific bug or something that led
>> you down this path?  Can you show an example of the existing code that's
>> creating a bad command line and generating an error and then how this
>> fixes things.  It's not like we have tests and for this stuff it's
>> really nice to have plenty of examples.
> 
> So here is the run without my patches:
> 
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode session
> iscsiadm: No active sessions.
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --targetname $TARGET --op new
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --target $TARGET --op update --name node.session.auth.authmethod --value CHAP
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --target $TARGET --op update --name node.session.auth.username --value $USER
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --target $TARGET --op update --name node.session.auth.password --value $PASS
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface --interface libvirt-iface-03316143 --op new
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface --interface libvirt-iface-03316143 --op update --name iface.initiatorname --value $INITIATOR
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode discovery --type sendtargets --portal $PORTAL:3260,1 --op nonpersistent
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --targetname $TARGET --login --interface libvirt-iface-03316143
> error : virCommandWait:2600 : internal error: Child process (iscsiadm --mode node --portal $PORTAL:3260,1 --targetname $TARGET --login --interface libvirt-iface-03316143) unexpected exit status 21:
> iscsiadm: No records found
> iscsiadm: No records found
> 
> 
> And with my patches:
> 
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode session
> iscsiadm: No active sessions.
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --targetname $TARGET --op new
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --target $TARGET --op update --name node.session.auth.authmethod --value CHAP
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --target $TARGET --op update --name node.session.auth.username --value $USER
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --target $TARGET --op update --name node.session.auth.password --value $PASS
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface --interface libvirt-iface-28727243 --op new
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface --interface libvirt-iface-28727243 --op update --name iface.initiatorname --value $INITIATOR
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode discovery --type sendtargets --portal $PORTAL:3260,1 --interface libvirt-iface-28727243
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --targetname $TARGET --login --interface libvirt-iface-28727243
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode session
> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode session -r 1 -R
> 
> 

So the example helps me understand - thanks! The difference of discovery
being:

  fail: iscsiadm --mode discovery --type sendtargets \
                 --portal $PORTAL:3260,1 \
                 --op nonpersistent

  succ: iscsiadm --mode discovery --type sendtargets \
                 --portal $PORTAL:3260,1 \
                 --interface libvirt-iface-28727243

So, what commit 56057900d did to "help" or "fix" auto-login for sessions
that do not "belong to" libvirt is being called out as causing problems
for the initiatoriqn sessions. Prior to that commit the command was:

    iscsiadm --mode discovery --type sendtargets --portal $PORTAL:3260,1

So, I have to wonder "how" or "if" discovery using an initiatoriqn
really worked since there wasn't an --interface argument. Not sure I
have the patience/desire to go through the history of refactors and
adjustments since 6aabcb5 though ;-). Although it does appear that the
original code would make a "node" during it's connection period rather
than doing a sendtargets using the --interface option (and whether that
option existed at the time is a different search through a different set
of code).

Given all of what's been discovered here - I think patch 4 and 5 should
be combined. And rather than adding a new "bool persist" parameter that
only is true when initiatoriqn is passed, let's use the fact that
initiatoriqn was passed in order to:

if (ifacename)
    virCommandAddArgList(cmd, "--interface", ifacename, NULL);
else
    virCommandAddArgList(cmd, "--op", "nonpersistent", NULL);

Then as long as non initiatoriqn sessions still work, even those without
a libvirt pool associated - we should be able to declare victory. Not
sure "if" non libvirt pool initiatoriqn sessions would be affected by
all this.

John

BTW: Based on that commit, I wonder if you can modify viriscsitest.c a
bit in order to generate the initiatoriqn output as well via a change to
testIscsiadmCb.

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 5/5] virISCSIScanTargets: Allow making targets persistent
Posted by Michal Prívozník 6 years, 10 months ago
On 07/03/2018 02:42 PM, John Ferlan wrote:
> 
> 
> On 07/03/2018 01:08 AM, Michal Prívozník wrote:
>> On 07/03/2018 01:40 AM, John Ferlan wrote:
>>>
>>>
>>> On 06/29/2018 11:01 AM, Michal Privoznik wrote:
>>>> After new iSCSI interface is successfully set up, we issue
>>>
>>> s/new/a new/
>>> s/issue/issue a/
>>>
>>>> sendtargets command. However, after 56057900dc53df490d we don't
>>>> update the host config which in turn makes login fail because
>>>> iscsiadm is unable to find any matching record for the interface.
>>>>
>>>> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>>>> ---
>>>>  src/storage/storage_backend_iscsi.c |  1 +
>>>>  src/util/viriscsi.c                 | 21 ++++++++++++++++++---
>>>>  src/util/viriscsi.h                 |  1 +
>>>>  tests/viriscsitest.c                |  3 ++-
>>>>  4 files changed, 22 insertions(+), 4 deletions(-)
>>>>
>>>
>>> Like the previous patch - is there a specific bug or something that led
>>> you down this path?  Can you show an example of the existing code that's
>>> creating a bad command line and generating an error and then how this
>>> fixes things.  It's not like we have tests and for this stuff it's
>>> really nice to have plenty of examples.
>>
>> So here is the run without my patches:
>>
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode session
>> iscsiadm: No active sessions.
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --targetname $TARGET --op new
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --target $TARGET --op update --name node.session.auth.authmethod --value CHAP
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --target $TARGET --op update --name node.session.auth.username --value $USER
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --target $TARGET --op update --name node.session.auth.password --value $PASS
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface --interface libvirt-iface-03316143 --op new
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface --interface libvirt-iface-03316143 --op update --name iface.initiatorname --value $INITIATOR
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode discovery --type sendtargets --portal $PORTAL:3260,1 --op nonpersistent
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --targetname $TARGET --login --interface libvirt-iface-03316143
>> error : virCommandWait:2600 : internal error: Child process (iscsiadm --mode node --portal $PORTAL:3260,1 --targetname $TARGET --login --interface libvirt-iface-03316143) unexpected exit status 21:
>> iscsiadm: No records found
>> iscsiadm: No records found
>>
>>
>> And with my patches:
>>
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode session
>> iscsiadm: No active sessions.
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --targetname $TARGET --op new
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --target $TARGET --op update --name node.session.auth.authmethod --value CHAP
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --target $TARGET --op update --name node.session.auth.username --value $USER
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --target $TARGET --op update --name node.session.auth.password --value $PASS
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface --interface libvirt-iface-28727243 --op new
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface --interface libvirt-iface-28727243 --op update --name iface.initiatorname --value $INITIATOR
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode iface
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode discovery --type sendtargets --portal $PORTAL:3260,1 --interface libvirt-iface-28727243
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode node --portal $PORTAL:3260,1 --targetname $TARGET --login --interface libvirt-iface-28727243
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode session
>> debug : virCommandRunAsync:2476 : About to run iscsiadm --mode session -r 1 -R
>>
>>
> 
> So the example helps me understand - thanks! The difference of discovery
> being:
> 
>   fail: iscsiadm --mode discovery --type sendtargets \
>                  --portal $PORTAL:3260,1 \
>                  --op nonpersistent
> 
>   succ: iscsiadm --mode discovery --type sendtargets \
>                  --portal $PORTAL:3260,1 \
>                  --interface libvirt-iface-28727243
> 
> So, what commit 56057900d did to "help" or "fix" auto-login for sessions
> that do not "belong to" libvirt is being called out as causing problems
> for the initiatoriqn sessions. Prior to that commit the command was:
> 
>     iscsiadm --mode discovery --type sendtargets --portal $PORTAL:3260,1
> 
> So, I have to wonder "how" or "if" discovery using an initiatoriqn
> really worked since there wasn't an --interface argument. 

Maybe it did. Maybe iscsiadm used to use all interfaces (which okay,
sounds unlikely) for sendtargets. Or it remembered that we added a
special interface for $PORTAL and preferred that. I have no idea. But it
is clearly not working now.

> Not sure I
> have the patience/desire to go through the history of refactors and
> adjustments since 6aabcb5 though ;-). Although it does appear that the
> original code would make a "node" during it's connection period rather
> than doing a sendtargets using the --interface option (and whether that
> option existed at the time is a different search through a different set
> of code).
> 
> Given all of what's been discovered here - I think patch 4 and 5 should
> be combined. 

Well, I can merge them. It's just that I wanted these virISCSI* helpers
to be generic enough so that when one day somebody wants to persists
targets for default connection they can do that. I view @ifacename and
@persist arguments as orthogonal. It's only the usage of APIs that makes
the arguments mutually exclusive (or tied together or what).

> And rather than adding a new "bool persist" parameter that
> only is true when initiatoriqn is passed, let's use the fact that
> initiatoriqn was passed in order to:
> 
> if (ifacename)
>     virCommandAddArgList(cmd, "--interface", ifacename, NULL);
> else
>     virCommandAddArgList(cmd, "--op", "nonpersistent", NULL);
> 
> Then as long as non initiatoriqn sessions still work, even those without
> a libvirt pool associated - we should be able to declare victory. Not
> sure "if" non libvirt pool initiatoriqn sessions would be affected by
> all this.

They shouldn't. That is why libvirt creates its own interface.

> 
> John
> 
> BTW: Based on that commit, I wonder if you can modify viriscsitest.c a
> bit in order to generate the initiatoriqn output as well via a change to
> testIscsiadmCb.
> 

I'll look into it.

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list