Page MenuHomeClusterLabs Projects

No OneTemporary

diff --git a/include/crm/common/logging.h b/include/crm/common/logging.h
index a2b4cfc3d7..47a5698cd7 100644
--- a/include/crm/common/logging.h
+++ b/include/crm/common/logging.h
@@ -1,381 +1,381 @@
/*
* Copyright 2004-2021 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
* This source code is licensed under the GNU General Public License version 2
* or later (GPLv2+) WITHOUT ANY WARRANTY.
*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* \file
* \brief Wrappers for and extensions to libqb logging
* \ingroup core
*/
#ifndef CRM_LOGGING__H
# define CRM_LOGGING__H
# include <stdio.h>
# include <glib.h>
# include <qb/qblog.h>
# include <libxml/tree.h>
/* Define custom log priorities.
*
* syslog(3) uses int for priorities, but libqb's struct qb_log_callsite uses
* uint8_t, so make sure they fit in the latter.
*/
// Define something even less desired than debug
# ifndef LOG_TRACE
# define LOG_TRACE (LOG_DEBUG+1)
# endif
// Print message to stdout instead of logging it
# ifndef LOG_STDOUT
# define LOG_STDOUT 254
# endif
// Don't send message anywhere
# ifndef LOG_NEVER
# define LOG_NEVER 255
# endif
/* "Extended information" logging support */
#ifdef QB_XS
# define CRM_XS QB_XS
# define crm_extended_logging(t, e) qb_log_ctl((t), QB_LOG_CONF_EXTENDED, (e))
#else
# define CRM_XS "|"
/* A caller might want to check the return value, so we can't define this as a
* no-op, and we can't simply define it to be 0 because gcc will then complain
* when the value isn't checked.
*/
static inline int
crm_extended_logging(int t, int e)
{
return 0;
}
#endif
extern unsigned int crm_log_level;
extern unsigned int crm_trace_nonlog;
/* These are set when a configuration issue is found, and turn on extra messages
* at the end of processing. They are set via wrapper functions and do not need
* to be set directly.
*/
extern bool pcmk__config_error;
extern bool pcmk__config_warning;
enum xml_log_options
{
xml_log_option_filtered = 0x0001,
xml_log_option_formatted = 0x0002,
xml_log_option_text = 0x0004, /* add this option to dump text into xml */
xml_log_option_full_fledged = 0x0008, // Use libxml when converting XML to text
xml_log_option_diff_plus = 0x0010,
xml_log_option_diff_minus = 0x0020,
xml_log_option_diff_short = 0x0040,
xml_log_option_diff_all = 0x0100,
xml_log_option_dirty_add = 0x1000,
xml_log_option_open = 0x2000,
xml_log_option_children = 0x4000,
xml_log_option_close = 0x8000,
};
void crm_enable_blackbox(int nsig);
void crm_disable_blackbox(int nsig);
void crm_write_blackbox(int nsig, struct qb_log_callsite *callsite);
void crm_update_callsites(void);
void crm_log_deinit(void);
void crm_log_preinit(const char *entity, int argc, char **argv);
gboolean crm_log_init(const char *entity, uint8_t level, gboolean daemon,
gboolean to_stderr, int argc, char **argv, gboolean quiet);
void crm_log_args(int argc, char **argv);
void crm_log_output_fn(const char *file, const char *function, int line, int level,
const char *prefix, const char *output);
// Log a block of text line by line
#define crm_log_output(level, prefix, output) \
crm_log_output_fn(__FILE__, __func__, __LINE__, level, prefix, output)
gboolean crm_add_logfile(const char *filename);
void crm_bump_log_level(int argc, char **argv);
void crm_enable_stderr(int enable);
gboolean crm_is_callsite_active(struct qb_log_callsite *cs, uint8_t level, uint32_t tags);
void log_data_element(int log_level, const char *file, const char *function, int line,
const char *prefix, xmlNode * data, int depth, gboolean formatted);
/* returns the old value */
unsigned int set_crm_log_level(unsigned int level);
unsigned int get_crm_log_level(void);
/*
* Throughout the macros below, note the leading, pre-comma, space in the
* various ' , ##args' occurrences to aid portability across versions of 'gcc'.
* https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html#Variadic-Macros
*/
#if defined(__clang__)
# define CRM_TRACE_INIT_DATA(name)
# else
# include <assert.h> // required by QB_LOG_INIT_DATA() macro
# define CRM_TRACE_INIT_DATA(name) QB_LOG_INIT_DATA(name)
#endif
/* Using "switch" instead of "if" in these macro definitions keeps
* static analysis from complaining about constant evaluations
*/
/*!
* \brief Log a message
*
* \param[in] level Priority at which to log the message
* \param[in] fmt printf-style format string literal for message
* \param[in] args Any arguments needed by format string
*
* \note This is a macro, and \p level may be evaluated more than once.
*/
# define do_crm_log(level, fmt, args...) do { \
switch (level) { \
case LOG_STDOUT: \
printf(fmt "\n" , ##args); \
break; \
case LOG_NEVER: \
break; \
default: \
qb_log_from_external_source(__func__, __FILE__, fmt, \
(level), __LINE__, 0 , ##args); \
break; \
} \
} while (0)
/*!
* \brief Log a message that is likely to be filtered out
*
* \param[in] level Priority at which to log the message
* \param[in] fmt printf-style format string for message
* \param[in] args Any arguments needed by format string
*
* \note This is a macro, and \p level may be evaluated more than once.
* This does nothing when level is LOG_STDOUT.
*/
# define do_crm_log_unlikely(level, fmt, args...) do { \
switch (level) { \
case LOG_STDOUT: case LOG_NEVER: \
break; \
default: { \
static struct qb_log_callsite *trace_cs = NULL; \
if (trace_cs == NULL) { \
trace_cs = qb_log_callsite_get(__func__, __FILE__, fmt, \
(level), __LINE__, 0); \
} \
if (crm_is_callsite_active(trace_cs, (level), 0)) { \
qb_log_from_external_source(__func__, __FILE__, fmt, \
(level), __LINE__, 0 , ##args); \
} \
} \
break; \
} \
} while (0)
# define CRM_LOG_ASSERT(expr) do { \
- if(__unlikely((expr) == FALSE)) { \
+ if (!(expr)) { \
static struct qb_log_callsite *core_cs = NULL; \
if(core_cs == NULL) { \
core_cs = qb_log_callsite_get(__func__, __FILE__, \
"log-assert", LOG_TRACE, \
__LINE__, 0); \
} \
crm_abort(__FILE__, __func__, __LINE__, #expr, \
core_cs?core_cs->targets:FALSE, TRUE); \
} \
} while(0)
/* 'failure_action' MUST NOT be 'continue' as it will apply to the
* macro's do-while loop
*/
# define CRM_CHECK(expr, failure_action) do { \
- if (__unlikely((expr) == FALSE)) { \
+ if (!(expr)) { \
static struct qb_log_callsite *core_cs = NULL; \
if (core_cs == NULL) { \
core_cs = qb_log_callsite_get(__func__, __FILE__, \
"check-assert", \
LOG_TRACE, __LINE__, 0); \
} \
crm_abort(__FILE__, __func__, __LINE__, #expr, \
(core_cs? core_cs->targets: FALSE), TRUE); \
failure_action; \
} \
} while(0)
/*!
* \brief Log XML line-by-line in a formatted fashion
*
* \param[in] level Priority at which to log the messages
* \param[in] text Prefix for each line
* \param[in] xml XML to log
*
* \note This is a macro, and \p level may be evaluated more than once.
* This does nothing when level is LOG_STDOUT.
*/
# define do_crm_log_xml(level, text, xml) do { \
switch (level) { \
case LOG_STDOUT: case LOG_NEVER: \
break; \
default: { \
static struct qb_log_callsite *xml_cs = NULL; \
if (xml_cs == NULL) { \
xml_cs = qb_log_callsite_get(__func__, __FILE__, \
"xml-blob", (level), __LINE__, 0); \
} \
if (crm_is_callsite_active(xml_cs, (level), 0)) { \
log_data_element((level), __FILE__, __func__, \
__LINE__, text, xml, 1, xml_log_option_formatted); \
} \
} \
break; \
} \
} while(0)
/*!
* \brief Log a message as if it came from a different code location
*
* \param[in] level Priority at which to log the message
* \param[in] file Source file name to use instead of __FILE__
* \param[in] function Source function name to use instead of __func__
* \param[in] line Source line number to use instead of __line__
* \param[in] fmt printf-style format string literal for message
* \param[in] args Any arguments needed by format string
*
* \note This is a macro, and \p level may be evaluated more than once.
*/
# define do_crm_log_alias(level, file, function, line, fmt, args...) do { \
switch (level) { \
case LOG_STDOUT: \
printf(fmt "\n" , ##args); \
break; \
case LOG_NEVER: \
break; \
default: \
qb_log_from_external_source(function, file, fmt, (level), \
line, 0 , ##args); \
break; \
} \
} while (0)
/*!
* \brief Send a system error message to both the log and stderr
*
* \param[in] level Priority at which to log the message
* \param[in] fmt printf-style format string for message
* \param[in] args Any arguments needed by format string
*
* \deprecated One of the other logging functions should be used with
* pcmk_strerror() instead.
* \note This is a macro, and \p level may be evaluated more than once.
* \note Because crm_perror() adds the system error message and error number
* onto the end of fmt, that information will become extended information
* if CRM_XS is used inside fmt and will not show up in syslog.
*/
# define crm_perror(level, fmt, args...) do { \
switch (level) { \
case LOG_NEVER: \
break; \
default: { \
const char *err = strerror(errno); \
/* cast to int makes coverity happy when level == 0 */ \
if ((level) <= (int) crm_log_level) { \
fprintf(stderr, fmt ": %s (%d)\n" , ##args, err, errno);\
} \
do_crm_log((level), fmt ": %s (%d)" , ##args, err, errno); \
} \
break; \
} \
} while (0)
/*!
* \brief Log a message with a tag (for use with PCMK_trace_tags)
*
* \param[in] level Priority at which to log the message
* \param[in] tag String to tag message with
* \param[in] fmt printf-style format string for message
* \param[in] args Any arguments needed by format string
*
* \note This is a macro, and \p level may be evaluated more than once.
* This does nothing when level is LOG_STDOUT.
*/
# define crm_log_tag(level, tag, fmt, args...) do { \
switch (level) { \
case LOG_STDOUT: case LOG_NEVER: \
break; \
default: { \
static struct qb_log_callsite *trace_tag_cs = NULL; \
int converted_tag = g_quark_try_string(tag); \
if (trace_tag_cs == NULL) { \
trace_tag_cs = qb_log_callsite_get(__func__, __FILE__, \
fmt, (level), __LINE__, converted_tag); \
} \
if (crm_is_callsite_active(trace_tag_cs, (level), \
converted_tag)) { \
qb_log_from_external_source(__func__, __FILE__, fmt, \
(level), __LINE__, converted_tag , ##args); \
} \
} \
} \
} while (0)
# define crm_emerg(fmt, args...) qb_log(LOG_EMERG, fmt , ##args)
# define crm_crit(fmt, args...) qb_logt(LOG_CRIT, 0, fmt , ##args)
# define crm_err(fmt, args...) qb_logt(LOG_ERR, 0, fmt , ##args)
# define crm_warn(fmt, args...) qb_logt(LOG_WARNING, 0, fmt , ##args)
# define crm_notice(fmt, args...) qb_logt(LOG_NOTICE, 0, fmt , ##args)
# define crm_info(fmt, args...) qb_logt(LOG_INFO, 0, fmt , ##args)
# define crm_debug(fmt, args...) do_crm_log_unlikely(LOG_DEBUG, fmt , ##args)
# define crm_trace(fmt, args...) do_crm_log_unlikely(LOG_TRACE, fmt , ##args)
# define crm_log_xml_crit(xml, text) do_crm_log_xml(LOG_CRIT, text, xml)
# define crm_log_xml_err(xml, text) do_crm_log_xml(LOG_ERR, text, xml)
# define crm_log_xml_warn(xml, text) do_crm_log_xml(LOG_WARNING, text, xml)
# define crm_log_xml_notice(xml, text) do_crm_log_xml(LOG_NOTICE, text, xml)
# define crm_log_xml_info(xml, text) do_crm_log_xml(LOG_INFO, text, xml)
# define crm_log_xml_debug(xml, text) do_crm_log_xml(LOG_DEBUG, text, xml)
# define crm_log_xml_trace(xml, text) do_crm_log_xml(LOG_TRACE, text, xml)
# define crm_log_xml_explicit(xml, text) do { \
static struct qb_log_callsite *digest_cs = NULL; \
digest_cs = qb_log_callsite_get( \
__func__, __FILE__, text, LOG_TRACE, __LINE__, \
crm_trace_nonlog); \
if (digest_cs && digest_cs->targets) { \
do_crm_log_xml(LOG_TRACE, text, xml); \
} \
} while(0)
# define crm_str(x) (const char*)(x?x:"<null>")
#if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
#include <crm/common/logging_compat.h>
#endif
#ifdef __cplusplus
}
#endif
#endif
diff --git a/include/crm/common/results.h b/include/crm/common/results.h
index 7073fc5165..5cef0bb2e0 100644
--- a/include/crm/common/results.h
+++ b/include/crm/common/results.h
@@ -1,272 +1,272 @@
/*
- * Copyright 2012-2020 the Pacemaker project contributors
+ * Copyright 2012-2021 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
* This source code is licensed under the GNU Lesser General Public License
* version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
*/
#ifndef CRM_RESULTS__H
# define CRM_RESULTS__H
#ifdef __cplusplus
extern "C" {
#endif
/*!
* \file
* \brief Function and executable result codes
* \ingroup core
*/
// Lifted from config.h
/* The _Noreturn keyword of C11. */
#ifndef _Noreturn
# if (defined __cplusplus \
&& ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
|| (defined _MSC_VER && 1900 <= _MSC_VER)))
# define _Noreturn [[noreturn]]
# elif ((!defined __cplusplus || defined __clang__) \
&& (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
|| 4 < __GNUC__ + (7 <= __GNUC_MINOR__)))
/* _Noreturn works as-is. */
# elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C
# define _Noreturn __attribute__ ((__noreturn__))
# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
# define _Noreturn __declspec (noreturn)
# else
# define _Noreturn
# endif
#endif
# define CRM_ASSERT(expr) do { \
- if(__unlikely((expr) == FALSE)) { \
+ if (!(expr)) { \
crm_abort(__FILE__, __func__, __LINE__, #expr, TRUE, FALSE); \
- abort(); /* Redundant but it makes static analyzers happy */ \
+ abort(); /* crm_abort() doesn't always abort! */ \
} \
} while(0)
/*
* Function return codes
*
* Most Pacemaker API functions return an integer return code. There are two
* alternative interpretations. The legacy interpration is that the absolute
* value of the return code is either a system error number or a custom
* pcmk_err_* number. This is less than ideal because system error numbers are
* constrained only to the positive int range, so there's the possibility
* (though not noticed in the wild) that system errors and custom errors could
* collide. The new intepretation is that negative values are from the pcmk_rc_e
* enum, and positive values are system error numbers. Both use 0 for success.
*
* For system error codes, see:
* - /usr/include/asm-generic/errno.h
* - /usr/include/asm-generic/errno-base.h
*/
// Legacy custom return codes for Pacemaker API functions (deprecated)
# define pcmk_ok 0
# define PCMK_ERROR_OFFSET 190 /* Replacements on non-linux systems, see include/portability.h */
# define PCMK_CUSTOM_OFFSET 200 /* Purely custom codes */
# define pcmk_err_generic 201
# define pcmk_err_no_quorum 202
# define pcmk_err_schema_validation 203
# define pcmk_err_transform_failed 204
# define pcmk_err_old_data 205
# define pcmk_err_diff_failed 206
# define pcmk_err_diff_resync 207
# define pcmk_err_cib_modified 208
# define pcmk_err_cib_backup 209
# define pcmk_err_cib_save 210
# define pcmk_err_schema_unchanged 211
# define pcmk_err_cib_corrupt 212
# define pcmk_err_multiple 213
# define pcmk_err_node_unknown 214
# define pcmk_err_already 215
/* On HPPA 215 is ENOSYM (Unknown error 215), which hopefully never happens. */
#ifdef __hppa__
# define pcmk_err_bad_nvpair 250 /* 216 is ENOTSOCK */
# define pcmk_err_unknown_format 252 /* 217 is EDESTADDRREQ */
#else
# define pcmk_err_bad_nvpair 216
# define pcmk_err_unknown_format 217
#endif
/*!
* \enum pcmk_rc_e
* \brief Return codes for Pacemaker API functions
*
* Any Pacemaker API function documented as returning a "standard Pacemaker
* return code" will return pcmk_rc_ok (0) on success, and one of this
* enumeration's other (negative) values or a (positive) system error number
* otherwise. The custom codes are at -1001 and lower, so that the caller may
* use -1 through -1000 for their own custom values if desired. While generally
* referred to as "errors", nonzero values simply indicate a result, which might
* or might not be an error depending on the calling context.
*/
enum pcmk_rc_e {
/* When adding new values, use consecutively lower numbers, update the array
* in lib/common/results.c, and test with crm_error.
*/
pcmk_rc_underflow = -1028,
pcmk_rc_no_input = -1027,
pcmk_rc_no_output = -1026,
pcmk_rc_after_range = -1025,
pcmk_rc_within_range = -1024,
pcmk_rc_before_range = -1023,
pcmk_rc_undetermined = -1022,
pcmk_rc_op_unsatisfied = -1021,
pcmk_rc_ipc_pid_only = -1020,
pcmk_rc_ipc_unresponsive = -1019,
pcmk_rc_ipc_unauthorized = -1018,
pcmk_rc_no_quorum = -1017,
pcmk_rc_schema_validation = -1016,
pcmk_rc_schema_unchanged = -1015,
pcmk_rc_transform_failed = -1014,
pcmk_rc_old_data = -1013,
pcmk_rc_diff_failed = -1012,
pcmk_rc_diff_resync = -1011,
pcmk_rc_cib_modified = -1010,
pcmk_rc_cib_backup = -1009,
pcmk_rc_cib_save = -1008,
pcmk_rc_cib_corrupt = -1007,
pcmk_rc_multiple = -1006,
pcmk_rc_node_unknown = -1005,
pcmk_rc_already = -1004,
pcmk_rc_bad_nvpair = -1003,
pcmk_rc_unknown_format = -1002,
// Developers: Use a more specific code than pcmk_rc_error whenever possible
pcmk_rc_error = -1001,
// Values -1 through -1000 reserved for caller use
pcmk_rc_ok = 0
// Positive values reserved for system error numbers
};
/* Uniform exit codes
* Everything is mapped to its OCF equivalent so that Pacemaker only deals with one set of codes
*/
enum ocf_exitcode {
PCMK_OCF_OK = 0,
PCMK_OCF_UNKNOWN_ERROR = 1,
PCMK_OCF_INVALID_PARAM = 2,
PCMK_OCF_UNIMPLEMENT_FEATURE = 3,
PCMK_OCF_INSUFFICIENT_PRIV = 4,
PCMK_OCF_NOT_INSTALLED = 5,
PCMK_OCF_NOT_CONFIGURED = 6,
PCMK_OCF_NOT_RUNNING = 7, /* End of overlap with LSB */
PCMK_OCF_RUNNING_MASTER = 8,
PCMK_OCF_FAILED_MASTER = 9,
/* 150-199 reserved for application use */
PCMK_OCF_CONNECTION_DIED = 189, // Deprecated (see PCMK_LRM_OP_NOT_CONNECTED)
PCMK_OCF_DEGRADED = 190, /* Active resource that is no longer 100% functional */
PCMK_OCF_DEGRADED_MASTER = 191, /* Promoted resource that is no longer 100% functional */
PCMK_OCF_EXEC_ERROR = 192, /* Generic problem invoking the agent */
PCMK_OCF_UNKNOWN = 193, /* State of the service is unknown - used for recording in-flight operations */
PCMK_OCF_SIGNAL = 194,
PCMK_OCF_NOT_SUPPORTED = 195,
PCMK_OCF_PENDING = 196,
PCMK_OCF_CANCELLED = 197,
PCMK_OCF_TIMEOUT = 198,
PCMK_OCF_OTHER_ERROR = 199, /* Keep the same codes as PCMK_LSB */
};
/*
* Exit status codes
*
* We want well-specified (i.e. OS-invariant) exit status codes for our daemons
* and applications so they can be relied on by callers. (Function return codes
* and errno's do not make good exit statuses.)
*
* The only hard rule is that exit statuses must be between 0 and 255; all else
* is convention. Universally, 0 is success, and 1 is generic error (excluding
* OSes we don't support -- for example, OpenVMS considers 1 success!).
*
* For init scripts, the LSB gives meaning to 0-7, and sets aside 150-199 for
* application use. OCF adds 8-9 and 189-199.
*
* sysexits.h was an attempt to give additional meanings, but never really
* caught on. It uses 0 and 64-78.
*
* Bash reserves 2 ("incorrect builtin usage") and 126-255 (126 is "command
* found but not executable", 127 is "command not found", 128 + n is
* "interrupted by signal n").
*
* tldp.org recommends 64-113 for application use.
*
* We try to overlap with the above conventions when practical.
*/
typedef enum crm_exit_e {
// Common convention
CRM_EX_OK = 0,
CRM_EX_ERROR = 1,
// LSB + OCF
CRM_EX_INVALID_PARAM = 2,
CRM_EX_UNIMPLEMENT_FEATURE = 3,
CRM_EX_INSUFFICIENT_PRIV = 4,
CRM_EX_NOT_INSTALLED = 5,
CRM_EX_NOT_CONFIGURED = 6,
CRM_EX_NOT_RUNNING = 7,
// sysexits.h
CRM_EX_USAGE = 64, // command line usage error
CRM_EX_DATAERR = 65, // user-supplied data incorrect
CRM_EX_NOINPUT = 66, // input file not available
CRM_EX_NOUSER = 67, // user does not exist
CRM_EX_NOHOST = 68, // host unknown
CRM_EX_UNAVAILABLE = 69, // needed service unavailable
CRM_EX_SOFTWARE = 70, // internal software bug
CRM_EX_OSERR = 71, // external (OS/environmental) problem
CRM_EX_OSFILE = 72, // system file not usable
CRM_EX_CANTCREAT = 73, // file couldn't be created
CRM_EX_IOERR = 74, // file I/O error
CRM_EX_TEMPFAIL = 75, // try again
CRM_EX_PROTOCOL = 76, // protocol violated
CRM_EX_NOPERM = 77, // non-file permission issue
CRM_EX_CONFIG = 78, // misconfiguration
// Custom
CRM_EX_FATAL = 100, // do not respawn
CRM_EX_PANIC = 101, // panic the local host
CRM_EX_DISCONNECT = 102, // lost connection to something
CRM_EX_OLD = 103, // update older than existing config
CRM_EX_DIGEST = 104, // digest comparison failed
CRM_EX_NOSUCH = 105, // requested item does not exist
CRM_EX_QUORUM = 106, // local partition does not have quorum
CRM_EX_UNSAFE = 107, // requires --force or new conditions
CRM_EX_EXISTS = 108, // requested item already exists
CRM_EX_MULTIPLE = 109, // requested item has multiple matches
CRM_EX_EXPIRED = 110, // requested item has expired
CRM_EX_NOT_YET_IN_EFFECT = 111, // requested item is not in effect
CRM_EX_INDETERMINATE = 112, // could not determine status
CRM_EX_UNSATISFIED = 113, // requested item does not satisfy constraints
// Other
CRM_EX_TIMEOUT = 124, // convention from timeout(1)
CRM_EX_MAX = 255, // ensure crm_exit_t can hold this
} crm_exit_t;
const char *pcmk_rc_name(int rc);
const char *pcmk_rc_str(int rc);
crm_exit_t pcmk_rc2exitc(int rc);
int pcmk_rc2legacy(int rc);
int pcmk_legacy2rc(int legacy_rc);
const char *pcmk_strerror(int rc);
const char *pcmk_errorname(int rc);
const char *bz2_strerror(int rc);
crm_exit_t crm_errno2exit(int rc);
const char *crm_exit_name(crm_exit_t exit_code);
const char *crm_exit_str(crm_exit_t exit_code);
_Noreturn crm_exit_t crm_exit(crm_exit_t rc);
#ifdef __cplusplus
}
#endif
#endif
diff --git a/include/crm/crm.h b/include/crm/crm.h
index 9a7a4d7888..30f00af0b8 100644
--- a/include/crm/crm.h
+++ b/include/crm/crm.h
@@ -1,246 +1,238 @@
/*
* Copyright 2004-2021 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
* This source code is licensed under the GNU Lesser General Public License
* version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
*/
#ifndef CRM__H
# define CRM__H
#ifdef __cplusplus
extern "C" {
#endif
/**
* \file
* \brief A dumping ground
* \ingroup core
*/
# include <crm_config.h>
# include <stdlib.h>
# include <glib.h>
# include <stdbool.h>
# include <string.h>
# include <libxml/tree.h>
#ifndef PCMK_ALLOW_DEPRECATED
/*!
* \brief Allow use of deprecated Pacemaker APIs
*
* By default, external code using Pacemaker headers is allowed to use
* deprecated Pacemaker APIs. If PCMK_ALLOW_DEPRECATED is defined to 0 before
* including any Pacemaker headers, deprecated APIs will be unusable. It is
* strongly recommended to leave this unchanged for production and release
* builds, to avoid breakage when users upgrade to new Pacemaker releases that
* deprecate more APIs. This should be defined to 0 only for development and
* testing builds when desiring to check for usage of currently deprecated APIs.
*/
#define PCMK_ALLOW_DEPRECATED 1
#endif
/*!
* The CRM feature set assists with compatibility in mixed-version clusters.
* The major version number increases when nodes with different versions
* would not work (rolling upgrades are not allowed). The minor version
* number increases when mixed-version clusters are allowed only during
* rolling upgrades (a node with the oldest feature set will be elected DC). The
* minor-minor version number is ignored, but allows resource agents to detect
* cluster support for various features.
*
* The feature set also affects the processing of old saved CIBs (such as for
* many scheduler regression tests).
*
* Particular feature points currently used by pacemaker:
*
* >2.1: Operation updates include timing data
* >=3.0.5: XML v2 digests are created
* >=3.0.8: Peers do not need acks for cancellations
* >=3.0.9: DC will send its own shutdown request to all peers
* XML v2 patchsets are created by default
* >=3.0.13: Fail counts include operation name and interval
* >=3.2.0: DC supports PCMK_LRM_OP_INVALID and PCMK_LRM_OP_NOT_CONNECTED
*/
# define CRM_FEATURE_SET "3.7.3"
# ifndef MAX_NAME
# define MAX_NAME 256
# endif
-# ifndef __GNUC__
-# define __builtin_expect(expr, result) (expr)
-# endif
-
-/* Some handy macros used by the Linux kernel */
-# define __likely(expr) __builtin_expect(expr, 1)
-# define __unlikely(expr) __builtin_expect(expr, 0)
-
# define CRM_META "CRM_meta"
extern char *crm_system_name;
/* *INDENT-OFF* */
// Used for some internal IPC timeouts (maybe should be configurable option)
# define MAX_IPC_DELAY 120
// How we represent "infinite" scores
# define CRM_SCORE_INFINITY 1000000
# define CRM_INFINITY_S "INFINITY"
# define CRM_PLUS_INFINITY_S "+" CRM_INFINITY_S
# define CRM_MINUS_INFINITY_S "-" CRM_INFINITY_S
/* @COMPAT API < 2.0.0 Deprecated "infinity" aliases
*
* INFINITY might be defined elsewhere (e.g. math.h), so undefine it first.
* This, of course, complicates any attempt to use the other definition in any
* code that includes this header.
*/
# undef INFINITY
# define INFINITY_S "INFINITY"
# define MINUS_INFINITY_S "-INFINITY"
# define INFINITY 1000000
/* Sub-systems */
# define CRM_SYSTEM_DC "dc"
# define CRM_SYSTEM_DCIB "dcib"
/* The master CIB */
# define CRM_SYSTEM_CIB "cib"
# define CRM_SYSTEM_CRMD "crmd"
# define CRM_SYSTEM_LRMD "lrmd"
# define CRM_SYSTEM_PENGINE "pengine"
# define CRM_SYSTEM_TENGINE "tengine"
# define CRM_SYSTEM_STONITHD "stonithd"
# define CRM_SYSTEM_MCP "pacemakerd"
// Names of internally generated node attributes
# define CRM_ATTR_UNAME "#uname"
# define CRM_ATTR_ID "#id"
# define CRM_ATTR_KIND "#kind"
# define CRM_ATTR_ROLE "#role"
# define CRM_ATTR_IS_DC "#is_dc"
# define CRM_ATTR_CLUSTER_NAME "#cluster-name"
# define CRM_ATTR_SITE_NAME "#site-name"
# define CRM_ATTR_UNFENCED "#node-unfenced"
# define CRM_ATTR_DIGESTS_ALL "#digests-all"
# define CRM_ATTR_DIGESTS_SECURE "#digests-secure"
# define CRM_ATTR_RA_VERSION "#ra-version"
# define CRM_ATTR_PROTOCOL "#attrd-protocol"
/* Valid operations */
# define CRM_OP_NOOP "noop"
# define CRM_OP_JOIN_ANNOUNCE "join_announce"
# define CRM_OP_JOIN_OFFER "join_offer"
# define CRM_OP_JOIN_REQUEST "join_request"
# define CRM_OP_JOIN_ACKNAK "join_ack_nack"
# define CRM_OP_JOIN_CONFIRM "join_confirm"
# define CRM_OP_PING "ping"
# define CRM_OP_NODE_INFO "node-info"
# define CRM_OP_THROTTLE "throttle"
# define CRM_OP_VOTE "vote"
# define CRM_OP_NOVOTE "no-vote"
# define CRM_OP_HELLO "hello"
# define CRM_OP_PECALC "pe_calc"
# define CRM_OP_QUIT "quit"
# define CRM_OP_LOCAL_SHUTDOWN "start_shutdown"
# define CRM_OP_SHUTDOWN_REQ "req_shutdown"
# define CRM_OP_SHUTDOWN "do_shutdown"
# define CRM_OP_FENCE "stonith"
# define CRM_OP_REGISTER "register"
# define CRM_OP_IPC_FWD "ipc_fwd"
# define CRM_OP_INVOKE_LRM "lrm_invoke"
# define CRM_OP_LRM_REFRESH "lrm_refresh" /* Deprecated */
# define CRM_OP_LRM_QUERY "lrm_query"
# define CRM_OP_LRM_DELETE "lrm_delete"
# define CRM_OP_LRM_FAIL "lrm_fail"
# define CRM_OP_PROBED "probe_complete"
# define CRM_OP_REPROBE "probe_again"
# define CRM_OP_CLEAR_FAILCOUNT "clear_failcount"
# define CRM_OP_REMOTE_STATE "remote_state"
# define CRM_OP_RELAXED_SET "one-or-more"
# define CRM_OP_RELAXED_CLONE "clone-one-or-more"
# define CRM_OP_RM_NODE_CACHE "rm_node_cache"
# define CRM_OP_MAINTENANCE_NODES "maintenance_nodes"
/* Possible cluster membership states */
# define CRMD_JOINSTATE_DOWN "down"
# define CRMD_JOINSTATE_PENDING "pending"
# define CRMD_JOINSTATE_MEMBER "member"
# define CRMD_JOINSTATE_NACK "banned"
# define CRMD_ACTION_DELETE "delete"
# define CRMD_ACTION_CANCEL "cancel"
# define CRMD_ACTION_RELOAD "reload"
# define CRMD_ACTION_MIGRATE "migrate_to"
# define CRMD_ACTION_MIGRATED "migrate_from"
# define CRMD_ACTION_START "start"
# define CRMD_ACTION_STARTED "running"
# define CRMD_ACTION_STOP "stop"
# define CRMD_ACTION_STOPPED "stopped"
# define CRMD_ACTION_PROMOTE "promote"
# define CRMD_ACTION_PROMOTED "promoted"
# define CRMD_ACTION_DEMOTE "demote"
# define CRMD_ACTION_DEMOTED "demoted"
# define CRMD_ACTION_NOTIFY "notify"
# define CRMD_ACTION_NOTIFIED "notified"
# define CRMD_ACTION_STATUS "monitor"
# define CRMD_ACTION_METADATA "meta-data"
# define CRMD_METADATA_CALL_TIMEOUT 30000
/* short names */
# define RSC_DELETE CRMD_ACTION_DELETE
# define RSC_CANCEL CRMD_ACTION_CANCEL
# define RSC_MIGRATE CRMD_ACTION_MIGRATE
# define RSC_MIGRATED CRMD_ACTION_MIGRATED
# define RSC_START CRMD_ACTION_START
# define RSC_STARTED CRMD_ACTION_STARTED
# define RSC_STOP CRMD_ACTION_STOP
# define RSC_STOPPED CRMD_ACTION_STOPPED
# define RSC_PROMOTE CRMD_ACTION_PROMOTE
# define RSC_PROMOTED CRMD_ACTION_PROMOTED
# define RSC_DEMOTE CRMD_ACTION_DEMOTE
# define RSC_DEMOTED CRMD_ACTION_DEMOTED
# define RSC_NOTIFY CRMD_ACTION_NOTIFY
# define RSC_NOTIFIED CRMD_ACTION_NOTIFIED
# define RSC_STATUS CRMD_ACTION_STATUS
# define RSC_METADATA CRMD_ACTION_METADATA
/* *INDENT-ON* */
# include <crm/common/logging.h>
# include <crm/common/util.h>
static inline const char *
crm_action_str(const char *task, guint interval_ms) {
if ((task != NULL) && (interval_ms == 0)
&& (strcasecmp(task, RSC_STATUS) == 0)) {
return "probe";
}
return task;
}
#if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
#include <crm/crm_compat.h>
#endif
#ifdef __cplusplus
}
#endif
#endif
diff --git a/include/crm/crm_compat.h b/include/crm/crm_compat.h
index f8be2b15b9..d391147e30 100644
--- a/include/crm/crm_compat.h
+++ b/include/crm/crm_compat.h
@@ -1,39 +1,52 @@
/*
* Copyright 2004-2021 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
* This source code is licensed under the GNU Lesser General Public License
* version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
*/
#ifndef PCMK__CRM_COMPAT__H
# define PCMK__CRM_COMPAT__H
#ifdef __cplusplus
extern "C" {
#endif
/**
* \file
* \brief Deprecated Pacemaker utilities
* \ingroup core
* \deprecated Do not include this header directly. The utilities in this
* header, and the header itself, will be removed in a future
* release.
*/
//! \deprecated Use '\0' instead
#define EOS '\0'
+//!@{
//! \deprecated This macro will be removed in a future release
+
#define DIMOF(a) ((int) (sizeof(a)/sizeof(a[0])))
+# ifndef __GNUC__
+# define __builtin_expect(expr, result) (expr)
+# endif
+
+#define __likely(expr) __builtin_expect(expr, 1)
+
+#define __unlikely(expr) __builtin_expect(expr, 0)
+
+// This ends the doxygen deprecation comment
+//!@}
+
//! \deprecated Use GList * instead
typedef GList *GListPtr;
#ifdef __cplusplus
}
#endif
#endif // PCMK__CRM_COMPAT__H

File Metadata

Mime Type
text/x-diff
Expires
Thu, Jun 26, 6:07 PM (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1959341
Default Alt Text
(39 KB)

Event Timeline