提交 adfcbdff 编写于 作者: M Michal Privoznik

virISCSIScanTargets: Allow making targets persistent

After a new iSCSI interface is successfully set up, we issue a
sendtargets command. However, after 56057900 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: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 2e5ad588
......@@ -196,6 +196,7 @@ virStorageBackendISCSIFindPoolSources(const char *srcSpec,
if (virISCSIScanTargets(portal,
source->initiator.iqn,
false,
&ntargets, &targets) < 0)
goto cleanup;
......
......@@ -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);
......@@ -294,9 +295,11 @@ virISCSIConnection(const char *portal,
* unless you've first issued a 'sendtargets' command to the
* 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.
* 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)
{
......@@ -486,7 +500,8 @@ virISCSIScanTargets(const char *portal,
}
}
ret = virISCSIScanTargetsInternal(portal, ifacename, ntargets, targets);
ret = virISCSIScanTargetsInternal(portal, ifacename,
persist, ntargets, targets);
VIR_FREE(ifacename);
return ret;
}
......
......@@ -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;
......
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册