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

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