Blame SOURCES/0169-UPBZ-1353357-json-output.patch

4ae388
---
4ae388
 libmultipath/print.c      |  222 ++++++++++++++++++++++++++++++++++++++++++++++
4ae388
 libmultipath/print.h      |   61 ++++++++++++
4ae388
 multipathd/cli.c          |    3 
4ae388
 multipathd/cli.h          |    2 
4ae388
 multipathd/cli_handlers.c |   93 +++++++++++++++++++
4ae388
 multipathd/cli_handlers.h |    2 
4ae388
 multipathd/main.c         |    2 
4ae388
 multipathd/multipathd.8   |    9 +
4ae388
 8 files changed, 393 insertions(+), 1 deletion(-)
4ae388
4ae388
Index: multipath-tools-130222/libmultipath/print.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/libmultipath/print.c
4ae388
+++ multipath-tools-130222/libmultipath/print.c
4ae388
@@ -269,6 +269,61 @@ snprint_multipath_vpr (char * buff, size
4ae388
 			pp->vendor_id, pp->product_id);
4ae388
 }
4ae388
 
4ae388
+
4ae388
+static int
4ae388
+snprint_multipath_vend (char * buff, size_t len, struct multipath * mpp)
4ae388
+{
4ae388
+	struct pathgroup * pgp;
4ae388
+	struct path * pp;
4ae388
+	int i, j;
4ae388
+
4ae388
+	vector_foreach_slot(mpp->pg, pgp, i) {
4ae388
+		if (!pgp)
4ae388
+			continue;
4ae388
+		vector_foreach_slot(pgp->paths, pp, j) {
4ae388
+			if (strlen(pp->vendor_id))
4ae388
+				return snprintf(buff, len, "%s", pp->vendor_id);
4ae388
+		}
4ae388
+	}
4ae388
+	return snprintf(buff, len, "##");
4ae388
+}
4ae388
+
4ae388
+static int
4ae388
+snprint_multipath_prod (char * buff, size_t len, struct multipath * mpp)
4ae388
+{
4ae388
+	struct pathgroup * pgp;
4ae388
+	struct path * pp;
4ae388
+	int i, j;
4ae388
+
4ae388
+	vector_foreach_slot(mpp->pg, pgp, i) {
4ae388
+		if (!pgp)
4ae388
+			continue;
4ae388
+		vector_foreach_slot(pgp->paths, pp, j) {
4ae388
+			if (strlen(pp->product_id))
4ae388
+				return snprintf(buff, len, "%s", pp->product_id);
4ae388
+		}
4ae388
+	}
4ae388
+	return snprintf(buff, len, "##");
4ae388
+}
4ae388
+
4ae388
+static int
4ae388
+snprint_multipath_rev (char * buff, size_t len, struct multipath * mpp)
4ae388
+{
4ae388
+	struct pathgroup * pgp;
4ae388
+	struct path * pp;
4ae388
+	int i, j;
4ae388
+
4ae388
+	vector_foreach_slot(mpp->pg, pgp, i) {
4ae388
+		if (!pgp)
4ae388
+			continue;
4ae388
+		vector_foreach_slot(pgp->paths, pp, j) {
4ae388
+			if (strlen(pp->rev))
4ae388
+				return snprintf(buff, len, "%s", pp->rev);
4ae388
+		}
4ae388
+	}
4ae388
+	return snprintf(buff, len, "##");
4ae388
+}
4ae388
+
4ae388
 static int
4ae388
 snprint_action (char * buff, size_t len, struct multipath * mpp)
4ae388
 {
4ae388
@@ -561,6 +616,9 @@ struct multipath_data mpd[] = {
4ae388
 	{'3', "total_q_time",  0, snprint_total_q_time},
4ae388
 	{'4', "q_timeouts",    0, snprint_q_timeouts},
4ae388
 	{'s', "vend/prod/rev", 0, snprint_multipath_vpr},
4ae388
+	{'v', "vend",          0, snprint_multipath_vend},
4ae388
+	{'p', "prod",          0, snprint_multipath_prod},
4ae388
+	{'e', "rev",           0, snprint_multipath_rev},
4ae388
 	{0, NULL, 0 , NULL}
4ae388
 };
4ae388
 
4ae388
@@ -983,6 +1041,170 @@ snprint_multipath_topology (char * buff,
4ae388
 	return fwd;
4ae388
 }
4ae388
 
4ae388
+static int
4ae388
+snprint_json (char * buff, int len, int indent, char *json_str)
4ae388
+{
4ae388
+	int fwd = 0, i;
4ae388
+
4ae388
+	for (i = 0; i < indent; i++) {
4ae388
+		fwd += snprintf(buff + fwd, len - fwd, PRINT_JSON_INDENT);
4ae388
+		if (fwd > len)
4ae388
+			return fwd;
4ae388
+	}
4ae388
+
4ae388
+	fwd += snprintf(buff + fwd, len - fwd, "%s", json_str);
4ae388
+	return fwd;
4ae388
+}
4ae388
+
4ae388
+static int
4ae388
+snprint_json_header (char * buff, int len)
4ae388
+{
4ae388
+	int fwd = 0;
4ae388
+
4ae388
+	fwd +=  snprint_json(buff, len, 0, PRINT_JSON_START_ELEM);
4ae388
+	if (fwd > len)
4ae388
+		return fwd;
4ae388
+
4ae388
+	fwd +=  snprintf(buff + fwd, len  - fwd, PRINT_JSON_START_VERSION,
4ae388
+			PRINT_JSON_MAJOR_VERSION, PRINT_JSON_MINOR_VERSION);
4ae388
+	return fwd;
4ae388
+}
4ae388
+
4ae388
+static int
4ae388
+snprint_json_elem_footer (char * buff, int len, int indent, int last)
4ae388
+{
4ae388
+	int fwd = 0, i;
4ae388
+
4ae388
+	for (i = 0; i < indent; i++) {
4ae388
+		fwd += snprintf(buff + fwd, len - fwd, PRINT_JSON_INDENT);
4ae388
+		if (fwd > len)
4ae388
+			return fwd;
4ae388
+	}
4ae388
+
4ae388
+	if (last == 1)
4ae388
+		fwd += snprintf(buff + fwd, len - fwd, "%s", PRINT_JSON_END_LAST_ELEM);
4ae388
+	else
4ae388
+		fwd += snprintf(buff + fwd, len - fwd, "%s", PRINT_JSON_END_ELEM);
4ae388
+	return fwd;
4ae388
+}
4ae388
+
4ae388
+static int
4ae388
+snprint_multipath_fields_json (char * buff, int len,
4ae388
+		struct multipath * mpp, int last)
4ae388
+{
4ae388
+	int i, j, fwd = 0;
4ae388
+	struct path *pp;
4ae388
+	struct pathgroup *pgp;
4ae388
+
4ae388
+	fwd += snprint_multipath(buff, len, PRINT_JSON_MAP, mpp, 0);
4ae388
+	if (fwd > len)
4ae388
+		return fwd;
4ae388
+
4ae388
+	fwd += snprint_json(buff + fwd, len - fwd, 2, PRINT_JSON_START_GROUPS);
4ae388
+	if (fwd > len)
4ae388
+		return fwd;
4ae388
+
4ae388
+	vector_foreach_slot (mpp->pg, pgp, i) {
4ae388
+
4ae388
+		pgp->selector = mpp->selector;
4ae388
+		fwd += snprint_pathgroup(buff + fwd, len - fwd, PRINT_JSON_GROUP, pgp);
4ae388
+		if (fwd > len)
4ae388
+			return fwd;
4ae388
+
4ae388
+		fwd += snprintf(buff + fwd, len - fwd, PRINT_JSON_GROUP_NUM, i + 1);
4ae388
+		if (fwd > len)
4ae388
+			return fwd;
4ae388
+
4ae388
+		fwd += snprint_json(buff + fwd, len - fwd, 3, PRINT_JSON_START_PATHS);
4ae388
+		if (fwd > len)
4ae388
+			return fwd;
4ae388
+
4ae388
+		vector_foreach_slot (pgp->paths, pp, j) {
4ae388
+			fwd += snprint_path(buff + fwd, len - fwd, PRINT_JSON_PATH, pp, 0);
4ae388
+			if (fwd > len)
4ae388
+				return fwd;
4ae388
+
4ae388
+			fwd += snprint_json_elem_footer(buff + fwd,
4ae388
+					len - fwd, 3, j + 1 == VECTOR_SIZE(pgp->paths));
4ae388
+			if (fwd > len)
4ae388
+				return fwd;
4ae388
+		}
4ae388
+		fwd += snprint_json(buff + fwd, len - fwd, 0, PRINT_JSON_END_ARRAY);
4ae388
+		if (fwd > len)
4ae388
+			return fwd;
4ae388
+
4ae388
+		fwd +=  snprint_json_elem_footer(buff + fwd,
4ae388
+				len - fwd, 2, i + 1 == VECTOR_SIZE(mpp->pg));
4ae388
+		if (fwd > len)
4ae388
+			return fwd;
4ae388
+	}
4ae388
+
4ae388
+	fwd += snprint_json(buff + fwd, len - fwd, 0, PRINT_JSON_END_ARRAY);
4ae388
+	if (fwd > len)
4ae388
+		return fwd;
4ae388
+
4ae388
+	fwd += snprint_json_elem_footer(buff + fwd, len - fwd, 1, last);
4ae388
+	return fwd;
4ae388
+}
4ae388
+
4ae388
+int
4ae388
+snprint_multipath_map_json (char * buff, int len,
4ae388
+		struct multipath * mpp, int last){
4ae388
+	int fwd = 0;
4ae388
+
4ae388
+	fwd +=  snprint_json_header(buff, len);
4ae388
+	if (fwd > len)
4ae388
+		return len;
4ae388
+
4ae388
+	fwd +=  snprint_json(buff + fwd, len - fwd, 0, PRINT_JSON_START_MAP);
4ae388
+	if (fwd > len)
4ae388
+		return len;
4ae388
+
4ae388
+	fwd += snprint_multipath_fields_json(buff + fwd, len - fwd, mpp, 1);
4ae388
+	if (fwd > len)
4ae388
+		return len;
4ae388
+
4ae388
+	fwd +=  snprint_json(buff + fwd, len - fwd, 0, "\n");
4ae388
+	if (fwd > len)
4ae388
+		return len;
4ae388
+
4ae388
+	fwd +=  snprint_json(buff + fwd, len - fwd, 0, PRINT_JSON_END_LAST);
4ae388
+	if (fwd > len)
4ae388
+		return len;
4ae388
+	return fwd;
4ae388
+}
4ae388
+
4ae388
+int
4ae388
+snprint_multipath_topology_json (char * buff, int len, struct vectors * vecs)
4ae388
+{
4ae388
+	int i, fwd = 0;
4ae388
+	struct multipath * mpp;
4ae388
+
4ae388
+	fwd +=  snprint_json_header(buff, len);
4ae388
+	if (fwd > len)
4ae388
+		return len;
4ae388
+
4ae388
+	fwd +=  snprint_json(buff + fwd, len  - fwd, 1, PRINT_JSON_START_MAPS);
4ae388
+	if (fwd > len)
4ae388
+		return len;
4ae388
+
4ae388
+	vector_foreach_slot(vecs->mpvec, mpp, i) {
4ae388
+		fwd += snprint_multipath_fields_json(buff + fwd, len - fwd,
4ae388
+				mpp, i + 1 == VECTOR_SIZE(vecs->mpvec));
4ae388
+		if (fwd > len)
4ae388
+			return len;
4ae388
+	}
4ae388
+
4ae388
+	fwd +=  snprint_json(buff + fwd, len - fwd, 0, PRINT_JSON_END_ARRAY);
4ae388
+	if (fwd > len)
4ae388
+		return len;
4ae388
+
4ae388
+	fwd +=  snprint_json(buff + fwd, len - fwd, 0, PRINT_JSON_END_LAST);
4ae388
+	if (fwd > len)
4ae388
+		return len;
4ae388
+	return fwd;
4ae388
+}
4ae388
+
4ae388
 static int
4ae388
 snprint_hwentry (char * buff, int len, struct hwentry * hwe)
4ae388
 {
4ae388
Index: multipath-tools-130222/libmultipath/print.h
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/libmultipath/print.h
4ae388
+++ multipath-tools-130222/libmultipath/print.h
4ae388
@@ -7,6 +7,63 @@
4ae388
 #define PRINT_MAP_PROPS      "size=%S features='%f' hwhandler='%h' wp=%r"
4ae388
 #define PRINT_PG_INDENT      "policy='%s' prio=%p status=%t"
4ae388
 
4ae388
+#define PRINT_JSON_MULTIPLIER     5
4ae388
+#define PRINT_JSON_MAJOR_VERSION  0
4ae388
+#define PRINT_JSON_MINOR_VERSION  1
4ae388
+#define PRINT_JSON_START_VERSION  "   \"major_version\": %d,\n" \
4ae388
+                                  "   \"minor_version\": %d,\n"
4ae388
+#define PRINT_JSON_START_ELEM     "{\n"
4ae388
+#define PRINT_JSON_START_MAP      "   \"map\":"
4ae388
+#define PRINT_JSON_START_MAPS     "\"maps\": ["
4ae388
+#define PRINT_JSON_START_PATHS    "\"paths\": ["
4ae388
+#define PRINT_JSON_START_GROUPS   "\"path_groups\": ["
4ae388
+#define PRINT_JSON_END_ELEM       "},"
4ae388
+#define PRINT_JSON_END_LAST_ELEM  "}"
4ae388
+#define PRINT_JSON_END_LAST       "}\n"
4ae388
+#define PRINT_JSON_END_ARRAY      "]\n"
4ae388
+#define PRINT_JSON_INDENT    "   "
4ae388
+#define PRINT_JSON_MAP       "{\n" \
4ae388
+                             "      \"name\" : \"%n\",\n" \
4ae388
+                             "      \"uuid\" : \"%w\",\n" \
4ae388
+                             "      \"sysfs\" : \"%d\",\n" \
4ae388
+                             "      \"failback\" : \"%F\",\n" \
4ae388
+                             "      \"queueing\" : \"%Q\",\n" \
4ae388
+                             "      \"paths\" : %N,\n" \
4ae388
+                             "      \"write_prot\" : \"%r\",\n" \
4ae388
+                             "      \"dm_st\" : \"%t\",\n" \
4ae388
+                             "      \"features\" : \"%f\",\n" \
4ae388
+                             "      \"hwhandler\" : \"%h\",\n" \
4ae388
+                             "      \"action\" : \"%A\",\n" \
4ae388
+                             "      \"path_faults\" : %0,\n" \
4ae388
+                             "      \"vend\" : \"%v\",\n" \
4ae388
+                             "      \"prod\" : \"%p\",\n" \
4ae388
+                             "      \"rev\" : \"%e\",\n" \
4ae388
+                             "      \"switch_grp\" : %1,\n" \
4ae388
+                             "      \"map_loads\" : %2,\n" \
4ae388
+                             "      \"total_q_time\" : %3,\n" \
4ae388
+                             "      \"q_timeouts\" : %4,"
4ae388
+
4ae388
+#define PRINT_JSON_GROUP     "{\n" \
4ae388
+                             "         \"selector\" : \"%s\",\n" \
4ae388
+                             "         \"pri\" : %p,\n" \
4ae388
+                             "         \"dm_st\" : \"%t\","
4ae388
+
4ae388
+#define PRINT_JSON_GROUP_NUM "         \"group\" : %d,\n"
4ae388
+
4ae388
+#define PRINT_JSON_PATH      "{\n" \
4ae388
+                             "            \"dev\" : \"%d\",\n"\
4ae388
+                             "            \"dev_t\" : \"%D\",\n" \
4ae388
+                             "            \"dm_st\" : \"%t\",\n" \
4ae388
+                             "            \"dev_st\" : \"%o\",\n" \
4ae388
+                             "            \"chk_st\" : \"%T\",\n" \
4ae388
+                             "            \"checker\" : \"%c\",\n" \
4ae388
+                             "            \"pri\" : %p,\n" \
4ae388
+                             "            \"host_wwnn\" : \"%N\",\n" \
4ae388
+                             "            \"target_wwnn\" : \"%n\",\n" \
4ae388
+                             "            \"host_wwpn\" : \"%R\",\n" \
4ae388
+                             "            \"target_wwpn\" : \"%r\",\n" \
4ae388
+                             "            \"host_adapter\" : \"%a\""
4ae388
+
4ae388
 #define MAX_LINE_LEN  80
4ae388
 #define MAX_LINES     64
4ae388
 #define MAX_FIELD_LEN 64
4ae388
@@ -41,6 +98,10 @@ int snprint_path (char *, int, char *, s
4ae388
 int snprint_multipath (char *, int, char *, struct multipath *, int);
4ae388
 int snprint_multipath_topology (char *, int, struct multipath * mpp,
4ae388
 				int verbosity);
4ae388
+int snprint_multipath_topology_json (char * buff, int len,
4ae388
+				struct vectors * vecs);
4ae388
+int snprint_multipath_map_json (char * buff, int len,
4ae388
+				struct multipath * mpp, int last);
4ae388
 int snprint_defaults (char *, int);
4ae388
 int snprint_blacklist (char *, int);
4ae388
 int snprint_blacklist_except (char *, int);
4ae388
Index: multipath-tools-130222/multipathd/cli.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/multipathd/cli.c
4ae388
+++ multipath-tools-130222/multipathd/cli.c
4ae388
@@ -189,6 +189,7 @@ load_keys (void)
4ae388
 	r += add_key(keys, "setprstatus", SETPRSTATUS, 0);
4ae388
 	r += add_key(keys, "unsetprstatus", UNSETPRSTATUS, 0);
4ae388
 	r += add_key(keys, "format", FMT, 1);
4ae388
+	r += add_key(keys, "json", JSON, 0);
4ae388
 
4ae388
 	if (r) {
4ae388
 		free_keys(keys);
4ae388
@@ -473,8 +474,10 @@ cli_init (void) {
4ae388
 	add_handler(LIST+MAPS+FMT, NULL);
4ae388
 	add_handler(LIST+MAPS+RAW+FMT, NULL);
4ae388
 	add_handler(LIST+MAPS+TOPOLOGY, NULL);
4ae388
+	add_handler(LIST+MAPS+JSON, NULL);
4ae388
 	add_handler(LIST+TOPOLOGY, NULL);
4ae388
 	add_handler(LIST+MAP+TOPOLOGY, NULL);
4ae388
+	add_handler(LIST+MAP+JSON, NULL);
4ae388
 	add_handler(LIST+CONFIG, NULL);
4ae388
 	add_handler(LIST+BLACKLIST, NULL);
4ae388
 	add_handler(LIST+DEVICES, NULL);
4ae388
Index: multipath-tools-130222/multipathd/cli.h
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/multipathd/cli.h
4ae388
+++ multipath-tools-130222/multipathd/cli.h
4ae388
@@ -36,6 +36,7 @@ enum {
4ae388
 	__SETPRSTATUS,
4ae388
 	__UNSETPRSTATUS,
4ae388
 	__FMT,
4ae388
+	__JSON,
4ae388
 };
4ae388
 
4ae388
 #define LIST		(1 << __LIST)
4ae388
@@ -74,6 +75,7 @@ enum {
4ae388
 #define SETPRSTATUS	(1ULL << __SETPRSTATUS)
4ae388
 #define UNSETPRSTATUS	(1ULL << __UNSETPRSTATUS)
4ae388
 #define FMT		(1ULL << __FMT)
4ae388
+#define JSON		(1ULL << __JSON)
4ae388
 
4ae388
 #define INITIAL_REPLY_LEN	1200
4ae388
 
4ae388
Index: multipath-tools-130222/multipathd/cli_handlers.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/multipathd/cli_handlers.c
4ae388
+++ multipath-tools-130222/multipathd/cli_handlers.c
4ae388
@@ -127,6 +127,70 @@ show_maps_topology (char ** r, int * len
4ae388
 }
4ae388
 
4ae388
 int
4ae388
+show_maps_json (char ** r, int * len, struct vectors * vecs)
4ae388
+{
4ae388
+	int i;
4ae388
+	struct multipath * mpp;
4ae388
+	char * c;
4ae388
+	char * reply;
4ae388
+	unsigned int maxlen = INITIAL_REPLY_LEN *
4ae388
+			PRINT_JSON_MULTIPLIER * VECTOR_SIZE(vecs->mpvec);
4ae388
+	int again = 1;
4ae388
+
4ae388
+	vector_foreach_slot(vecs->mpvec, mpp, i) {
4ae388
+		if (update_multipath(vecs, mpp->alias, 0)) {
4ae388
+			return 1;
4ae388
+		}
4ae388
+	}
4ae388
+
4ae388
+	reply = MALLOC(maxlen);
4ae388
+
4ae388
+	while (again) {
4ae388
+		if (!reply)
4ae388
+			return 1;
4ae388
+
4ae388
+		c = reply;
4ae388
+
4ae388
+		c += snprint_multipath_topology_json(c, maxlen, vecs);
4ae388
+		again = ((c - reply) == maxlen);
4ae388
+
4ae388
+		REALLOC_REPLY(reply, again, maxlen);
4ae388
+	}
4ae388
+	*r = reply;
4ae388
+	*len = (int)(c - reply);
4ae388
+	return 0;
4ae388
+}
4ae388
+
4ae388
+int
4ae388
+show_map_json (char ** r, int * len, struct multipath * mpp,
4ae388
+		   struct vectors * vecs)
4ae388
+{
4ae388
+	char * c;
4ae388
+	char * reply;
4ae388
+	unsigned int maxlen = INITIAL_REPLY_LEN;
4ae388
+	int again = 1;
4ae388
+
4ae388
+	if (update_multipath(vecs, mpp->alias, 0))
4ae388
+		return 1;
4ae388
+	reply = MALLOC(maxlen);
4ae388
+
4ae388
+	while (again) {
4ae388
+		if (!reply)
4ae388
+			return 1;
4ae388
+
4ae388
+		c = reply;
4ae388
+
4ae388
+		c += snprint_multipath_map_json(c, maxlen, mpp, 1);
4ae388
+		again = ((c - reply) == maxlen);
4ae388
+
4ae388
+		REALLOC_REPLY(reply, again, maxlen);
4ae388
+	}
4ae388
+	*r = reply;
4ae388
+	*len = (int)(c - reply);
4ae388
+	return 0;
4ae388
+}
4ae388
+
4ae388
+int
4ae388
 show_config (char ** r, int * len)
4ae388
 {
4ae388
 	char * c;
4ae388
@@ -239,6 +303,35 @@ cli_list_maps_topology (void * v, char *
4ae388
 }
4ae388
 
4ae388
 int
4ae388
+cli_list_map_json (void * v, char ** reply, int * len, void * data)
4ae388
+{
4ae388
+	struct multipath * mpp;
4ae388
+	struct vectors * vecs = (struct vectors *)data;
4ae388
+	char * param = get_keyparam(v, MAP);
4ae388
+
4ae388
+	param = convert_dev(param, 0);
4ae388
+	get_path_layout(vecs->pathvec, 0);
4ae388
+	mpp = find_mp_by_str(vecs->mpvec, param);
4ae388
+
4ae388
+	if (!mpp)
4ae388
+		return 1;
4ae388
+
4ae388
+	condlog(3, "list multipath json %s (operator)", param);
4ae388
+
4ae388
+	return show_map_json(reply, len, mpp, vecs);
4ae388
+}
4ae388
+
4ae388
+int
4ae388
+cli_list_maps_json (void * v, char ** reply, int * len, void * data)
4ae388
+{
4ae388
+	struct vectors * vecs = (struct vectors *)data;
4ae388
+
4ae388
+	condlog(3, "list multipaths json (operator)");
4ae388
+
4ae388
+	return show_maps_json(reply, len, vecs);
4ae388
+}
4ae388
+
4ae388
+int
4ae388
 cli_list_wildcards (void * v, char ** reply, int * len, void * data)
4ae388
 {
4ae388
 	char * c;
4ae388
Index: multipath-tools-130222/multipathd/cli_handlers.h
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/multipathd/cli_handlers.h
4ae388
+++ multipath-tools-130222/multipathd/cli_handlers.h
4ae388
@@ -10,6 +10,8 @@ int cli_list_maps_status (void * v, char
4ae388
 int cli_list_maps_stats (void * v, char ** reply, int * len, void * data);
4ae388
 int cli_list_map_topology (void * v, char ** reply, int * len, void * data);
4ae388
 int cli_list_maps_topology (void * v, char ** reply, int * len, void * data);
4ae388
+int cli_list_map_json (void * v, char ** reply, int * len, void * data);
4ae388
+int cli_list_maps_json (void * v, char ** reply, int * len, void * data);
4ae388
 int cli_list_config (void * v, char ** reply, int * len, void * data);
4ae388
 int cli_list_blacklist (void * v, char ** reply, int * len, void * data);
4ae388
 int cli_list_devices (void * v, char ** reply, int * len, void * data);
4ae388
Index: multipath-tools-130222/multipathd/main.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/multipathd/main.c
4ae388
+++ multipath-tools-130222/multipathd/main.c
4ae388
@@ -981,7 +981,9 @@ uxlsnrloop (void * ap)
4ae388
 	set_handler_callback(LIST+MAPS+RAW+FMT, cli_list_maps_raw);
4ae388
 	set_handler_callback(LIST+MAPS+TOPOLOGY, cli_list_maps_topology);
4ae388
 	set_handler_callback(LIST+TOPOLOGY, cli_list_maps_topology);
4ae388
+	set_handler_callback(LIST+MAPS+JSON, cli_list_maps_json);
4ae388
 	set_handler_callback(LIST+MAP+TOPOLOGY, cli_list_map_topology);
4ae388
+	set_handler_callback(LIST+MAP+JSON, cli_list_map_json);
4ae388
 	set_handler_callback(LIST+CONFIG, cli_list_config);
4ae388
 	set_handler_callback(LIST+BLACKLIST, cli_list_blacklist);
4ae388
 	set_handler_callback(LIST+DEVICES, cli_list_devices);
4ae388
Index: multipath-tools-130222/multipathd/multipathd.8
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/multipathd/multipathd.8
4ae388
+++ multipath-tools-130222/multipathd/multipathd.8
4ae388
@@ -53,11 +53,15 @@ using a format string with multipath for
4ae388
 Show the status of all multipath devices that the multipathd is monitoring.
4ae388
 .TP
4ae388
 .B list|show maps|multipaths stats
4ae388
-Show some statistics of all multipath devices that the multipathd is monitoring.
4ae388
+Show some statistics of all multipath devices that multipathd is monitoring.
4ae388
 .TP
4ae388
 .B list|show maps|multipaths topology
4ae388
 Show the current multipath topology. Same as "multipath \-ll".
4ae388
 .TP
4ae388
+.B list|show maps|multipaths json
4ae388
+Show the multipath devices that multipathd is monitoring, using JSON
4ae388
+formatted output.
4ae388
+.TP
4ae388
 .B list|show topology
4ae388
 Show the current multipath topology. Same as "multipath \-ll".
4ae388
 .TP
4ae388
@@ -65,6 +69,9 @@ Show the current multipath topology. Sam
4ae388
 Show topology of a single multipath device specified by $map, e.g. 36005076303ffc56200000000000010aa.
4ae388
 This map could be obtained from "list maps".
4ae388
 .TP
4ae388
+.B list|show map|multipath $map json
4ae388
+Show a single multipath device specified by $map, using JSON formatted output.
4ae388
+.TP
4ae388
 .B list|show wildcards
4ae388
 Show the format wildcards used in interactive commands taking $format
4ae388
 .TP