void qmp_guest_shutdown(bool has_mode, const char *mode, Error **err)

{

    UINT shutdown_flag = EWX_FORCE;



    slog("guest-shutdown called, mode: %s", mode);



    if (!has_mode || strcmp(mode, "powerdown") == 0) {

        shutdown_flag |= EWX_POWEROFF;

    } else if (strcmp(mode, "halt") == 0) {

        shutdown_flag |= EWX_SHUTDOWN;

    } else if (strcmp(mode, "reboot") == 0) {

        shutdown_flag |= EWX_REBOOT;

    } else {

        error_set(err, QERR_INVALID_PARAMETER_VALUE, "mode",

                  "halt|powerdown|reboot");

        return;

    }



    /* Request a shutdown privilege, but try to shut down the system

       anyway. */

    acquire_privilege(SE_SHUTDOWN_NAME, err);

    if (error_is_set(err)) {

        return;

    }



    if (!ExitWindowsEx(shutdown_flag, SHTDN_REASON_FLAG_PLANNED)) {

        slog("guest-shutdown failed: %d", GetLastError());

        error_set(err, QERR_UNDEFINED_ERROR);

    }

}

void qmp_guest_shutdown(bool has_mode, const char *mode, Error **err)

{

    UINT shutdown_flag = EWX_FORCE;



    slog("guest-shutdown called, mode: %s", mode);



    if (!has_mode || strcmp(mode, "powerdown") == 0) {

        shutdown_flag |= EWX_POWEROFF;

    } else if (strcmp(mode, "halt") == 0) {

        shutdown_flag |= EWX_SHUTDOWN;

    } else if (strcmp(mode, "reboot") == 0) {

        shutdown_flag |= EWX_REBOOT;

    } else {

        error_set(err, QERR_INVALID_PARAMETER_VALUE, "mode",

                  "halt|powerdown|reboot");

        return;

    }



    



    acquire_privilege(SE_SHUTDOWN_NAME, err);

    if (error_is_set(err)) {

        return;

    }



    if (!ExitWindowsEx(shutdown_flag, SHTDN_REASON_FLAG_PLANNED)) {

        slog("guest-shutdown failed: %d", GetLastError());

        error_set(err, QERR_UNDEFINED_ERROR);

    }

}

        slog("guest-shutdown failed: %d", GetLastError());
void FUNC_0(bool VAR_0, const char *VAR_1, Error **VAR_2)

{

    UINT shutdown_flag = EWX_FORCE;



    slog("guest-shutdown called, VAR_1: %s", VAR_1);



    if (!VAR_0 || strcmp(VAR_1, "powerdown") == 0) {

        shutdown_flag |= EWX_POWEROFF;

    } else if (strcmp(VAR_1, "halt") == 0) {

        shutdown_flag |= EWX_SHUTDOWN;

    } else if (strcmp(VAR_1, "reboot") == 0) {

        shutdown_flag |= EWX_REBOOT;

    } else {

        error_set(VAR_2, QERR_INVALID_PARAMETER_VALUE, "VAR_1",

                  "halt|powerdown|reboot");

        return;

    }



    



    acquire_privilege(SE_SHUTDOWN_NAME, VAR_2);

    if (error_is_set(VAR_2)) {

        return;

    }



    if (!ExitWindowsEx(shutdown_flag, SHTDN_REASON_FLAG_PLANNED)) {

        slog("guest-shutdown failed: %d", GetLastError());

        error_set(VAR_2, QERR_UNDEFINED_ERROR);

    }

}

void FUNC_0(bool VAR_0, const char *VAR_1, Error **VAR_2)
{ UINT shutdown_flag = EWX_FORCE; slog("guest-shutdown called, VAR_1: %s", VAR_1); if (!VAR_0 || strcmp(VAR_1, "powerdown") == 0) { shutdown_flag |= EWX_POWEROFF; } else if (strcmp(VAR_1, "halt") == 0) { shutdown_flag |= EWX_SHUTDOWN; } else if (strcmp(VAR_1, "reboot") == 0) { shutdown_flag |= EWX_REBOOT; } else { error_set(VAR_2, QERR_INVALID_PARAMETER_VALUE, "VAR_1",
"halt|powerdown|reboot"); return; } acquire_privilege(SE_SHUTDOWN_NAME, VAR_2); if (error_is_set(VAR_2)) { return; } if (!ExitWindowsEx(shutdown_flag, SHTDN_REASON_FLAG_PLANNED)) { slog("guest-shutdown failed: %d", GetLastError()); error_set(VAR_2, QERR_UNDEFINED_ERROR); } }