static int
virISCSIScanTargetsInternal(const char *portal,
const char *ifacename,
+ bool persist,
size_t *ntargetsret,
char ***targetsret);
* 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;
static int
virISCSIScanTargetsInternal(const char *portal,
const char *ifacename,
+ bool persist,
size_t *ntargetsret,
char ***targetsret)
{
"--mode", "discovery",
"--type", "sendtargets",
"--portal", portal,
- "--op", "nonpersistent",
NULL);
+ if (!persist) {
+ virCommandAddArgList(cmd,
+ "--op", "nonpersistent",
+ NULL);
+ }
+
if (ifacename) {
virCommandAddArgList(cmd,
"--interface", ifacename,
* 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
*
* 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)
{
}
}
- ret = virISCSIScanTargetsInternal(portal, ifacename, ntargets, targets);
+ ret = virISCSIScanTargetsInternal(portal, ifacename,
+ persist, ntargets, targets);
VIR_FREE(ifacename);
return ret;
}
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) {