4 * Copyright IBM, Corp. 2011
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU LGPL, version 2. See
10 * the COPYING.LIB file in the top-level directory.
15 #include "qemu/compiler.h"
16 #include "qapi-types.h"
20 * A class representing internal errors within QEMU. An error has a ErrorClass
21 * code and a human message.
23 typedef struct Error Error
;
26 * Set an indirect pointer to an error given a ErrorClass value and a
27 * printf-style human message. This function is not meant to be used outside
30 void error_set(Error
**errp
, ErrorClass err_class
, const char *fmt
, ...)
34 * Set an indirect pointer to an error given a ErrorClass value and a
35 * printf-style human message, followed by a strerror() string if
36 * @os_error is not zero.
38 void error_setg_errno(Error
**errp
, int os_error
, const char *fmt
, ...)
43 * Set an indirect pointer to an error given a ErrorClass value and a
44 * printf-style human message, followed by a g_win32_error_message() string if
45 * @win32_err is not zero.
47 void error_setg_win32(Error
**errp
, int win32_err
, const char *fmt
, ...)
52 * Same as error_set(), but sets a generic error
54 void error_setg(Error
**errp
, const char *fmt
, ...)
58 * Helper for open() errors
60 void error_setg_file_open(Error
**errp
, int os_errno
, const char *filename
);
63 * Get the error class of an error object.
65 ErrorClass
error_get_class(const Error
*err
);
68 * Returns an exact copy of the error passed as an argument.
70 Error
*error_copy(const Error
*err
);
73 * Get a human readable representation of an error object.
75 const char *error_get_pretty(Error
*err
);
78 * Convenience function to error_report() and free an error object.
80 void error_report_err(Error
*);
83 * Propagate an error to an indirect pointer to an error. This function will
84 * always transfer ownership of the error reference and handles the case where
85 * dst_err is NULL correctly. Errors after the first are discarded.
87 void error_propagate(Error
**dst_errp
, Error
*local_err
);
90 * Free an error object.
92 void error_free(Error
*err
);
95 * If passed to error_set and friends, abort().
98 extern Error
*error_abort
;