[stgt] [PATCH] add "debug" property to sytem mode; to change debug mode on the fy

Alexander Nezhinsky alexandern at voltaire.com
Wed Jun 16 14:20:10 CEST 2010


add "debug" property to --mode system;
allows to change debug mode on the fly;
two values: on/off are supported

invocation example:
  tgtadm --mode system --op update --name debug --value on

Signed-off-by: Alexander Nezhinsky <alexandern at voltaire.com>
---
 usr/mgmt.c   |   14 +++++++++++++-
 usr/tgtadm.c |   22 ++++++++++++++++++++++
 2 files changed, 35 insertions(+), 1 deletions(-)

diff --git a/usr/mgmt.c b/usr/mgmt.c
index 7dc9f30..37a5d0e 100644
--- a/usr/mgmt.c
+++ b/usr/mgmt.c
@@ -259,7 +259,19 @@ static int sys_mgmt(int lld_no, struct mgmt_task *mtask)

 	switch (req->op) {
 	case OP_UPDATE:
-		if (tgt_drivers[lld_no]->update)
+		if (!strncmp(mtask->buf,"debug=",6)) {
+			if (!strncmp(mtask->buf+6,"on",2)) {
+				is_debug=1;
+				err = 0;
+			}
+			else if (!strncmp(mtask->buf+6,"off",3)) {
+				is_debug=0;
+				err = 0;
+			}
+			if (!err)
+				eprintf("set debug to: %d\n", is_debug);
+		}
+		else if (tgt_drivers[lld_no]->update)
 			err = tgt_drivers[lld_no]->update(req->mode, req->op,
 							  req->tid,
 							  req->sid, req->lun,
diff --git a/usr/tgtadm.c b/usr/tgtadm.c
index 2fb419e..28ed754 100644
--- a/usr/tgtadm.c
+++ b/usr/tgtadm.c
@@ -554,6 +554,28 @@ int main(int argc, char **argv)
 		exit(EINVAL);
 	}

+	if (mode == MODE_SYSTEM) {
+		switch (op) {
+		case OP_UPDATE:
+			rc = verify_mode_params(argc, argv, "monvC");
+			if (rc) {
+				eprintf("system mode: option '-%c' is not "
+					"allowed/supported\n", rc);
+				exit(EINVAL);
+			}
+			if ((!name || !value)) {
+				eprintf("update operation requires 'name'"
+					" and 'value' options\n");
+				exit(EINVAL);
+			}
+			break;
+		default:
+			eprintf("option %d not supported in system mode\n", op);
+			exit(EINVAL);
+			break;
+		}
+	}
+
 	if (mode == MODE_TARGET) {
 		if ((tid <= 0 && (op != OP_SHOW))) {
 			eprintf("'tid' option is necessary\n");
--
1.6.5
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list