From: Martin Wilck <mwilck@xxxxxxxx> The command completion never worked, because the handlers array wasn't initialized in client mode. The handlers array is now also required in multipathc, but it doesn't need the actual handler functions. To keep multipathc as small as possible, we just add a handler table with NULL handler functions. Signed-off-by: Martin Wilck <mwilck@xxxxxxxx> --- multipathd/callbacks.c | 60 +++++++++++++++++++++++++++++++++++++ multipathd/cli.c | 2 ++ multipathd/cli_handlers.c | 62 ++------------------------------------- multipathd/main.c | 1 - multipathd/multipathc.c | 3 ++ 5 files changed, 67 insertions(+), 61 deletions(-) create mode 100644 multipathd/callbacks.c diff --git a/multipathd/callbacks.c b/multipathd/callbacks.c new file mode 100644 index 0000000..0bd76b7 --- /dev/null +++ b/multipathd/callbacks.c @@ -0,0 +1,60 @@ +void init_handler_callbacks(void) +{ + set_handler_callback(LIST+PATHS, HANDLER(cli_list_paths)); + set_handler_callback(LIST+PATHS+FMT, HANDLER(cli_list_paths_fmt)); + set_handler_callback(LIST+PATHS+RAW+FMT, HANDLER(cli_list_paths_raw)); + set_handler_callback(LIST+PATH, HANDLER(cli_list_path)); + set_handler_callback(LIST+MAPS, HANDLER(cli_list_maps)); + set_handler_callback(LIST+STATUS, HANDLER(cli_list_status)); + set_unlocked_handler_callback(LIST+DAEMON, HANDLER(cli_list_daemon)); + set_handler_callback(LIST+MAPS+STATUS, HANDLER(cli_list_maps_status)); + set_handler_callback(LIST+MAPS+STATS, HANDLER(cli_list_maps_stats)); + set_handler_callback(LIST+MAPS+FMT, HANDLER(cli_list_maps_fmt)); + set_handler_callback(LIST+MAPS+RAW+FMT, HANDLER(cli_list_maps_raw)); + set_handler_callback(LIST+MAPS+TOPOLOGY, HANDLER(cli_list_maps_topology)); + set_handler_callback(LIST+TOPOLOGY, HANDLER(cli_list_maps_topology)); + set_handler_callback(LIST+MAPS+JSON, HANDLER(cli_list_maps_json)); + set_handler_callback(LIST+MAP+TOPOLOGY, HANDLER(cli_list_map_topology)); + set_handler_callback(LIST+MAP+FMT, HANDLER(cli_list_map_fmt)); + set_handler_callback(LIST+MAP+RAW+FMT, HANDLER(cli_list_map_fmt)); + set_handler_callback(LIST+MAP+JSON, HANDLER(cli_list_map_json)); + set_handler_callback(LIST+CONFIG+LOCAL, HANDLER(cli_list_config_local)); + set_handler_callback(LIST+CONFIG, HANDLER(cli_list_config)); + set_handler_callback(LIST+BLACKLIST, HANDLER(cli_list_blacklist)); + set_handler_callback(LIST+DEVICES, HANDLER(cli_list_devices)); + set_handler_callback(LIST+WILDCARDS, HANDLER(cli_list_wildcards)); + set_handler_callback(RESET+MAPS+STATS, HANDLER(cli_reset_maps_stats)); + set_handler_callback(RESET+MAP+STATS, HANDLER(cli_reset_map_stats)); + set_handler_callback(ADD+PATH, HANDLER(cli_add_path)); + set_handler_callback(DEL+PATH, HANDLER(cli_del_path)); + set_handler_callback(ADD+MAP, HANDLER(cli_add_map)); + set_handler_callback(DEL+MAP, HANDLER(cli_del_map)); + set_handler_callback(DEL+MAPS, HANDLER(cli_del_maps)); + set_handler_callback(SWITCH+MAP+GROUP, HANDLER(cli_switch_group)); + set_unlocked_handler_callback(RECONFIGURE, HANDLER(cli_reconfigure)); + set_unlocked_handler_callback(RECONFIGURE+ALL, HANDLER(cli_reconfigure_all)); + set_handler_callback(SUSPEND+MAP, HANDLER(cli_suspend)); + set_handler_callback(RESUME+MAP, HANDLER(cli_resume)); + set_handler_callback(RESIZE+MAP, HANDLER(cli_resize)); + set_handler_callback(RELOAD+MAP, HANDLER(cli_reload)); + set_handler_callback(RESET+MAP, HANDLER(cli_reassign)); + set_handler_callback(REINSTATE+PATH, HANDLER(cli_reinstate)); + set_handler_callback(FAIL+PATH, HANDLER(cli_fail)); + set_handler_callback(DISABLEQ+MAP, HANDLER(cli_disable_queueing)); + set_handler_callback(RESTOREQ+MAP, HANDLER(cli_restore_queueing)); + set_handler_callback(DISABLEQ+MAPS, HANDLER(cli_disable_all_queueing)); + set_handler_callback(RESTOREQ+MAPS, HANDLER(cli_restore_all_queueing)); + set_unlocked_handler_callback(QUIT, HANDLER(cli_quit)); + set_unlocked_handler_callback(SHUTDOWN, HANDLER(cli_shutdown)); + set_handler_callback(GETPRSTATUS+MAP, HANDLER(cli_getprstatus)); + set_handler_callback(SETPRSTATUS+MAP, HANDLER(cli_setprstatus)); + set_handler_callback(UNSETPRSTATUS+MAP, HANDLER(cli_unsetprstatus)); + set_handler_callback(FORCEQ+DAEMON, HANDLER(cli_force_no_daemon_q)); + set_handler_callback(RESTOREQ+DAEMON, HANDLER(cli_restore_no_daemon_q)); + set_handler_callback(GETPRKEY+MAP, HANDLER(cli_getprkey)); + set_handler_callback(SETPRKEY+MAP+KEY, HANDLER(cli_setprkey)); + set_handler_callback(UNSETPRKEY+MAP, HANDLER(cli_unsetprkey)); + set_handler_callback(SETMARGINAL+PATH, HANDLER(cli_set_marginal)); + set_handler_callback(UNSETMARGINAL+PATH, HANDLER(cli_unset_marginal)); + set_handler_callback(UNSETMARGINAL+MAP, HANDLER(cli_unset_all_marginal)); +} diff --git a/multipathd/cli.c b/multipathd/cli.c index d1bfeee..5d25ddb 100644 --- a/multipathd/cli.c +++ b/multipathd/cli.c @@ -14,6 +14,7 @@ #include "mpath_cmd.h" #include "cli.h" +#include "cli_handlers.h" #include "debug.h" #include "strbuf.h" @@ -451,6 +452,7 @@ cli_init (void) { if (alloc_handlers()) return 1; + init_handler_callbacks(); return 0; } diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index 3d39967..5b8f647 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -1519,63 +1519,5 @@ static int cli_unset_all_marginal(void * v, struct strbuf *reply, void * data) return reload_and_sync_map(mpp, vecs, 0); } -void init_handler_callbacks(void) -{ - set_handler_callback(LIST+PATHS, cli_list_paths); - set_handler_callback(LIST+PATHS+FMT, cli_list_paths_fmt); - set_handler_callback(LIST+PATHS+RAW+FMT, cli_list_paths_raw); - set_handler_callback(LIST+PATH, cli_list_path); - set_handler_callback(LIST+MAPS, cli_list_maps); - set_handler_callback(LIST+STATUS, cli_list_status); - set_unlocked_handler_callback(LIST+DAEMON, cli_list_daemon); - set_handler_callback(LIST+MAPS+STATUS, cli_list_maps_status); - set_handler_callback(LIST+MAPS+STATS, cli_list_maps_stats); - set_handler_callback(LIST+MAPS+FMT, cli_list_maps_fmt); - set_handler_callback(LIST+MAPS+RAW+FMT, cli_list_maps_raw); - set_handler_callback(LIST+MAPS+TOPOLOGY, cli_list_maps_topology); - set_handler_callback(LIST+TOPOLOGY, cli_list_maps_topology); - set_handler_callback(LIST+MAPS+JSON, cli_list_maps_json); - set_handler_callback(LIST+MAP+TOPOLOGY, cli_list_map_topology); - set_handler_callback(LIST+MAP+FMT, cli_list_map_fmt); - set_handler_callback(LIST+MAP+RAW+FMT, cli_list_map_fmt); - set_handler_callback(LIST+MAP+JSON, cli_list_map_json); - set_handler_callback(LIST+CONFIG+LOCAL, cli_list_config_local); - set_handler_callback(LIST+CONFIG, cli_list_config); - set_handler_callback(LIST+BLACKLIST, cli_list_blacklist); - set_handler_callback(LIST+DEVICES, cli_list_devices); - set_handler_callback(LIST+WILDCARDS, cli_list_wildcards); - set_handler_callback(RESET+MAPS+STATS, cli_reset_maps_stats); - set_handler_callback(RESET+MAP+STATS, cli_reset_map_stats); - set_handler_callback(ADD+PATH, cli_add_path); - set_handler_callback(DEL+PATH, cli_del_path); - set_handler_callback(ADD+MAP, cli_add_map); - set_handler_callback(DEL+MAP, cli_del_map); - set_handler_callback(DEL+MAPS, cli_del_maps); - set_handler_callback(SWITCH+MAP+GROUP, cli_switch_group); - set_unlocked_handler_callback(RECONFIGURE, cli_reconfigure); - set_unlocked_handler_callback(RECONFIGURE+ALL, cli_reconfigure_all); - set_handler_callback(SUSPEND+MAP, cli_suspend); - set_handler_callback(RESUME+MAP, cli_resume); - set_handler_callback(RESIZE+MAP, cli_resize); - set_handler_callback(RELOAD+MAP, cli_reload); - set_handler_callback(RESET+MAP, cli_reassign); - set_handler_callback(REINSTATE+PATH, cli_reinstate); - set_handler_callback(FAIL+PATH, cli_fail); - set_handler_callback(DISABLEQ+MAP, cli_disable_queueing); - set_handler_callback(RESTOREQ+MAP, cli_restore_queueing); - set_handler_callback(DISABLEQ+MAPS, cli_disable_all_queueing); - set_handler_callback(RESTOREQ+MAPS, cli_restore_all_queueing); - set_unlocked_handler_callback(QUIT, cli_quit); - set_unlocked_handler_callback(SHUTDOWN, cli_shutdown); - set_handler_callback(GETPRSTATUS+MAP, cli_getprstatus); - set_handler_callback(SETPRSTATUS+MAP, cli_setprstatus); - set_handler_callback(UNSETPRSTATUS+MAP, cli_unsetprstatus); - set_handler_callback(FORCEQ+DAEMON, cli_force_no_daemon_q); - set_handler_callback(RESTOREQ+DAEMON, cli_restore_no_daemon_q); - set_handler_callback(GETPRKEY+MAP, cli_getprkey); - set_handler_callback(SETPRKEY+MAP+KEY, cli_setprkey); - set_handler_callback(UNSETPRKEY+MAP, cli_unsetprkey); - set_handler_callback(SETMARGINAL+PATH, cli_set_marginal); - set_handler_callback(UNSETMARGINAL+PATH, cli_unset_marginal); - set_handler_callback(UNSETMARGINAL+MAP, cli_unset_all_marginal); -} +#define HANDLER(x) x +#include "callbacks.c" diff --git a/multipathd/main.c b/multipathd/main.c index 4a65359..ba52d39 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1797,7 +1797,6 @@ uxlsnrloop (void * ap) /* Tell main thread that thread has started */ post_config_state(DAEMON_CONFIGURE); - init_handler_callbacks(); umask(077); /* diff --git a/multipathd/multipathc.c b/multipathd/multipathc.c index 9d49655..b3f7db0 100644 --- a/multipathd/multipathc.c +++ b/multipathd/multipathc.c @@ -274,3 +274,6 @@ int main (int argc, const char * const argv[]) mpath_disconnect(fd); return 0; } + +#define HANDLER(x) NULL +#include "callbacks.c" -- 2.37.1 -- dm-devel mailing list dm-devel@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/dm-devel