@@ -43,4 +43,23 @@ void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
const char *error_get_progname(void);
extern bool enable_timestamp_msg;
+/* Report message and exit with error */
+void QEMU_NORETURN error_vreport_fatal(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0);
+void QEMU_NORETURN error_report_fatal(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
+/* Report message with caller location and abort */
+#define error_vreport_abort(fmt, ap) \
+ do { \
+ error_report_abort_caller_internal(__FILE__, __LINE__, __func__); \
+ error_vreport_abort_internal(fmt, ap); \
+ } while (0)
+#define error_report_abort(fmt, ...) \
+ do { \
+ error_report_abort_caller_internal(__FILE__, __LINE__, __func__); \
+ error_report_abort_internal(fmt, ##__VA_ARGS__); \
+ } while (0)
+
+void error_report_abort_caller_internal(const char *file, int line, const char *func);
+void QEMU_NORETURN error_vreport_abort_internal(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0);
+void QEMU_NORETURN error_report_abort_internal(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
+
#endif
@@ -237,3 +237,36 @@ void error_report(const char *fmt, ...)
error_vreport(fmt, ap);
va_end(ap);
}
+
+void error_vreport_fatal(const char *fmt, va_list ap)
+{
+ error_vreport(fmt, ap);
+ exit(1);
+}
+
+void error_report_fatal(const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ error_vreport_fatal(fmt, ap);
+ va_end(ap);
+}
+
+void error_report_abort_caller_internal(const char *file, int line, const char *func)
+{
+ error_report("Unexpected error in %s() at %s:%d:", func, file, line);
+}
+
+void error_vreport_abort_internal(const char *fmt, va_list ap)
+{
+ error_vreport(fmt, ap);
+ abort();
+}
+
+void error_report_abort_internal(const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ error_vreport_abort_internal(fmt, ap);
+ va_end(ap);
+}
Provide two lean functions to report error messages that fatal/abort QEMU. Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu> --- include/qemu/error-report.h | 19 +++++++++++++++++++ util/qemu-error.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+)