[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] libvirt should not disable auto_login of iscsi-targets that are *not* used by libvirt



Hi, Cole Robinson asked me to post the attached patch here.
For more info, see https://bugzilla.redhat.com/show_bug.cgi?id=1331552

Cheers
 -Fritz
From: Fritz Elfert <fritz fritz-elfert de>
Date: Fri, 29 Apr 2016 20:59:59 +0200
Subject: [PATCH] viriscsi: Use nonpersistent iscsi discovery

Instead of disabling auto-login of all scsi targets (even those
that do not "belong" to libvirt, use iscsiadm's --op nonpersistent
during discovery.

https://bugzilla.redhat.com/show_bug.cgi?id=1331552
---
 src/util/viriscsi.c  | 28 +---------------------------
 tests/viriscsitest.c |  4 +++-
 2 files changed, 4 insertions(+), 28 deletions(-)

diff --git a/src/util/viriscsi.c b/src/util/viriscsi.c
index bd34fea..31f8ce6 100644
--- a/src/util/viriscsi.c
+++ b/src/util/viriscsi.c
@@ -386,21 +386,6 @@ virISCSIGetTargets(char **const groups,
 }
 
 
-static int
-virISCSITargetAutologin(const char *portal,
-                        const char *initiatoriqn,
-                        const char *target,
-                        bool enable)
-{
-    const char *extraargv[] = { "--op", "update",
-                                "--name", "node.startup",
-                                "--value", enable ? "automatic" : "manual",
-                                NULL };
-
-    return virISCSIConnection(portal, initiatoriqn, target, extraargv);
-}
-
-
 int
 virISCSIScanTargets(const char *portal,
                     const char *initiatoriqn,
@@ -428,6 +413,7 @@ virISCSIScanTargets(const char *portal,
                                              "--mode", "discovery",
                                              "--type", "sendtargets",
                                              "--portal", portal,
+                                             "--op", "nonpersistent",
                                              NULL);
 
     memset(&list, 0, sizeof(list));
@@ -440,18 +426,6 @@ virISCSIScanTargets(const char *portal,
                            &list, NULL) < 0)
         goto cleanup;
 
-    for (i = 0; i < list.ntargets; i++) {
-        /* We have to ignore failure, because we can't undo
-         * the results of 'sendtargets', unless we go scrubbing
-         * around in the dirt in /var/lib/iscsi.
-         */
-        if (virISCSITargetAutologin(portal,
-                                    initiatoriqn,
-                                    list.targets[i], false) < 0)
-            VIR_WARN("Unable to disable auto-login on iSCSI target %s: %s",
-                     portal, list.targets[i]);
-    }
-
     if (ntargetsret && targetsret) {
         *ntargetsret = list.ntargets;
         *targetsret = list.targets;
diff --git a/tests/viriscsitest.c b/tests/viriscsitest.c
index c697a4a..b5b0e20 100644
--- a/tests/viriscsitest.c
+++ b/tests/viriscsitest.c
@@ -90,7 +90,9 @@ static void testIscsiadmCb(const char *const*args,
                args[4] && STREQ(args[4], "sendtargets") &&
                args[5] && STREQ(args[5], "--portal") &&
                args[6] && STREQ(args[6], "10.20.30.40:3260,1") &&
-               args[7] == NULL) {
+               args[7] && STREQ(args[7], "--op") &&
+               args[8] && STREQ(args[8], "nonpersistent") &&
+               args[9] == NULL) {
         ignore_value(VIR_STRDUP(*output, iscsiadmSendtargetsOutput));
     } else {
         *status = -1;
-- 
2.5.5

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]