]> git.proxmox.com Git - corosync-pve.git/blob - patches/0005-cfgtool-Improve-link-status-display.patch
add patches for Corosync 3.x
[corosync-pve.git] / patches / 0005-cfgtool-Improve-link-status-display.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= <f.gruenbichler@proxmox.com>
3 Date: Wed, 22 May 2019 12:24:45 +0200
4 Subject: [PATCH] cfgtool: Improve link status display
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 cherry-picked from upstream master
10
11 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
12 ---
13 .../cfgtool-Improve-link-status-display.patch | 134 ++++++++++++++++++
14 debian/patches/series | 1 +
15 2 files changed, 135 insertions(+)
16 create mode 100644 debian/patches/cfgtool-Improve-link-status-display.patch
17
18 diff --git a/debian/patches/cfgtool-Improve-link-status-display.patch b/debian/patches/cfgtool-Improve-link-status-display.patch
19 new file mode 100644
20 index 00000000..93ee9937
21 --- /dev/null
22 +++ b/debian/patches/cfgtool-Improve-link-status-display.patch
23 @@ -0,0 +1,134 @@
24 +From: Christine Caulfield <ccaulfie@redhat.com>
25 +Date: Tue, 22 Jan 2019 10:06:29 +0000
26 +Subject: cfgtool: Improve link status display
27 +
28 +Now show the nodeids properly, rather than node indexes which were
29 +annoying and unhelpful.
30 +
31 +Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
32 +Reviewed-by: Jan Friesse <jfriesse@redhat.com>
33 +(cherry picked from commit c0d14485c3ebdeb2332f7c48acd155163e5b7fc1)
34 +---
35 + tools/Makefile.am | 2 +-
36 + tools/corosync-cfgtool.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++--
37 + 2 files changed, 55 insertions(+), 3 deletions(-)
38 +
39 +diff --git a/tools/Makefile.am b/tools/Makefile.am
40 +index 7a9ab04..0793884 100644
41 +--- a/tools/Makefile.am
42 ++++ b/tools/Makefile.am
43 +@@ -58,7 +58,7 @@ corosync-blackbox: corosync-blackbox.sh
44 +
45 + corosync_cmapctl_LDADD = $(LIBQB_LIBS) $(top_builddir)/lib/libcmap.la
46 +
47 +-corosync_cfgtool_LDADD = $(LIBQB_LIBS) $(top_builddir)/lib/libcfg.la
48 ++corosync_cfgtool_LDADD = $(LIBQB_LIBS) $(top_builddir)/lib/libcfg.la $(top_builddir)/lib/libcmap.la
49 +
50 + corosync_cpgtool_LDADD = $(LIBQB_LIBS) $(top_builddir)/lib/libcfg.la \
51 + $(top_builddir)/lib/libcpg.la
52 +diff --git a/tools/corosync-cfgtool.c b/tools/corosync-cfgtool.c
53 +index c138085..ed29694 100644
54 +--- a/tools/corosync-cfgtool.c
55 ++++ b/tools/corosync-cfgtool.c
56 +@@ -50,6 +50,7 @@
57 + #include <corosync/corotypes.h>
58 + #include <corosync/totem/totem.h>
59 + #include <corosync/cfg.h>
60 ++#include <corosync/cmap.h>
61 +
62 + #define cs_repeat(result, max, code) \
63 + do { \
64 +@@ -75,16 +76,33 @@ enum user_action {
65 + ACTION_KILL_NODE,
66 + };
67 +
68 ++static int node_compare(const void *aptr, const void *bptr)
69 ++{
70 ++ uint32_t a,b;
71 ++
72 ++ a = *(uint32_t *)aptr;
73 ++ b = *(uint32_t *)bptr;
74 ++
75 ++ return a > b;
76 ++}
77 ++
78 + static int
79 + linkstatusget_do (char *interface_name, int brief)
80 + {
81 + cs_error_t result;
82 + corosync_cfg_handle_t handle;
83 ++ cmap_handle_t cmap_handle;
84 + unsigned int interface_count;
85 + char **interface_names;
86 + char **interface_status;
87 ++ uint32_t nodeid_list[KNET_MAX_HOST];
88 ++ char iter_key[CMAP_KEYNAME_MAXLEN];
89 + unsigned int i;
90 ++ cmap_iter_handle_t iter;
91 + unsigned int nodeid;
92 ++ unsigned int node_pos;
93 ++ cmap_value_types_t type;
94 ++ size_t value_len;
95 + int rc = 0;
96 + int len, s = 0, t;
97 +
98 +@@ -95,6 +113,37 @@ linkstatusget_do (char *interface_name, int brief)
99 + exit (1);
100 + }
101 +
102 ++ result = cmap_initialize (&cmap_handle);
103 ++ if (result != CS_OK) {
104 ++ printf ("Could not initialize corosync cmap API error %d\n", result);
105 ++ exit (1);
106 ++ }
107 ++ /* Get a list of nodes. We do it this way rather than using votequorum as cfgtool
108 ++ * needs to be independent of quorum type
109 ++ */
110 ++ result = cmap_iter_init(cmap_handle, "nodelist.node.", &iter);
111 ++ if (result != CS_OK) {
112 ++ printf ("Could not get nodelist from cmap. error %d\n", result);
113 ++ exit (1);
114 ++ }
115 ++
116 ++ while ((cmap_iter_next(cmap_handle, iter, iter_key, &value_len, &type)) == CS_OK) {
117 ++ result = sscanf(iter_key, "nodelist.node.%u.nodeid", &node_pos);
118 ++ if (result != 1) {
119 ++ continue;
120 ++ }
121 ++ if (cmap_get_uint32(cmap_handle, iter_key, &nodeid) == CS_OK) {
122 ++ nodeid_list[s++] = nodeid;
123 ++ }
124 ++ }
125 ++
126 ++ /* totemknet returns nodes in nodeid order - even though it doesn't tell us
127 ++ what the nodeid is. So sort our node list and we can then look up
128 ++ knet node pos to get an actual nodeid.
129 ++ Yep, I really should have totally rewritten the cfg interface for this.
130 ++ */
131 ++ qsort(nodeid_list, s, sizeof(uint32_t), node_compare);
132 ++
133 + result = corosync_cfg_local_get(handle, &nodeid);
134 + if (result != CS_OK) {
135 + printf ("Could not get the local node id, the error is: %d\n", result);
136 +@@ -134,9 +183,11 @@ linkstatusget_do (char *interface_name, int brief)
137 + (!strstr(interface_status[i], "FAULTY"))) {
138 + len = strlen(interface_status[i]);
139 + printf ("\tstatus:\n");
140 +- while(s < len) {
141 ++ while (s < len) {
142 ++ nodeid = nodeid_list[s];
143 + t = interface_status[i][s] - '0';
144 +- printf("\t\tnode %d:\t", s++);
145 ++ s++;
146 ++ printf("\t\tnodeid %2d:\t", nodeid);
147 + printf("link enabled:%d\t", t&1? 1 : 0);
148 + printf("link connected:%d\n", t&2? 1: 0);
149 + }
150 +@@ -157,6 +208,7 @@ linkstatusget_do (char *interface_name, int brief)
151 + free(interface_names);
152 + }
153 +
154 ++ (void)cmap_finalize (cmap_handle);
155 + (void)corosync_cfg_finalize (handle);
156 + return rc;
157 + }
158 diff --git a/debian/patches/series b/debian/patches/series
159 index fcba2944..32007175 100644
160 --- a/debian/patches/series
161 +++ b/debian/patches/series
162 @@ -6,3 +6,4 @@ AC_PROG_SED-is-already-present.patch
163 Use-the-SED-variable-provided-by-configure.patch
164 Use-the-AWK-variable-provided-by-configure.patch
165 pve__only-start-corosync.service-if-conf-exists.patch
166 +cfgtool-Improve-link-status-display.patch