init.d/sanlock.sysconfig | 12 ++++++++++++ init.d/wdmd.sysconfig | 11 +++++++++++ src/sysconfig.sanlock | 12 ------------ wdmd/main.c | 33 ++++++++++++++++++++------------- wdmd/sysconfig.wdmd | 8 -------- 5 files changed, 43 insertions(+), 33 deletions(-)
New commits: commit d8a502cf22cd87aa546c5fcc79c1ce05593af280 Author: Federico Simoncelli fsimonce@redhat.com Date: Tue Nov 20 11:52:22 2012 -0500
wdmd: make the watchdog device configurable
Signed-off-by: Federico Simoncelli fsimonce@redhat.com
diff --git a/init.d/sanlock.sysconfig b/init.d/sanlock.sysconfig new file mode 100644 index 0000000..89b6fa3 --- /dev/null +++ b/init.d/sanlock.sysconfig @@ -0,0 +1,12 @@ +# SANLOCKOPTS -- set the command line options for the sanlock daemon +# See sanlock man page for full list of command line options. +# +# Include "-U sanlock -G sanlock" in the option string unless +# also changing the SANLOCKUSER above. +# +# To disable use of watchdog via wdmd +#SANLOCKOPTS="-U sanlock -G sanlock -w 0" +# +# To disable use of watchdog via wdmd and disable high priority features +#SANLOCKOPTS="-U sanlock -G sanlock -w 0 -h 0" + diff --git a/init.d/wdmd.sysconfig b/init.d/wdmd.sysconfig new file mode 100644 index 0000000..1ef8564 --- /dev/null +++ b/init.d/wdmd.sysconfig @@ -0,0 +1,11 @@ +# WDMDOPTS -- set the command line options for the wdmd daemon +# See wdmd man page for full list of command line options. +# +# Include "-G sanlock" in the option string. +# +# To enable use of test scripts +#WDMDOPTS="-G sanlock -S 1" +# +# To select a specific watchdog device +#WDMDOPTS="-G sanlock -w /dev/watchdog1" + diff --git a/src/sysconfig.sanlock b/src/sysconfig.sanlock deleted file mode 100644 index 89b6fa3..0000000 --- a/src/sysconfig.sanlock +++ /dev/null @@ -1,12 +0,0 @@ -# SANLOCKOPTS -- set the command line options for the sanlock daemon -# See sanlock man page for full list of command line options. -# -# Include "-U sanlock -G sanlock" in the option string unless -# also changing the SANLOCKUSER above. -# -# To disable use of watchdog via wdmd -#SANLOCKOPTS="-U sanlock -G sanlock -w 0" -# -# To disable use of watchdog via wdmd and disable high priority features -#SANLOCKOPTS="-U sanlock -G sanlock -w 0 -h 0" - diff --git a/wdmd/main.c b/wdmd/main.c index 08f2c94..d1666b9 100644 --- a/wdmd/main.c +++ b/wdmd/main.c @@ -64,6 +64,7 @@ static int shm_fd; static int allow_scripts; static int kill_script_sec; static char *scripts_dir = (char *)"/etc/wdmd.d"; +static char *watchdog_path = "/dev/watchdog";
struct script_status { uint64_t start; @@ -921,13 +922,13 @@ static int open_dev(void) int fd;
if (dev_fd != -1) { - log_error("/dev/watchdog already open fd %d", dev_fd); + log_error("watchdog already open fd %d", dev_fd); return -1; }
- fd = open("/dev/watchdog", O_WRONLY | O_CLOEXEC); + fd = open(watchdog_path, O_WRONLY | O_CLOEXEC); if (fd < 0) { - log_error("no /dev/watchdog, load a watchdog driver"); + log_error("no %s, load a watchdog driver", watchdog_path); return fd; }
@@ -942,7 +943,7 @@ static void close_watchdog_unclean(void) return; }
- log_error("/dev/watchdog closed unclean"); + log_error("%s closed unclean", watchdog_path); close(dev_fd); dev_fd = -1;
@@ -960,9 +961,9 @@ static void close_watchdog(void)
rv = write(dev_fd, "V", 1); if (rv < 0) - log_error("/dev/watchdog disarm write error %d", errno); + log_error("%s disarm write error %d", watchdog_path, errno); else - log_error("/dev/watchdog disarmed"); + log_error("%s disarmed", watchdog_path);
close(dev_fd); dev_fd = -1; @@ -980,7 +981,7 @@ static int setup_watchdog(void)
rv = ioctl(dev_fd, WDIOC_GETTIMEOUT, &timeout); if (rv < 0) { - log_error("/dev/watchdog failed to report timeout"); + log_error("%s failed to report timeout", watchdog_path); close_watchdog(); return -1; } @@ -992,18 +993,18 @@ static int setup_watchdog(void)
rv = ioctl(dev_fd, WDIOC_SETTIMEOUT, &timeout); if (rv < 0) { - log_error("/dev/watchdog failed to set timeout"); + log_error("%s failed to set timeout", watchdog_path); close_watchdog(); return -1; }
if (timeout != fire_timeout) { - log_error("/dev/watchdog failed to set new timeout"); + log_error("%s failed to set new timeout", watchdog_path); close_watchdog(); return -1; } out: - log_error("/dev/watchdog armed with fire_timeout %d", fire_timeout); + log_error("%s armed with fire_timeout %d", watchdog_path, fire_timeout);
return 0; } @@ -1152,7 +1153,7 @@ static int test_loop(void) if (dev_fd == -1) { open_dev(); pet_watchdog(); - log_error("/dev/watchdog reopen"); + log_error("%s reopen", watchdog_path); } else { pet_watchdog(); } @@ -1328,6 +1329,7 @@ static void print_usage_and_exit(int status) printf("-s <path> path to scripts dir (default %s)\n", scripts_dir); printf("-k <num> kill unfinished scripts after num seconds (default %d)\n", kill_script_sec); + printf("-w /dev/watchdog path to the watchdog device (default %s)\n", watchdog_path); exit(status); }
@@ -1360,7 +1362,7 @@ int main(int argc, char *argv[]) {0, 0, 0, 0 } };
- c = getopt_long(argc, argv, "hdVDH:G:S:s:k:", + c = getopt_long(argc, argv, "hdVDH:G:S:s:k:w:", long_options, &option_index); if (c == -1) break; @@ -1393,6 +1395,9 @@ int main(int argc, char *argv[]) case 'k': kill_script_sec = atoi(optarg); break; + case 'w': + watchdog_path = strdup(optarg); + break; } }
diff --git a/wdmd/sysconfig.wdmd b/wdmd/sysconfig.wdmd deleted file mode 100644 index 06a13db..0000000 --- a/wdmd/sysconfig.wdmd +++ /dev/null @@ -1,8 +0,0 @@ -# WDMDOPTS -- set the command line options for the wdmd daemon -# See wdmd man page for full list of command line options. -# -# Include "-G sanlock" in the option string. -# -# To enable use of test scripts -#WDMDOPTS="-G sanlock -S 1" -
commit 4b5733fdf52390cb78361a46a53c3b74a5e7b8c7 Author: Federico Simoncelli fsimonce@redhat.com Date: Tue Nov 20 11:36:49 2012 -0500
wdmd: trap also SIGINT for a clean exit
Signed-off-by: Federico Simoncelli fsimonce@redhat.com
diff --git a/wdmd/main.c b/wdmd/main.c index 646a0ac..08f2c94 100644 --- a/wdmd/main.c +++ b/wdmd/main.c @@ -1029,7 +1029,8 @@ static void process_signals(int ci) return; }
- if (fdsi.ssi_signo == SIGTERM) { + if ((fdsi.ssi_signo == SIGTERM) || + (fdsi.ssi_signo == SIGINT)) { if (!active_clients()) daemon_quit = 1; } @@ -1046,6 +1047,7 @@ static int setup_signals(void)
sigemptyset(&mask); sigaddset(&mask, SIGTERM); + sigaddset(&mask, SIGINT); sigaddset(&mask, SIGHUP);
rv = sigprocmask(SIG_BLOCK, &mask, NULL);
sanlock-devel@lists.fedorahosted.org