예제 #1
0
파일: sbd-common.c 프로젝트: l-mb/sbd
void
do_off(void)
{
	if (debug_mode == 1) {
		cl_log(LOG_ERR, "Request to power-off changed to kdump due to DEBUG MODE!");
		watchdog_close();
		sysrq_trigger('c');
		exit(0);
	} else 	if (debug_mode == 2) {
		cl_log(LOG_ERR, "Skipping request to power-off due to DEBUG MODE!");
		watchdog_close();
		exit(0);
	} else if (debug_mode == 3) {
		/* The idea is to give the system some time to flush
		 * logs to disk before rebooting. */
		cl_log(LOG_ERR, "Delaying request to power-off by 10s due to DEBUG MODE!");
		watchdog_close();
		sync();
		sync();
		sleep(10);
		cl_log(LOG_ERR, "Debug mode is now becoming real ...");
	}
	sysrq_trigger('o');
	cl_reboot(5, "sbd is self-fencing (power-off)");
	sleep(timeout_watchdog * 2);
	exit(1);
}
예제 #2
0
static void
pcmk_panic_local(void) 
{
    int rc = pcmk_ok;
    uid_t uid = geteuid();
    pid_t ppid = getppid();

    if(uid != 0 && ppid > 1) {
        /* We're a non-root pacemaker daemon (cib, crmd, pengine,
         * attrd, etc) with the original pacemakerd parent
         *
         * Of these, only crmd is likely to be initiating resets
         */
        do_crm_log_always(LOG_EMERG, "Signaling parent %d to panic", ppid);
        crm_exit(pcmk_err_panic);
        return;

    } else if (uid != 0) {
        /*
         * No permissions and no pacemakerd parent to escalate to
         * Track down the new pacakerd process and send a signal instead
         */
        union sigval signal_value;

        memset(&signal_value, 0, sizeof(signal_value));
        ppid = crm_procfs_pid_of("pacemakerd");
        do_crm_log_always(LOG_EMERG, "Signaling pacemakerd(%d) to panic", ppid);

        if(ppid > 1 && sigqueue(ppid, SIGQUIT, signal_value) < 0) {
            crm_perror(LOG_EMERG, "Cannot signal pacemakerd(%d) to panic", ppid);
        }
        /* The best we can do now is die */
        crm_exit(pcmk_err_panic);
        return;
    }

    /* We're either pacemakerd, or a pacemaker daemon running as root */

    if (safe_str_eq("crash", getenv("PCMK_panic_action"))) {
        sysrq_trigger('c');
    } else {
        sysrq_trigger('b');
    }
    /* reboot(RB_HALT_SYSTEM); rc = errno; */
    reboot(RB_AUTOBOOT);
    rc = errno;

    do_crm_log_always(LOG_EMERG, "Reboot failed, escalating to %d: %s (%d)", ppid, pcmk_strerror(rc), rc);

    if(ppid > 1) {
        /* child daemon */
        exit(pcmk_err_panic);
    } else {
        /* pacemakerd or orphan child */
        exit(DAEMON_RESPAWN_STOP);
    }
}
예제 #3
0
파일: sbd-common.c 프로젝트: l-mb/sbd
void
do_crashdump(void)
{
	if (timeout_watchdog_crashdump) {
		timeout_watchdog = timeout_watchdog_crashdump;
		watchdog_init_interval();
		watchdog_tickle();
	}
	sysrq_trigger('c');
	/* is it possible to reach the following line? */
	cl_reboot(5, "sbd is triggering crashdumping");
	exit(1);
}
예제 #4
0
파일: sbd-common.c 프로젝트: gao-yan/sbd
static void
do_exit(char kind) 
{
    /* TODO: Turn debug_mode into a bit field? Delay + kdump for example */
    const char *reason = NULL;

    if (kind == 'c') {
        cl_log(LOG_NOTICE, "Initiating kdump");

    } else if (debug_mode == 1) {
        cl_log(LOG_WARNING, "Initiating kdump instead of panicing the node (debug mode)");
        kind = 'c';
    }

    if (debug_mode == 2) {
        cl_log(LOG_WARNING, "Shutting down SBD instead of panicing the node (debug mode)");
        watchdog_close(true);
        exit(0);
    }

    if (debug_mode == 3) {
        /* Give the system some time to flush logs to disk before rebooting. */
        cl_log(LOG_WARNING, "Delaying node panic by 10s (debug mode)");

        watchdog_close(true);
        sync();

        sleep(10);
    }

    switch(kind) {
        case 'b':
            reason = "reboot";
            break;
        case 'c':
            reason = "crashdump";
            break;
        case 'o':
            reason = "off";
            break;
        default:
            reason = "unknown";
            break;
    }

    cl_log(LOG_EMERG, "Rebooting system: %s", reason);
    sync();

    if(kind == 'c') {
        watchdog_close(true);
        sysrq_trigger(kind);

    } else {
        watchdog_close(false);
        sysrq_trigger(kind);
        if(reboot(RB_AUTOBOOT) < 0) {
            cl_perror("Reboot failed");
        }
    }

    exit(1);
}