[Pkg-iscsi-maintainers] [SCM] Debian Open-iSCSI Packaging branch, upstream-mnc, updated. 2.0-872-193-gde2c0e7

Mike Christie michaelc at cs.wisc.edu
Sat Apr 7 15:44:00 UTC 2012


The following commit has been merged in the upstream-mnc branch:
commit 2199c2c140f37eea4f5f6ce28789fb5348aca219
Author: Mike Christie <michaelc at cs.wisc.edu>
Date:   Sun Feb 26 02:39:58 2012 -0600

    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 ....

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);

-- 
Debian Open-iSCSI Packaging



More information about the Pkg-iscsi-maintainers mailing list