@@ -15,6 +15,7 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
+#include "qemu/error-report.h"
#include "block/block.h"
#include "qemu/rcu_queue.h"
#include "qemu/sockets.h"
@@ -80,7 +80,7 @@ static void __attribute__((constructor)) coroutine_init(void)
ret = pthread_key_create(&thread_state_key, qemu_coroutine_thread_cleanup);
if (ret != 0) {
- fprintf(stderr, "unable to create leader key: %s\n", strerror(errno));
+ error_report("unable to create leader key: %s", strerror(errno));
abort();
}
}
@@ -32,8 +32,8 @@ Error *error_fatal;
static void error_handle_fatal(Error **errp, Error *err)
{
if (errp == &error_abort) {
- fprintf(stderr, "Unexpected error in %s() at %s:%d:\n",
- err->func, err->src, err->line);
+ error_report("Unexpected error in %s() at %s:%d:",
+ err->func, err->src, err->line);
error_report_err(err);
abort();
}
@@ -95,7 +95,7 @@ static int qemu_signal_init(void)
sigdelset(&set, SIG_IPI);
sigfd = qemu_signalfd(&set);
if (sigfd == -1) {
- fprintf(stderr, "failed to create signalfd\n");
+ error_report("failed to create signalfd");
return -errno;
}
@@ -11,6 +11,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/error-report.h"
#include "qemu/mmap-alloc.h"
#include "qemu/host-utils.h"
@@ -51,7 +52,7 @@ size_t qemu_mempath_getpagesize(const char *mem_path)
} while (ret != 0 && errno == EINTR);
if (ret != 0) {
- fprintf(stderr, "Couldn't statfs() memory path: %s\n",
+ error_report("Couldn't statfs() memory path: %s",
strerror(errno));
exit(1);
}
@@ -124,13 +124,13 @@ static int module_load_file(const char *fname)
g_module = g_module_open(fname, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
if (!g_module) {
- fprintf(stderr, "Failed to open module: %s\n",
+ error_report("Failed to open module: %s",
g_module_error());
ret = -EINVAL;
goto out;
}
if (!g_module_symbol(g_module, DSO_STAMP_FUN_STR, (gpointer *)&sym)) {
- fprintf(stderr, "Failed to initialize module: %s\n",
+ error_report("Failed to initialize module: %s",
fname);
/* Print some info if this is a QEMU module (but from different build),
* this will make debugging user problems easier. */
@@ -169,7 +169,7 @@ void module_load_one(const char *prefix, const char *lib_name)
static GHashTable *loaded_modules;
if (!g_module_supported()) {
- fprintf(stderr, "Module is not supported by system.\n");
+ error_report("Module is not supported by system.");
return;
}
@@ -466,7 +466,7 @@ void fips_set_state(bool requested)
#endif /* __linux__ */
#ifdef _FIPS_DEBUG
- fprintf(stderr, "FIPS mode %s (requested %s)\n",
+ error_report("FIPS mode %s (requested %s)",
(fips_enabled ? "enabled" : "disabled"),
(requested ? "enabled" : "disabled"));
#endif
@@ -493,7 +493,7 @@ int socket_init(void)
ret = WSAStartup(MAKEWORD(2, 2), &Data);
if (ret != 0) {
err = WSAGetLastError();
- fprintf(stderr, "WSAStartup: %d\n", err);
+ error_report("WSAStartup: %d", err);
return -1;
}
atexit(socket_cleanup);
@@ -34,6 +34,7 @@
#include "sysemu/sysemu.h"
#include "trace.h"
#include "qapi/error.h"
+#include "qemu/error-report.h"
#include "qemu/sockets.h"
#include <libgen.h>
#include <sys/signal.h>
@@ -91,7 +92,7 @@ int qemu_daemon(int nochdir, int noclose)
void *qemu_oom_check(void *ptr)
{
if (ptr == NULL) {
- fprintf(stderr, "Failed to allocate memory: %s\n", strerror(errno));
+ error_report("Failed to allocate memory: %s", strerror(errno));
abort();
}
return ptr;
@@ -30,6 +30,7 @@
* see the license comment there.
*/
#include "qemu/osdep.h"
+#include "qemu/error-report.h"
#include <windows.h>
#include "qapi/error.h"
#include "sysemu/sysemu.h"
@@ -44,7 +45,7 @@
void *qemu_oom_check(void *ptr)
{
if (ptr == NULL) {
- fprintf(stderr, "Failed to allocate memory: %lu\n", GetLastError());
+ error_report("Failed to allocate memory: %lu", GetLastError());
abort();
}
return ptr;
@@ -13,6 +13,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/error-report.h"
#include "trace.h"
#include "qemu-common.h"
#include "qemu/thread.h"
@@ -110,7 +111,7 @@ void qemu_aio_coroutine_enter(AioContext *ctx, Coroutine *co)
trace_qemu_aio_coroutine_enter(ctx, self, co, co->entry_arg);
if (co->caller) {
- fprintf(stderr, "Co-routine re-entered recursively\n");
+ error_report("Co-routine re-entered recursively");
abort();
}
@@ -164,7 +165,7 @@ void coroutine_fn qemu_coroutine_yield(void)
trace_qemu_coroutine_yield(self, to);
if (!to) {
- fprintf(stderr, "Co-routine is yielding to no one\n");
+ error_report("Co-routine is yielding to no one");
abort();
}
@@ -23,6 +23,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/error-report.h"
#include "qemu-common.h"
struct progress_state {
@@ -68,7 +69,7 @@ static void sigusr_print(int signal)
static void progress_dummy_print(void)
{
if (print_pending) {
- fprintf(stderr, " (%3.2f/100%%)\n", state.current);
+ error_report(" (%3.2f/100%%)", state.current);
print_pending = 0;
}
}
@@ -11,6 +11,7 @@
*
*/
#include "qemu/osdep.h"
+#include "qemu/error-report.h"
#include "qemu/thread.h"
#include "qemu/atomic.h"
#include "qemu/notify.h"
@@ -25,14 +26,14 @@ void qemu_thread_naming(bool enable)
#ifndef CONFIG_THREAD_SETNAME_BYTHREAD
/* This is a debugging option, not fatal */
if (enable) {
- fprintf(stderr, "qemu: thread naming not supported on this host\n");
+ error_report("thread naming not supported on this host");
}
#endif
}
static void error_exit(int err, const char *msg)
{
- fprintf(stderr, "qemu: %s: %s\n", msg, strerror(err));
+ error_report("%s: %s", msg, strerror(err));
abort();
}
@@ -16,6 +16,7 @@
#endif
#include "qemu/osdep.h"
+#include "qemu/error-report.h"
#include "qemu-common.h"
#include "qemu/thread.h"
#include "qemu/notify.h"
@@ -29,7 +30,7 @@ void qemu_thread_naming(bool enable)
/* But note we don't actually name them on Windows yet */
name_threads = enable;
- fprintf(stderr, "qemu: thread naming not supported on this host\n");
+ error_report("thread naming not supported on this host");
}
static void error_exit(int err, const char *msg)
@@ -38,7 +39,7 @@ static void error_exit(int err, const char *msg)
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
NULL, err, 0, (LPTSTR)&pstr, 2, NULL);
- fprintf(stderr, "qemu: %s: %s\n", msg, pstr);
+ error_report("%s: %s", msg, pstr);
LocalFree(pstr);
abort();
}
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
#include "qemu/osdep.h"
+#include "qemu/error-report.h"
#include "qemu/timer.h"
/***********************************************************/
@@ -37,7 +38,7 @@ static void __attribute__((constructor)) init_get_clock(void)
int ret;
ret = QueryPerformanceFrequency(&freq);
if (ret == 0) {
- fprintf(stderr, "Could not calibrate ticks\n");
+ error_report("Could not calibrate ticks");
exit(1);
}
clock_freq = freq.QuadPart;
@@ -154,7 +154,7 @@ static void qht_bucket_debug__locked(struct qht_bucket *b)
continue;
}
if (seen_empty) {
- fprintf(stderr, "%s: b: %p, pos: %i, hash: 0x%x, p: %p\n",
+ error_report("%s: b: %p, pos: %i, hash: 0x%x, p: %p",
__func__, b, i, b->hashes[i], b->pointers[i]);
corrupt = true;
}