@@ -37,10 +37,12 @@ void error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
void error_set_progname(const char *argv0);
void error_vreport(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0);
+void error_vreport_errno(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0);
void warn_vreport(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0);
void info_vreport(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0);
void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
+void error_report_errno(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
void warn_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
void info_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
@@ -245,6 +245,18 @@ void error_vreport(const char *fmt, va_list ap)
}
/*
+ * Print an error message to current monitor if we have one, else to stderr.
+ * Format arguments like vsprintf(). The resulting message should be
+ * a single phrase, with no newline or trailing punctuation.
+ * Prepend the current location and append ": " strerror(errno) "\n".
+ * It's wrong to call this in a QMP monitor. Use error_setg() there.
+ */
+void error_vreport_errno(const char *fmt, va_list ap)
+{
+ vreport(REPORT_TYPE_ERROR, errno, fmt, ap);
+}
+
+/*
* Print a warning message to current monitor if we have one, else to stderr.
* Format arguments like vsprintf(). The resulting message should be
* a single phrase, with no newline or trailing punctuation.
@@ -286,6 +298,22 @@ void error_report(const char *fmt, ...)
}
/*
+ * Print an error message to current monitor if we have one, else to stderr.
+ * Format arguments like sprintf(). The resulting message should be
+ * a single phrase, with no newline or trailing punctuation.
+ * Prepend the current location and append ": " strerror(errno) "\n".
+ * It's wrong to call this in a QMP monitor. Use error_setg() there.
+ */
+void error_report_errno(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vreport(REPORT_TYPE_ERROR, errno, fmt, ap);
+ va_end(ap);
+}
+
+/*
* Print a warning message to current monitor if we have one, else to stderr.
* Format arguments like sprintf(). The resulting message should be a
* single phrase, with no newline or trailing punctuation.
This will let us replace a lot of open coded calls to perror, strerror, etc. No callers yet so no functional change. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> --- include/qemu/error-report.h | 2 ++ util/qemu-error.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+)