[DRBD-user] [PATCH] Fixes malformed json output of paths in drbdsetup show.

Anton Tykhyy atykhyy at gmail.com
Thu Feb 13 12:16:40 CET 2020


This is seen both with standalone connections without paths, and in connections
with paths that are not standalone (paths list ends with a trailing comma).
To reproduce the bug:
drbdsetup new-resource test 0
drbdsetup new-minor test 0 0
drbdsetup new-peer test 1 --protocol=C
drbdsetup show --json test | jq
# parse error: Expected another key-value pair at line 17, column 13
---
 user/v9/drbdsetup.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/user/v9/drbdsetup.c b/user/v9/drbdsetup.c
index 4798cf62..95b58160 100644
--- a/user/v9/drbdsetup.c
+++ b/user/v9/drbdsetup.c
@@ -2190,14 +2190,12 @@ static void show_connection_json(struct
connections_list *connection, struct pee
 {
        struct peer_devices_list *peer_device;

-       printI(QUOTED("_peer_node_id") ": %d,\n",
connection->ctx.ctx_peer_node_id);
-
        bool has_disk_options =
connection_has_disk_options(connection->ctx.ctx_peer_node_id,
peer_devices);

        print_paths(connection);
        if (connection->info.conn_connection_state == C_STANDALONE)
                printI(QUOTED("_is_standalone") ": true,\n");
-       print_options_json(connection->net_conf,
&show_net_options_ctx, "net", false, has_disk_options);
+       print_options_json(connection->net_conf,
&show_net_options_ctx, "net", false, true);

        if (has_disk_options)
        {
@@ -2225,8 +2223,10 @@ static void show_connection_json(struct
connections_list *connection, struct pee
                                printed++;
                        }
                }
-               printI("]\n");
+               printI("],\n");
        }
+
+       printI(QUOTED("_peer_node_id") ": %d\n",
connection->ctx.ctx_peer_node_id);
 }

 static void show_volume_json(struct devices_list *device)
--
2.21.0.windows.1


More information about the drbd-user mailing list