summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Christie <michaelc@cs.wisc.edu>2012-02-26 02:39:58 -0600
committerMike Christie <michaelc@cs.wisc.edu>2012-02-26 02:39:58 -0600
commit2199c2c140f37eea4f5f6ce28789fb5348aca219 (patch)
treee27a322e30d35459f6d51467c8c6bb965208c68c
parent8927ad34fc1e9eeea77e5faddca4cc66a1266da1 (diff)
downloadopen-iscsi-2199c2c140f37eea4f5f6ce28789fb5348aca219.tar.gz
iscsistart: allow any rec/iscsid.conf setting as arg
This patch allows users to pass in any record/iscsid.conf setting as a parameter to iscsistart. iscsistart --param $NAME=$VALUE .... example: iscsistart --param node.session.timeo.replacement_timeout=30 \ --param node.session.err_timeo.lu_reset_timeout=120 ....
-rw-r--r--doc/iscsistart.84
-rw-r--r--usr/idbm.c32
-rw-r--r--usr/idbm.h1
-rw-r--r--usr/iscsistart.c11
4 files changed, 46 insertions, 2 deletions
diff --git a/doc/iscsistart.8 b/doc/iscsistart.8
index 5dcecd3..3f8cbda 100644
--- a/doc/iscsistart.8
+++ b/doc/iscsistart.8
@@ -51,6 +51,10 @@ Bring up the network as specified by iBFT or OF
.BI [-f|--fwparam_print]
Print the iBFT or OF info to STDOUT
.TP
+.BI [-P|--param=]\fINAME=VALUE\fP
+Set the parameter with the name NAME to VALUE. NAME is one of the settings
+in the node record or iscsid.conf. Multiple params can be passed in.
+.TP
.BI [-h|--help]
Display this help and exit
.TP
diff --git a/usr/idbm.c b/usr/idbm.c
index 92219db..7ebd3d5 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -2320,6 +2320,38 @@ idbm_slp_defaults(struct iscsi_slp_config *cfg)
sizeof(struct iscsi_slp_config));
}
+int idbm_parse_param(char *param, struct node_rec *rec)
+{
+ char *name, *value;
+ recinfo_t *info;
+ int rc;
+
+ name = param;
+
+ value = strchr(param, '=');
+ if (!value) {
+ log_error("Invalid --param %s. Missing setting.\n", param);
+ return ISCSI_ERR_INVAL;
+ }
+ *value = '\0';
+ value++;
+
+ info = idbm_recinfo_alloc(MAX_KEYS);
+ if (!info) {
+ log_error("Could not allocate memory to setup params.\n");
+ return ISCSI_ERR_NOMEM;
+ }
+
+ idbm_recinfo_node(rec, info);
+
+ rc = idbm_rec_update_param(info, name, value, 0);
+ if (rc)
+ log_error("Could not set %s to %s. Check that %s is a "
+ "valid parameter.\n", name, value, name);
+ free(info);
+ return rc;
+}
+
int idbm_node_set_param(void *data, node_rec_t *rec)
{
struct db_set_param *param = data;
diff --git a/usr/idbm.h b/usr/idbm.h
index 6bca984..ced224d 100644
--- a/usr/idbm.h
+++ b/usr/idbm.h
@@ -139,6 +139,7 @@ extern int idbm_discovery_read(discovery_rec_t *rec, int type, char *addr,
extern int idbm_rec_read(node_rec_t *out_rec, char *target_name,
int tpgt, char *addr, int port,
struct iface_rec *iface);
+extern int idbm_parse_param(char *param, struct node_rec *rec);
extern int idbm_node_set_param(void *data, node_rec_t *rec);
extern int idbm_discovery_set_param(void *data, discovery_rec_t *rec);
extern void idbm_node_setup_defaults(node_rec_t *rec);
diff --git a/usr/iscsistart.c b/usr/iscsistart.c
index 6046ac6..5bfed08 100644
--- a/usr/iscsistart.c
+++ b/usr/iscsistart.c
@@ -76,6 +76,7 @@ static struct option const long_options[] = {
{"fwparam_connect", no_argument, NULL, 'b'},
{"fwparam_network", no_argument, NULL, 'N'},
{"fwparam_print", no_argument, NULL, 'f'},
+ {"param", required_argument, NULL, 'P'},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'},
{NULL, 0, NULL, 0},
@@ -103,6 +104,7 @@ Open-iSCSI initiator.\n\
-b, --fwparam_connect create a session to the target using iBFT or OF\n\
-N, --fwparam_network bring up the network as specified by iBFT or OF\n\
-f, --fwparam_print print the iBFT or OF info to STDOUT \n\
+ -P, --param=NAME=VALUE set parameter with the name NAME to VALUE\n\
-h, --help display this help and exit\n\
-v, --version display version and exit\n\
");
@@ -241,7 +243,7 @@ int main(int argc, char *argv[])
struct boot_context *context, boot_context;
struct sigaction sa_old;
struct sigaction sa_new;
- int control_fd, mgmt_ipc_fd;
+ int control_fd, mgmt_ipc_fd, err;
pid_t pid;
idbm_node_setup_defaults(&config_rec);
@@ -262,7 +264,7 @@ int main(int argc, char *argv[])
if (iscsi_sysfs_check_class_version())
exit(ISCSI_ERR_SYSFS_LOOKUP);
- while ((ch = getopt_long(argc, argv, "i:t:g:a:p:d:u:w:U:W:bNfvh",
+ while ((ch = getopt_long(argc, argv, "P:i:t:g:a:p:d:u:w:U:W:bNfvh",
long_options, &longindex)) >= 0) {
switch (ch) {
case 'i':
@@ -341,6 +343,11 @@ int main(int argc, char *argv[])
fw_free_targets(&targets);
exit(0);
+ case 'P':
+ err = idbm_parse_param(optarg, &config_rec);
+ if (err)
+ exit(err);
+ break;
case 'v':
printf("%s version %s\n", program_name,
ISCSI_VERSION_STR);