diff mbox series

[v3,42/46] util: Replace fprintf(stderr, "*\n" with error_report()

Message ID 7f741376b50552aa58c943b710fffa3c24f28b2f.1508390588.git.alistair.francis@xilinx.com
State New
Headers show
Series Remove some of the fprintf(stderr, "* | expand

Commit Message

Alistair Francis Oct. 19, 2017, 4:18 p.m. UTC
Replace a large number of the fprintf(stderr, "*\n" calls with
error_report(). The functions were renamed with these commands and then
compiler issues where manually fixed.

find ./* -type f -exec sed -i \
    'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
    {} +
find ./* -type f -exec sed -i \
    'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
    {} +
find ./* -type f -exec sed -i \
    'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
    {} +
find ./* -type f -exec sed -i \
    'N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
    {} +
find ./* -type f -exec sed -i \
    'N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
    {} +
find ./* -type f -exec sed -i \
    'N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
    {} +
find ./* -type f -exec sed -i \
    'N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
    {} +
find ./* -type f -exec sed -i \
    'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
    {} +
find ./* -type f -exec sed -i \
    'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
    {} +
find ./* -type f -exec sed -i \
    'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
    {} +
find ./* -type f -exec sed -i \
    'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
    {} +

Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Stefan Weil <sw@weilnetz.de>
Cc: qemu-block@nongnu.org
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---

 util/aio-posix.c             | 5 +++--
 util/coroutine-sigaltstack.c | 2 +-
 util/error.c                 | 2 +-
 util/main-loop.c             | 2 +-
 util/mmap-alloc.c            | 3 ++-
 util/module.c                | 6 +++---
 util/osdep.c                 | 4 ++--
 util/oslib-posix.c           | 3 ++-
 util/oslib-win32.c           | 3 ++-
 util/qemu-coroutine.c        | 5 +++--
 util/qemu-progress.c         | 3 ++-
 util/qemu-thread-posix.c     | 5 +++--
 util/qemu-thread-win32.c     | 5 +++--
 util/qemu-timer-common.c     | 3 ++-
 util/qht.c                   | 2 +-
 15 files changed, 31 insertions(+), 22 deletions(-)

Comments

Thomas Huth Oct. 19, 2017, 5:53 p.m. UTC | #1
On 19.10.2017 18:18, Alistair Francis wrote:
> Replace a large number of the fprintf(stderr, "*\n" calls with
> error_report(). The functions were renamed with these commands and then
> compiler issues where manually fixed.
[...]
> diff --git a/util/aio-posix.c b/util/aio-posix.c
> index 5946ac09f0..29fff51fcf 100644
> --- a/util/aio-posix.c
> +++ b/util/aio-posix.c
> @@ -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"
> @@ -703,8 +704,8 @@ void aio_context_setup(AioContext *ctx)
>  {
>      /* TODO remove this in final patch submission */
>      if (getenv("QEMU_AIO_POLL_MAX_NS")) {
> -        fprintf(stderr, "The QEMU_AIO_POLL_MAX_NS environment variable has "
> -                "been replaced with -object iothread,poll-max-ns=NUM\n");
> +        error_report("The QEMU_AIO_POLL_MAX_NS environment variable has "
> +                "been replaced with -object iothread,poll-max-ns=NUM");
>          exit(1);
>      }

The comment in front of this code block indicates that this should
rather be removed completely. Stefan, do you agree?

> diff --git a/util/error.c b/util/error.c
> index 3efdd69162..e423368ca0 100644
> --- a/util/error.c
> +++ b/util/error.c
> @@ -32,7 +32,7 @@ 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",
> +        error_report("Unexpected error in %s() at %s:%d:",
>                  err->func, err->src, err->line);

Indentation is still wrong if the statement spans more than one line :-(

 Thomas
Stefan Weil Oct. 19, 2017, 7:47 p.m. UTC | #2
Am 19.10.2017 um 19:53 schrieb Thomas Huth:
> On 19.10.2017 18:18, Alistair Francis wrote:
>> Replace a large number of the fprintf(stderr, "*\n" calls with
>> error_report(). The functions were renamed with these commands and then
>> compiler issues where manually fixed.
> [...]
>> diff --git a/util/aio-posix.c b/util/aio-posix.c
>> index 5946ac09f0..29fff51fcf 100644
>> --- a/util/aio-posix.c
>> +++ b/util/aio-posix.c
>> @@ -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"
>> @@ -703,8 +704,8 @@ void aio_context_setup(AioContext *ctx)
>>  {
>>      /* TODO remove this in final patch submission */
>>      if (getenv("QEMU_AIO_POLL_MAX_NS")) {
>> -        fprintf(stderr, "The QEMU_AIO_POLL_MAX_NS environment variable has "
>> -                "been replaced with -object iothread,poll-max-ns=NUM\n");
>> +        error_report("The QEMU_AIO_POLL_MAX_NS environment variable has "
>> +                "been replaced with -object iothread,poll-max-ns=NUM");
>>          exit(1);
>>      }
> 
> The comment in front of this code block indicates that this should
> rather be removed completely. Stefan, do you agree?


I assume you asked the other Stefan, but I think he'll agree as I do,
because it is obvious that such random debug code does not belong
into the QEMU code base.

Stefan
Thomas Huth Oct. 20, 2017, 6:27 a.m. UTC | #3
On 19.10.2017 21:47, Stefan Weil wrote:
> Am 19.10.2017 um 19:53 schrieb Thomas Huth:
>> On 19.10.2017 18:18, Alistair Francis wrote:
>>> Replace a large number of the fprintf(stderr, "*\n" calls with
>>> error_report(). The functions were renamed with these commands and then
>>> compiler issues where manually fixed.
>> [...]
>>> diff --git a/util/aio-posix.c b/util/aio-posix.c
>>> index 5946ac09f0..29fff51fcf 100644
>>> --- a/util/aio-posix.c
>>> +++ b/util/aio-posix.c
>>> @@ -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"
>>> @@ -703,8 +704,8 @@ void aio_context_setup(AioContext *ctx)
>>>  {
>>>      /* TODO remove this in final patch submission */
>>>      if (getenv("QEMU_AIO_POLL_MAX_NS")) {
>>> -        fprintf(stderr, "The QEMU_AIO_POLL_MAX_NS environment variable has "
>>> -                "been replaced with -object iothread,poll-max-ns=NUM\n");
>>> +        error_report("The QEMU_AIO_POLL_MAX_NS environment variable has "
>>> +                "been replaced with -object iothread,poll-max-ns=NUM");
>>>          exit(1);
>>>      }
>>
>> The comment in front of this code block indicates that this should
>> rather be removed completely. Stefan, do you agree?
> 
> I assume you asked the other Stefan, but I think he'll agree as I do,

Right, the code has been introduced by this commit:

commit 4a1cba3802554a3b077d436002519ff1fb0c18bf
Author: Stefan Hajnoczi <stefanha@redhat.com>
Date:   Thu Dec 1 19:26:42 2016 +0000

    aio: add polling mode to AioContext

and apparently the environment variable has never been used in the
committed code base, so removing this code block sounds like the right
way to go.

 Thomas
Stefan Hajnoczi Oct. 20, 2017, 10:47 a.m. UTC | #4
On Fri, Oct 20, 2017 at 08:27:41AM +0200, Thomas Huth wrote:
> On 19.10.2017 21:47, Stefan Weil wrote:
> > Am 19.10.2017 um 19:53 schrieb Thomas Huth:
> >> On 19.10.2017 18:18, Alistair Francis wrote:
> >>> Replace a large number of the fprintf(stderr, "*\n" calls with
> >>> error_report(). The functions were renamed with these commands and then
> >>> compiler issues where manually fixed.
> >> [...]
> >>> diff --git a/util/aio-posix.c b/util/aio-posix.c
> >>> index 5946ac09f0..29fff51fcf 100644
> >>> --- a/util/aio-posix.c
> >>> +++ b/util/aio-posix.c
> >>> @@ -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"
> >>> @@ -703,8 +704,8 @@ void aio_context_setup(AioContext *ctx)
> >>>  {
> >>>      /* TODO remove this in final patch submission */
> >>>      if (getenv("QEMU_AIO_POLL_MAX_NS")) {
> >>> -        fprintf(stderr, "The QEMU_AIO_POLL_MAX_NS environment variable has "
> >>> -                "been replaced with -object iothread,poll-max-ns=NUM\n");
> >>> +        error_report("The QEMU_AIO_POLL_MAX_NS environment variable has "
> >>> +                "been replaced with -object iothread,poll-max-ns=NUM");
> >>>          exit(1);
> >>>      }
> >>
> >> The comment in front of this code block indicates that this should
> >> rather be removed completely. Stefan, do you agree?
> > 
> > I assume you asked the other Stefan, but I think he'll agree as I do,
> 
> Right, the code has been introduced by this commit:
> 
> commit 4a1cba3802554a3b077d436002519ff1fb0c18bf
> Author: Stefan Hajnoczi <stefanha@redhat.com>
> Date:   Thu Dec 1 19:26:42 2016 +0000
> 
>     aio: add polling mode to AioContext
> 
> and apparently the environment variable has never been used in the
> committed code base, so removing this code block sounds like the right
> way to go.

Yes, feel free to remove it.

Initially the RFC patches used the QEMU_AIO_POLL_MAX_NS environment
variable.  When I wrote a proper command-line interface for this setting
I left the error to help any of the people testing this optimization
migrate their scripts to the new interface.

...Then I forgot to remove it for the final non-RFC patch which got
merged :).

Stefan
Alistair Francis Oct. 20, 2017, 4:38 p.m. UTC | #5
On Fri, Oct 20, 2017 at 3:47 AM, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> On Fri, Oct 20, 2017 at 08:27:41AM +0200, Thomas Huth wrote:
>> On 19.10.2017 21:47, Stefan Weil wrote:
>> > Am 19.10.2017 um 19:53 schrieb Thomas Huth:
>> >> On 19.10.2017 18:18, Alistair Francis wrote:
>> >>> Replace a large number of the fprintf(stderr, "*\n" calls with
>> >>> error_report(). The functions were renamed with these commands and then
>> >>> compiler issues where manually fixed.
>> >> [...]
>> >>> diff --git a/util/aio-posix.c b/util/aio-posix.c
>> >>> index 5946ac09f0..29fff51fcf 100644
>> >>> --- a/util/aio-posix.c
>> >>> +++ b/util/aio-posix.c
>> >>> @@ -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"
>> >>> @@ -703,8 +704,8 @@ void aio_context_setup(AioContext *ctx)
>> >>>  {
>> >>>      /* TODO remove this in final patch submission */
>> >>>      if (getenv("QEMU_AIO_POLL_MAX_NS")) {
>> >>> -        fprintf(stderr, "The QEMU_AIO_POLL_MAX_NS environment variable has "
>> >>> -                "been replaced with -object iothread,poll-max-ns=NUM\n");
>> >>> +        error_report("The QEMU_AIO_POLL_MAX_NS environment variable has "
>> >>> +                "been replaced with -object iothread,poll-max-ns=NUM");
>> >>>          exit(1);
>> >>>      }
>> >>
>> >> The comment in front of this code block indicates that this should
>> >> rather be removed completely. Stefan, do you agree?
>> >
>> > I assume you asked the other Stefan, but I think he'll agree as I do,
>>
>> Right, the code has been introduced by this commit:
>>
>> commit 4a1cba3802554a3b077d436002519ff1fb0c18bf
>> Author: Stefan Hajnoczi <stefanha@redhat.com>
>> Date:   Thu Dec 1 19:26:42 2016 +0000
>>
>>     aio: add polling mode to AioContext
>>
>> and apparently the environment variable has never been used in the
>> committed code base, so removing this code block sounds like the right
>> way to go.
>
> Yes, feel free to remove it.
>
> Initially the RFC patches used the QEMU_AIO_POLL_MAX_NS environment
> variable.  When I wrote a proper command-line interface for this setting
> I left the error to help any of the people testing this optimization
> migrate their scripts to the new interface.
>
> ...Then I forgot to remove it for the final non-RFC patch which got
> merged :).

Ok, I will remove it in the next version.

Thanks,
Alistair

>
> Stefan
diff mbox series

Patch

diff --git a/util/aio-posix.c b/util/aio-posix.c
index 5946ac09f0..29fff51fcf 100644
--- a/util/aio-posix.c
+++ b/util/aio-posix.c
@@ -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"
@@ -703,8 +704,8 @@  void aio_context_setup(AioContext *ctx)
 {
     /* TODO remove this in final patch submission */
     if (getenv("QEMU_AIO_POLL_MAX_NS")) {
-        fprintf(stderr, "The QEMU_AIO_POLL_MAX_NS environment variable has "
-                "been replaced with -object iothread,poll-max-ns=NUM\n");
+        error_report("The QEMU_AIO_POLL_MAX_NS environment variable has "
+                "been replaced with -object iothread,poll-max-ns=NUM");
         exit(1);
     }
 
diff --git a/util/coroutine-sigaltstack.c b/util/coroutine-sigaltstack.c
index f6fc49a0e5..96a01c2c88 100644
--- a/util/coroutine-sigaltstack.c
+++ b/util/coroutine-sigaltstack.c
@@ -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();
     }
 }
diff --git a/util/error.c b/util/error.c
index 3efdd69162..e423368ca0 100644
--- a/util/error.c
+++ b/util/error.c
@@ -32,7 +32,7 @@  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",
+        error_report("Unexpected error in %s() at %s:%d:",
                 err->func, err->src, err->line);
         error_report_err(err);
         abort();
diff --git a/util/main-loop.c b/util/main-loop.c
index 7558eb5f53..d8369716b2 100644
--- a/util/main-loop.c
+++ b/util/main-loop.c
@@ -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;
     }
 
diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c
index 3ec029a9ea..11887aac69 100644
--- a/util/mmap-alloc.c
+++ b/util/mmap-alloc.c
@@ -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);
     }
diff --git a/util/module.c b/util/module.c
index c90973721f..1153e3ebb0 100644
--- a/util/module.c
+++ b/util/module.c
@@ -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;
     }
 
diff --git a/util/osdep.c b/util/osdep.c
index a479fedc4a..62d92c9560 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -425,7 +425,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
@@ -452,7 +452,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);
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 80086c549f..d840692dd7 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -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>
@@ -87,7 +88,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;
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index 69a6286d50..2197a6a4fc 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -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;
diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c
index d6095c1d5a..1f7cce6706 100644
--- a/util/qemu-coroutine.c
+++ b/util/qemu-coroutine.c
@@ -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();
     }
 
diff --git a/util/qemu-progress.c b/util/qemu-progress.c
index 3c2223c1a2..84598f0fbb 100644
--- a/util/qemu-progress.c
+++ b/util/qemu-progress.c
@@ -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;
     }
 }
diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
index 7306475899..1207ef71d6 100644
--- a/util/qemu-thread-posix.c
+++ b/util/qemu-thread-posix.c
@@ -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();
 }
 
diff --git a/util/qemu-thread-win32.c b/util/qemu-thread-win32.c
index 94f3491a87..02b94e22da 100644
--- a/util/qemu-thread-win32.c
+++ b/util/qemu-thread-win32.c
@@ -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();
 }
diff --git a/util/qemu-timer-common.c b/util/qemu-timer-common.c
index 06d084d364..ab7b702c4f 100644
--- a/util/qemu-timer-common.c
+++ b/util/qemu-timer-common.c
@@ -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;
diff --git a/util/qht.c b/util/qht.c
index ff4d2e6974..bfab5c7e5e 100644
--- a/util/qht.c
+++ b/util/qht.c
@@ -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;
             }