util: remove hardcoded ISCSIADM command path

Gating the iscsi driver backend on a isciadm probe is likely to do
more harm than good as it needlessly disables the code if the dev
forgot to install iscsiadm at build time. As a Linux only command
it is simpler to gate the feature based on the platform choice and
allow missing binaries to be diagnose at runtime.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé committed 2025-05-02 09:31:27 +01:00
1 parent ce7ac2f908
commit fa513d5845
3 files changed
+37 -39

No files matched your search

+2 -3
View File
@@ -854,7 +854,6 @@ optional_test_programs = [
]
optional_programs = [
'iscsiadm',
'mdevctl',
'mm-ctl',
'modprobe',
@@ -1825,11 +1824,11 @@ if conf.has('WITH_LIBVIRTD')
error('Need glusterfs (libgfapi) for gluster storage driver')
endif
if not get_option('storage_iscsi').disabled() and iscsiadm_prog.found()
if not get_option('storage_iscsi').disabled() and host_machine.system() == 'linux'
use_storage = true
conf.set('WITH_STORAGE_ISCSI', 1)
elif get_option('storage_iscsi').enabled()
error('We need iscsiadm for iSCSI storage driver')
error('Linux host needed for iSCSI storage driver using iscsiadm')
endif
if not get_option('storage_iscsi_direct').disabled() and libiscsi_dep.found()
+27 -28
View File
@@ -88,8 +88,8 @@ virISCSIGetSession(const char *devpath,
int exitstatus = 0;
g_autofree char *error = NULL;
g_autoptr(virCommand) cmd = virCommandNewArgList(ISCSIADM, "--mode",
"session", NULL);
g_autoptr(virCommand) cmd = virCommandNewArgList("iscsiadm", "--mode",
"session", NULL);
virCommandSetErrorBuffer(cmd, &error);
if (virCommandRunRegex(cmd,
@@ -123,8 +123,8 @@ virStorageBackendIQNFound(const char *initiatoriqn,
g_autofree char *outbuf = NULL;
g_autofree char *iface = NULL;
g_autofree char *iqn = NULL;
g_autoptr(virCommand) cmd = virCommandNewArgList(ISCSIADM,
"--mode", "iface", NULL);
g_autoptr(virCommand) cmd = virCommandNewArgList("iscsiadm",
"--mode", "iface", NULL);
*ifacename = NULL;
@@ -193,8 +193,8 @@ virStorageBackendIQNFound(const char *initiatoriqn,
error:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("malformed output of %1$s: %2$s"),
ISCSIADM, line);
_("malformed output of 'iscsiadm': %1$s"),
line);
goto cleanup;
}
@@ -215,7 +215,7 @@ virStorageBackendCreateIfaceIQN(const char *initiatoriqn,
VIR_DEBUG("Attempting to create interface '%s' with IQN '%s'",
temp_ifacename, initiatoriqn);
newcmd = virCommandNewArgList(ISCSIADM,
newcmd = virCommandNewArgList("iscsiadm",
"--mode", "iface",
"--interface", temp_ifacename,
"--op", "new",
@@ -225,13 +225,12 @@ virStorageBackendCreateIfaceIQN(const char *initiatoriqn,
* We will just rely on whether the interface got created
* properly. */
if (virCommandRun(newcmd, &exitstatus) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to run command '%1$s' to create new iscsi interface"),
ISCSIADM);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to run command 'iscsiadm' to create new iscsi interface"));
return -1;
}
updatecmd = virCommandNewArgList(ISCSIADM,
updatecmd = virCommandNewArgList("iscsiadm",
"--mode", "iface",
"--interface", temp_ifacename,
"--op", "update",
@@ -244,8 +243,8 @@ virStorageBackendCreateIfaceIQN(const char *initiatoriqn,
* rely on whether iface file got updated properly. */
if (virCommandRun(updatecmd, &exitstatus) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to run command '%1$s' to update iscsi interface with IQN '%2$s'"),
ISCSIADM, initiatoriqn);
_("Failed to run command 'iscsiadm' to update iscsi interface with IQN '%1$s'"),
initiatoriqn);
return -1;
}
@@ -273,7 +272,7 @@ virISCSIConnection(const char *portal,
const char **extraargv)
{
const char *const baseargv[] = {
ISCSIADM,
"iscsiadm",
"--mode", "node",
"--portal", portal,
"--targetname", target,
@@ -343,11 +342,11 @@ virISCSIConnectionLogout(const char *portal,
int
virISCSIRescanLUNs(const char *session)
{
g_autoptr(virCommand) cmd = virCommandNewArgList(ISCSIADM,
"--mode", "session",
"-r", session,
"-R",
NULL);
g_autoptr(virCommand) cmd = virCommandNewArgList("iscsiadm",
"--mode", "session",
"-r", session,
"-R",
NULL);
return virCommandRun(cmd, NULL);
}
@@ -396,11 +395,11 @@ virISCSIScanTargetsInternal(const char *portal,
int vars[] = { 2 };
struct virISCSITargetList list = { 0 };
size_t i;
g_autoptr(virCommand) cmd = virCommandNewArgList(ISCSIADM,
"--mode", "discovery",
"--type", "sendtargets",
"--portal", portal,
NULL);
g_autoptr(virCommand) cmd = virCommandNewArgList("iscsiadm",
"--mode", "discovery",
"--type", "sendtargets",
"--portal", portal,
NULL);
if (!persist) {
virCommandAddArgList(cmd,
@@ -512,7 +511,7 @@ virISCSINodeNew(const char *portal,
g_autoptr(virCommand) cmd = NULL;
int status;
cmd = virCommandNewArgList(ISCSIADM,
cmd = virCommandNewArgList("iscsiadm",
"--mode", "node",
"--portal", portal,
"--targetname", target,
@@ -528,8 +527,8 @@ virISCSINodeNew(const char *portal,
if (status != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("%1$s failed new mode for target '%2$s' with status '%3$d'"),
ISCSIADM, target, status);
_("'iscsiadm': failed new mode for target '%1$s' with status '%2$d'"),
target, status);
return -1;
}
@@ -546,7 +545,7 @@ virISCSINodeUpdate(const char *portal,
g_autoptr(virCommand) cmd = NULL;
int status;
cmd = virCommandNewArgList(ISCSIADM,
cmd = virCommandNewArgList("iscsiadm",
"--mode", "node",
"--portal", portal,
"--target", target,
+8 -8
View File
@@ -82,7 +82,7 @@ static void testIscsiadmCb(const char *const*args,
{
struct testIscsiadmCbData *data = opaque;
if (args[0] && STREQ(args[0], ISCSIADM) &&
if (args[0] && STREQ(args[0], "iscsiadm") &&
args[1] && STREQ(args[1], "--mode") &&
args[2] && STREQ(args[2], "session") &&
args[3] == NULL) {
@@ -90,7 +90,7 @@ static void testIscsiadmCb(const char *const*args,
*output = g_strdup(iscsiadmSessionOutputNonFlash);
else
*output = g_strdup(iscsiadmSessionOutput);
} else if (args[0] && STREQ(args[0], ISCSIADM) &&
} else if (args[0] && STREQ(args[0], "iscsiadm") &&
args[1] && STREQ(args[1], "--mode") &&
args[2] && STREQ(args[2], "discovery") &&
args[3] && STREQ(args[3], "--type") &&
@@ -101,7 +101,7 @@ static void testIscsiadmCb(const char *const*args,
args[8] && STREQ(args[8], "nonpersistent") &&
args[9] == NULL) {
*output = g_strdup(iscsiadmSendtargetsOutput);
} else if (args[0] && STREQ(args[0], ISCSIADM) &&
} else if (args[0] && STREQ(args[0], "iscsiadm") &&
args[1] && STREQ(args[1], "--mode") &&
args[2] && STREQ(args[2], "node") &&
args[3] && STREQ(args[3], "--portal") &&
@@ -120,7 +120,7 @@ static void testIscsiadmCb(const char *const*args,
* target: iqn.2004-06.example:example1:iscsi.test, \
* portal: 10.20.30.40:3260,1] successful.
*/
} else if (args[0] && STREQ(args[0], ISCSIADM) &&
} else if (args[0] && STREQ(args[0], "iscsiadm") &&
args[1] && STREQ(args[1], "--mode") &&
args[2] && STREQ(args[2], "iface") &&
args[3] == NULL) {
@@ -128,7 +128,7 @@ static void testIscsiadmCb(const char *const*args,
*output = g_strdup(iscsiadmIfaceIfaceOutput);
else
*output = g_strdup(iscsiadmIfaceDefaultOutput);
} else if (args[0] && STREQ(args[0], ISCSIADM) &&
} else if (args[0] && STREQ(args[0], "iscsiadm") &&
args[1] && STREQ(args[1], "--mode") &&
args[2] && STREQ(args[2], "iface") &&
args[3] && STREQ(args[3], "--interface") &&
@@ -142,7 +142,7 @@ static void testIscsiadmCb(const char *const*args,
* New interface libvirt-iface-03020100 added
*/
data->iface_created = true;
} else if (args[0] && STREQ(args[0], ISCSIADM) &&
} else if (args[0] && STREQ(args[0], "iscsiadm") &&
args[1] && STREQ(args[1], "--mode") &&
args[2] && STREQ(args[2], "iface") &&
args[3] && STREQ(args[3], "--interface") &&
@@ -160,7 +160,7 @@ static void testIscsiadmCb(const char *const*args,
*
* libvirt-iface-03020100 updated.
*/
} else if (args[0] && STREQ(args[0], ISCSIADM) &&
} else if (args[0] && STREQ(args[0], "iscsiadm") &&
args[1] && STREQ(args[1], "--mode") &&
args[2] && STREQ(args[2], "discovery") &&
args[3] && STREQ(args[3], "--type") &&
@@ -172,7 +172,7 @@ static void testIscsiadmCb(const char *const*args,
args[9] == NULL &&
data->iface_created) {
*output = g_strdup(iscsiadmSendtargetsOutput);
} else if (args[0] && STREQ(args[0], ISCSIADM) &&
} else if (args[0] && STREQ(args[0], "iscsiadm") &&
args[1] && STREQ(args[1], "--mode") &&
args[2] && STREQ(args[2], "node") &&
args[3] && STREQ(args[3], "--portal") &&