From fc9817fec47db5a558ce9ed697841e02fdaa8ce0 Mon Sep 17 00:00:00 2001 From: Christine Caulfield Date: Tue, 8 Sep 2015 13:41:37 +0100 Subject: [PATCH] votequorum: Make display of qdevice more intuitive. corosync-quorumtool displays the votes of the qdevice whether or not it is active. This is confusing because if it is not active then the display looks like there is a vote being contributed to quorum when there is not. This patch displays 0 for qdevice votes if the device is present (but inactive) and adds the votes after the name. If the device is contributing votes then they are displayed as normal. Signed-off-by: Christine Caulfield --- test/testvotequorum2.c | 4 ++-- tools/corosync-quorumtool.c | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/test/testvotequorum2.c b/test/testvotequorum2.c index 0a2e926d..9a3fca95 100644 --- a/test/testvotequorum2.c +++ b/test/testvotequorum2.c @@ -100,7 +100,7 @@ static void usage(const char *command) printf(" -p Number of times to poll qdevice (default 0=infinte)\n"); printf(" -t Time (in seconds) to wait between polls (default=1)\n"); printf(" -n Name of quorum device (default QDEVICE)\n"); - printf(" -c Cast vote (default yes)\n"); + printf(" -c Don't cast vote (default is to cast vote)\n"); printf(" -q Don't print device status every poll time (default=will print)\n"); printf(" -m Master wins (default no)\n"); printf(" -1 Print status once and exit\n"); @@ -127,7 +127,7 @@ int main(int argc, char *argv[]) master_wins = 1; break; case 'c': - cast_vote = 1; + cast_vote = 0; break; case '1': once = 1; diff --git a/tools/corosync-quorumtool.c b/tools/corosync-quorumtool.c index 007fd5ec..835c19d4 100644 --- a/tools/corosync-quorumtool.c +++ b/tools/corosync-quorumtool.c @@ -416,6 +416,7 @@ static int compare_nodenames(const void *one, const void *two) static void display_nodes_data(nodeid_format_t nodeid_format, name_format_t name_format, sorttype_t sort_type) { int i, display_qdevice = 0; + unsigned int our_flags = 0; struct votequorum_info info[g_view_list_entries]; /* * cache node info because we need to parse them twice @@ -488,6 +489,7 @@ static void display_nodes_data(nodeid_format_t nodeid_format, name_format_t name printf("%s", g_view_list[i].name); if (g_view_list[i].node_id == our_nodeid) { printf(" (local)"); + our_flags = info[i].flags; } printf("\n"); } @@ -506,8 +508,21 @@ static void display_nodes_data(nodeid_format_t nodeid_format, name_format_t name } else { printf("0x%08x ", VOTEQUORUM_QDEVICE_NODEID); } - print_uint32_padded(info[0].qdevice_votes); - printf(" %s\n", info[0].qdevice_name); + /* If the quorum device is inactive on this node then show votes as 0 + so that the display is not confusing */ + if (our_flags & VOTEQUORUM_INFO_QDEVICE_CAST_VOTE) { + print_uint32_padded(info[0].qdevice_votes); + } + else { + print_uint32_padded(0); + } + printf(" %s", info[0].qdevice_name); + if (our_flags & VOTEQUORUM_INFO_QDEVICE_CAST_VOTE) { + printf("\n"); + } + else { + printf(" (votes %d)\n", info[0].qdevice_votes); + } } }