diff mbox

[v2] Convert stderr message calling error_get_pretty() to error_report()

Message ID 51FFFFBC.6050101@hds.com
State New
Headers show

Commit Message

Seiji Aguchi Aug. 5, 2013, 7:40 p.m. UTC
Convert stderr messages calling error_get_pretty()
to error_report().

Timestamp is prepended by -msg timstamp option with it.

Per Markus's comment below, A conversion from fprintf() to
error_report() is always an improvement, regardless of 
error_get_pretty().

http://marc.info/?l=qemu-devel&m=137513283408601&w=2

But, it is not reasonable to convert them at one time
because fprintf() is used everwhere in qemu.

So, it should be done step by step with avoiding regression.

Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com>
---
Change from v2
 - Remove "\n" from strings because error_report() appends it.

 Patch v1
 http://marc.info/?l=qemu-devel&m=137452706024842&w=2
---
 arch_init.c                 |    4 ++--
 hw/char/serial.c            |    5 +++--
 hw/i386/pc.c                |    6 +++---
 qemu-char.c                 |    2 +-
 target-i386/cpu.c           |    2 +-
 target-ppc/translate_init.c |    3 ++-
 vl.c                        |    9 +++++----
 7 files changed, 17 insertions(+), 14 deletions(-)

-- 1.7.1

Comments

Laszlo Ersek Aug. 7, 2013, 7:09 p.m. UTC | #1
On 08/05/13 21:40, Seiji Aguchi wrote:
> Convert stderr messages calling error_get_pretty()
> to error_report().
> 
> Timestamp is prepended by -msg timstamp option with it.
> 
> Per Markus's comment below, A conversion from fprintf() to
> error_report() is always an improvement, regardless of 
> error_get_pretty().
> 
> http://marc.info/?l=qemu-devel&m=137513283408601&w=2
> 
> But, it is not reasonable to convert them at one time
> because fprintf() is used everwhere in qemu.
> 
> So, it should be done step by step with avoiding regression.
> 
> Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com>
> ---
> Change from v2
>  - Remove "\n" from strings because error_report() appends it.
> 
>  Patch v1
>  http://marc.info/?l=qemu-devel&m=137452706024842&w=2
> ---
>  arch_init.c                 |    4 ++--
>  hw/char/serial.c            |    5 +++--
>  hw/i386/pc.c                |    6 +++---
>  qemu-char.c                 |    2 +-
>  target-i386/cpu.c           |    2 +-
>  target-ppc/translate_init.c |    3 ++-
>  vl.c                        |    9 +++++----
>  7 files changed, 17 insertions(+), 14 deletions(-)
> 
> diff --git a/arch_init.c b/arch_init.c
> index 68a7ab7..94d45e1 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -1125,8 +1125,8 @@ void do_acpitable_option(const QemuOpts *opts)
>  
>      acpi_table_add(opts, &err);
>      if (err) {
> -        fprintf(stderr, "Wrong acpi table provided: %s\n",
> -                error_get_pretty(err));
> +        error_report("Wrong acpi table provided: %s",
> +                     error_get_pretty(err));
>          error_free(err);
>          exit(1);
>      }
> diff --git a/hw/char/serial.c b/hw/char/serial.c
> index 6025592..a31eb57 100644
> --- a/hw/char/serial.c
> +++ b/hw/char/serial.c
> @@ -27,6 +27,7 @@
>  #include "sysemu/char.h"
>  #include "qemu/timer.h"
>  #include "exec/address-spaces.h"
> +#include "qemu/error-report.h"
>  
>  //#define DEBUG_SERIAL
>  
> @@ -696,7 +697,7 @@ SerialState *serial_init(int base, qemu_irq irq, int baudbase,
>      s->chr = chr;
>      serial_realize_core(s, &err);
>      if (err != NULL) {
> -        fprintf(stderr, "%s\n", error_get_pretty(err));
> +        error_report("%s", error_get_pretty(err));
>          error_free(err);
>          exit(1);
>      }
> @@ -760,7 +761,7 @@ SerialState *serial_mm_init(MemoryRegion *address_space,
>  
>      serial_realize_core(s, &err);
>      if (err != NULL) {
> -        fprintf(stderr, "%s\n", error_get_pretty(err));
> +        error_report("%s", error_get_pretty(err));
>          error_free(err);
>          exit(1);
>      }
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index a2b9d88..5bce10f 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -979,7 +979,7 @@ void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge)
>          cpu = pc_new_cpu(cpu_model, x86_cpu_apic_id_from_index(i),
>                           icc_bridge, &error);
>          if (error) {
> -            fprintf(stderr, "%s\n", error_get_pretty(error));
> +            error_report("%s", error_get_pretty(error));
>              error_free(error);
>              exit(1);
>          }
> @@ -1097,8 +1097,8 @@ void pc_acpi_init(const char *default_dsdt)
>  
>          acpi_table_add(opts, &err);
>          if (err) {
> -            fprintf(stderr, "WARNING: failed to load %s: %s\n", filename,
> -                    error_get_pretty(err));
> +            error_report("WARNING: failed to load %s: %s", filename,
> +                         error_get_pretty(err));
>              error_free(err);
>          }
>          g_free(arg);
> diff --git a/qemu-char.c b/qemu-char.c
> index 3f606c9..2e9a11d 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -3299,7 +3299,7 @@ CharDriverState *qemu_chr_new(const char *label, const char *filename, void (*in
>  
>      chr = qemu_chr_new_from_opts(opts, init, &err);
>      if (error_is_set(&err)) {
> -        fprintf(stderr, "%s\n", error_get_pretty(err));
> +        error_report("%s", error_get_pretty(err));
>          error_free(err);
>      }
>      if (chr && qemu_opt_get_bool(opts, "mux", 0)) {
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index 71ab915..43061e2 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -1843,7 +1843,7 @@ X86CPU *cpu_x86_init(const char *cpu_model)
>  
>  out:
>      if (error) {
> -        fprintf(stderr, "%s\n", error_get_pretty(error));
> +        error_report("%s", error_get_pretty(error));
>          error_free(error);
>          if (cpu != NULL) {
>              object_unref(OBJECT(cpu));
> diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
> index 0724226..3cf74a2 100644
> --- a/target-ppc/translate_init.c
> +++ b/target-ppc/translate_init.c
> @@ -27,6 +27,7 @@
>  #include "cpu-models.h"
>  #include "mmu-hash32.h"
>  #include "mmu-hash64.h"
> +#include "qemu/error-report.h"
>  
>  //#define PPC_DUMP_CPU
>  //#define PPC_DEBUG_SPR
> @@ -8177,7 +8178,7 @@ PowerPCCPU *cpu_ppc_init(const char *cpu_model)
>  
>      object_property_set_bool(OBJECT(cpu), true, "realized", &err);
>      if (err != NULL) {
> -        fprintf(stderr, "%s\n", error_get_pretty(err));
> +        error_report("%s", error_get_pretty(err));
>          error_free(err);
>          object_unref(OBJECT(cpu));
>          return NULL;
> diff --git a/vl.c b/vl.c
> index 25b8f2f..2e427d8 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2393,7 +2393,7 @@ static int chardev_init_func(QemuOpts *opts, void *opaque)
>  
>      qemu_chr_new_from_opts(opts, NULL, &local_err);
>      if (error_is_set(&local_err)) {
> -        fprintf(stderr, "%s\n", error_get_pretty(local_err));
> +        error_report("%s", error_get_pretty(local_err));
>          error_free(local_err);
>          return -1;
>      }
> @@ -4375,8 +4375,8 @@ int main(int argc, char **argv, char **envp)
>          vnc_display_init(ds);
>          vnc_display_open(ds, vnc_display, &local_err);
>          if (local_err != NULL) {
> -            fprintf(stderr, "Failed to start VNC server on `%s': %s\n",
> -                    vnc_display, error_get_pretty(local_err));
> +            error_report("Failed to start VNC server on `%s': %s",
> +                         vnc_display, error_get_pretty(local_err));
>              error_free(local_err);
>              exit(1);
>          }
> @@ -4419,7 +4419,8 @@ int main(int argc, char **argv, char **envp)
>          Error *local_err = NULL;
>          qemu_start_incoming_migration(incoming, &local_err);
>          if (local_err) {
> -            fprintf(stderr, "-incoming %s: %s\n", incoming, error_get_pretty(local_err));
> +            error_report("-incoming %s: %s", incoming,
> +                         error_get_pretty(local_err));
>              error_free(local_err);
>              exit(1);
>          }
> -- 1.7.1
> 
> 
> 

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Seiji Aguchi Aug. 13, 2013, 8:27 p.m. UTC | #2
Luiz,

Can you pick up to your tree?

Seiji

> -----Original Message-----

> From: Laszlo Ersek [mailto:lersek@redhat.com]

> Sent: Wednesday, August 07, 2013 3:10 PM

> To: Seiji Aguchi

> Cc: qemu-devel@nongnu.org; armbru@redhat.com; Tomoki Sekiyama; lcapitulino@redhat.com

> Subject: Re: [Qemu-devel] [PATCH v2] Convert stderr message calling error_get_pretty() to error_report()

> 

> On 08/05/13 21:40, Seiji Aguchi wrote:

> > Convert stderr messages calling error_get_pretty()

> > to error_report().

> >

> > Timestamp is prepended by -msg timstamp option with it.

> >

> > Per Markus's comment below, A conversion from fprintf() to

> > error_report() is always an improvement, regardless of

> > error_get_pretty().

> >

> > http://marc.info/?l=qemu-devel&m=137513283408601&w=2

> >

> > But, it is not reasonable to convert them at one time

> > because fprintf() is used everwhere in qemu.

> >

> > So, it should be done step by step with avoiding regression.

> >

> > Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com>

> > ---

> > Change from v2

> >  - Remove "\n" from strings because error_report() appends it.

> >

> >  Patch v1

> >  http://marc.info/?l=qemu-devel&m=137452706024842&w=2

> > ---

> >  arch_init.c                 |    4 ++--

> >  hw/char/serial.c            |    5 +++--

> >  hw/i386/pc.c                |    6 +++---

> >  qemu-char.c                 |    2 +-

> >  target-i386/cpu.c           |    2 +-

> >  target-ppc/translate_init.c |    3 ++-

> >  vl.c                        |    9 +++++----

> >  7 files changed, 17 insertions(+), 14 deletions(-)

> >

> > diff --git a/arch_init.c b/arch_init.c

> > index 68a7ab7..94d45e1 100644

> > --- a/arch_init.c

> > +++ b/arch_init.c

> > @@ -1125,8 +1125,8 @@ void do_acpitable_option(const QemuOpts *opts)

> >

> >      acpi_table_add(opts, &err);

> >      if (err) {

> > -        fprintf(stderr, "Wrong acpi table provided: %s\n",

> > -                error_get_pretty(err));

> > +        error_report("Wrong acpi table provided: %s",

> > +                     error_get_pretty(err));

> >          error_free(err);

> >          exit(1);

> >      }

> > diff --git a/hw/char/serial.c b/hw/char/serial.c

> > index 6025592..a31eb57 100644

> > --- a/hw/char/serial.c

> > +++ b/hw/char/serial.c

> > @@ -27,6 +27,7 @@

> >  #include "sysemu/char.h"

> >  #include "qemu/timer.h"

> >  #include "exec/address-spaces.h"

> > +#include "qemu/error-report.h"

> >

> >  //#define DEBUG_SERIAL

> >

> > @@ -696,7 +697,7 @@ SerialState *serial_init(int base, qemu_irq irq, int baudbase,

> >      s->chr = chr;

> >      serial_realize_core(s, &err);

> >      if (err != NULL) {

> > -        fprintf(stderr, "%s\n", error_get_pretty(err));

> > +        error_report("%s", error_get_pretty(err));

> >          error_free(err);

> >          exit(1);

> >      }

> > @@ -760,7 +761,7 @@ SerialState *serial_mm_init(MemoryRegion *address_space,

> >

> >      serial_realize_core(s, &err);

> >      if (err != NULL) {

> > -        fprintf(stderr, "%s\n", error_get_pretty(err));

> > +        error_report("%s", error_get_pretty(err));

> >          error_free(err);

> >          exit(1);

> >      }

> > diff --git a/hw/i386/pc.c b/hw/i386/pc.c

> > index a2b9d88..5bce10f 100644

> > --- a/hw/i386/pc.c

> > +++ b/hw/i386/pc.c

> > @@ -979,7 +979,7 @@ void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge)

> >          cpu = pc_new_cpu(cpu_model, x86_cpu_apic_id_from_index(i),

> >                           icc_bridge, &error);

> >          if (error) {

> > -            fprintf(stderr, "%s\n", error_get_pretty(error));

> > +            error_report("%s", error_get_pretty(error));

> >              error_free(error);

> >              exit(1);

> >          }

> > @@ -1097,8 +1097,8 @@ void pc_acpi_init(const char *default_dsdt)

> >

> >          acpi_table_add(opts, &err);

> >          if (err) {

> > -            fprintf(stderr, "WARNING: failed to load %s: %s\n", filename,

> > -                    error_get_pretty(err));

> > +            error_report("WARNING: failed to load %s: %s", filename,

> > +                         error_get_pretty(err));

> >              error_free(err);

> >          }

> >          g_free(arg);

> > diff --git a/qemu-char.c b/qemu-char.c

> > index 3f606c9..2e9a11d 100644

> > --- a/qemu-char.c

> > +++ b/qemu-char.c

> > @@ -3299,7 +3299,7 @@ CharDriverState *qemu_chr_new(const char *label, const char *filename, void (*in

> >

> >      chr = qemu_chr_new_from_opts(opts, init, &err);

> >      if (error_is_set(&err)) {

> > -        fprintf(stderr, "%s\n", error_get_pretty(err));

> > +        error_report("%s", error_get_pretty(err));

> >          error_free(err);

> >      }

> >      if (chr && qemu_opt_get_bool(opts, "mux", 0)) {

> > diff --git a/target-i386/cpu.c b/target-i386/cpu.c

> > index 71ab915..43061e2 100644

> > --- a/target-i386/cpu.c

> > +++ b/target-i386/cpu.c

> > @@ -1843,7 +1843,7 @@ X86CPU *cpu_x86_init(const char *cpu_model)

> >

> >  out:

> >      if (error) {

> > -        fprintf(stderr, "%s\n", error_get_pretty(error));

> > +        error_report("%s", error_get_pretty(error));

> >          error_free(error);

> >          if (cpu != NULL) {

> >              object_unref(OBJECT(cpu));

> > diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c

> > index 0724226..3cf74a2 100644

> > --- a/target-ppc/translate_init.c

> > +++ b/target-ppc/translate_init.c

> > @@ -27,6 +27,7 @@

> >  #include "cpu-models.h"

> >  #include "mmu-hash32.h"

> >  #include "mmu-hash64.h"

> > +#include "qemu/error-report.h"

> >

> >  //#define PPC_DUMP_CPU

> >  //#define PPC_DEBUG_SPR

> > @@ -8177,7 +8178,7 @@ PowerPCCPU *cpu_ppc_init(const char *cpu_model)

> >

> >      object_property_set_bool(OBJECT(cpu), true, "realized", &err);

> >      if (err != NULL) {

> > -        fprintf(stderr, "%s\n", error_get_pretty(err));

> > +        error_report("%s", error_get_pretty(err));

> >          error_free(err);

> >          object_unref(OBJECT(cpu));

> >          return NULL;

> > diff --git a/vl.c b/vl.c

> > index 25b8f2f..2e427d8 100644

> > --- a/vl.c

> > +++ b/vl.c

> > @@ -2393,7 +2393,7 @@ static int chardev_init_func(QemuOpts *opts, void *opaque)

> >

> >      qemu_chr_new_from_opts(opts, NULL, &local_err);

> >      if (error_is_set(&local_err)) {

> > -        fprintf(stderr, "%s\n", error_get_pretty(local_err));

> > +        error_report("%s", error_get_pretty(local_err));

> >          error_free(local_err);

> >          return -1;

> >      }

> > @@ -4375,8 +4375,8 @@ int main(int argc, char **argv, char **envp)

> >          vnc_display_init(ds);

> >          vnc_display_open(ds, vnc_display, &local_err);

> >          if (local_err != NULL) {

> > -            fprintf(stderr, "Failed to start VNC server on `%s': %s\n",

> > -                    vnc_display, error_get_pretty(local_err));

> > +            error_report("Failed to start VNC server on `%s': %s",

> > +                         vnc_display, error_get_pretty(local_err));

> >              error_free(local_err);

> >              exit(1);

> >          }

> > @@ -4419,7 +4419,8 @@ int main(int argc, char **argv, char **envp)

> >          Error *local_err = NULL;

> >          qemu_start_incoming_migration(incoming, &local_err);

> >          if (local_err) {

> > -            fprintf(stderr, "-incoming %s: %s\n", incoming, error_get_pretty(local_err));

> > +            error_report("-incoming %s: %s", incoming,

> > +                         error_get_pretty(local_err));

> >              error_free(local_err);

> >              exit(1);

> >          }

> > -- 1.7.1

> >

> >

> >

> 

> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Luiz Capitulino Aug. 13, 2013, 8:33 p.m. UTC | #3
On Tue, 13 Aug 2013 20:27:15 +0000
Seiji Aguchi <seiji.aguchi@hds.com> wrote:

> Luiz,
> 
> Can you pick up to your tree?

Yes, this is queued for review for 1.7. I should start reviewing patches
for 1.7 in the end of this week or in the beginning of next week.
Luiz Capitulino Aug. 19, 2013, 7:38 p.m. UTC | #4
On Mon, 05 Aug 2013 15:40:44 -0400
Seiji Aguchi <seiji.aguchi@hds.com> wrote:

> Convert stderr messages calling error_get_pretty()
> to error_report().
> 
> Timestamp is prepended by -msg timstamp option with it.
> 
> Per Markus's comment below, A conversion from fprintf() to
> error_report() is always an improvement, regardless of 
> error_get_pretty().
> 
> http://marc.info/?l=qemu-devel&m=137513283408601&w=2
> 
> But, it is not reasonable to convert them at one time
> because fprintf() is used everwhere in qemu.
> 
> So, it should be done step by step with avoiding regression.
> 
> Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com>

Applied to the qmp branch, thanks.

> ---
> Change from v2
>  - Remove "\n" from strings because error_report() appends it.
> 
>  Patch v1
>  http://marc.info/?l=qemu-devel&m=137452706024842&w=2
> ---
>  arch_init.c                 |    4 ++--
>  hw/char/serial.c            |    5 +++--
>  hw/i386/pc.c                |    6 +++---
>  qemu-char.c                 |    2 +-
>  target-i386/cpu.c           |    2 +-
>  target-ppc/translate_init.c |    3 ++-
>  vl.c                        |    9 +++++----
>  7 files changed, 17 insertions(+), 14 deletions(-)
> 
> diff --git a/arch_init.c b/arch_init.c
> index 68a7ab7..94d45e1 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -1125,8 +1125,8 @@ void do_acpitable_option(const QemuOpts *opts)
>  
>      acpi_table_add(opts, &err);
>      if (err) {
> -        fprintf(stderr, "Wrong acpi table provided: %s\n",
> -                error_get_pretty(err));
> +        error_report("Wrong acpi table provided: %s",
> +                     error_get_pretty(err));
>          error_free(err);
>          exit(1);
>      }
> diff --git a/hw/char/serial.c b/hw/char/serial.c
> index 6025592..a31eb57 100644
> --- a/hw/char/serial.c
> +++ b/hw/char/serial.c
> @@ -27,6 +27,7 @@
>  #include "sysemu/char.h"
>  #include "qemu/timer.h"
>  #include "exec/address-spaces.h"
> +#include "qemu/error-report.h"
>  
>  //#define DEBUG_SERIAL
>  
> @@ -696,7 +697,7 @@ SerialState *serial_init(int base, qemu_irq irq, int baudbase,
>      s->chr = chr;
>      serial_realize_core(s, &err);
>      if (err != NULL) {
> -        fprintf(stderr, "%s\n", error_get_pretty(err));
> +        error_report("%s", error_get_pretty(err));
>          error_free(err);
>          exit(1);
>      }
> @@ -760,7 +761,7 @@ SerialState *serial_mm_init(MemoryRegion *address_space,
>  
>      serial_realize_core(s, &err);
>      if (err != NULL) {
> -        fprintf(stderr, "%s\n", error_get_pretty(err));
> +        error_report("%s", error_get_pretty(err));
>          error_free(err);
>          exit(1);
>      }
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index a2b9d88..5bce10f 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -979,7 +979,7 @@ void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge)
>          cpu = pc_new_cpu(cpu_model, x86_cpu_apic_id_from_index(i),
>                           icc_bridge, &error);
>          if (error) {
> -            fprintf(stderr, "%s\n", error_get_pretty(error));
> +            error_report("%s", error_get_pretty(error));
>              error_free(error);
>              exit(1);
>          }
> @@ -1097,8 +1097,8 @@ void pc_acpi_init(const char *default_dsdt)
>  
>          acpi_table_add(opts, &err);
>          if (err) {
> -            fprintf(stderr, "WARNING: failed to load %s: %s\n", filename,
> -                    error_get_pretty(err));
> +            error_report("WARNING: failed to load %s: %s", filename,
> +                         error_get_pretty(err));
>              error_free(err);
>          }
>          g_free(arg);
> diff --git a/qemu-char.c b/qemu-char.c
> index 3f606c9..2e9a11d 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -3299,7 +3299,7 @@ CharDriverState *qemu_chr_new(const char *label, const char *filename, void (*in
>  
>      chr = qemu_chr_new_from_opts(opts, init, &err);
>      if (error_is_set(&err)) {
> -        fprintf(stderr, "%s\n", error_get_pretty(err));
> +        error_report("%s", error_get_pretty(err));
>          error_free(err);
>      }
>      if (chr && qemu_opt_get_bool(opts, "mux", 0)) {
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index 71ab915..43061e2 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -1843,7 +1843,7 @@ X86CPU *cpu_x86_init(const char *cpu_model)
>  
>  out:
>      if (error) {
> -        fprintf(stderr, "%s\n", error_get_pretty(error));
> +        error_report("%s", error_get_pretty(error));
>          error_free(error);
>          if (cpu != NULL) {
>              object_unref(OBJECT(cpu));
> diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
> index 0724226..3cf74a2 100644
> --- a/target-ppc/translate_init.c
> +++ b/target-ppc/translate_init.c
> @@ -27,6 +27,7 @@
>  #include "cpu-models.h"
>  #include "mmu-hash32.h"
>  #include "mmu-hash64.h"
> +#include "qemu/error-report.h"
>  
>  //#define PPC_DUMP_CPU
>  //#define PPC_DEBUG_SPR
> @@ -8177,7 +8178,7 @@ PowerPCCPU *cpu_ppc_init(const char *cpu_model)
>  
>      object_property_set_bool(OBJECT(cpu), true, "realized", &err);
>      if (err != NULL) {
> -        fprintf(stderr, "%s\n", error_get_pretty(err));
> +        error_report("%s", error_get_pretty(err));
>          error_free(err);
>          object_unref(OBJECT(cpu));
>          return NULL;
> diff --git a/vl.c b/vl.c
> index 25b8f2f..2e427d8 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2393,7 +2393,7 @@ static int chardev_init_func(QemuOpts *opts, void *opaque)
>  
>      qemu_chr_new_from_opts(opts, NULL, &local_err);
>      if (error_is_set(&local_err)) {
> -        fprintf(stderr, "%s\n", error_get_pretty(local_err));
> +        error_report("%s", error_get_pretty(local_err));
>          error_free(local_err);
>          return -1;
>      }
> @@ -4375,8 +4375,8 @@ int main(int argc, char **argv, char **envp)
>          vnc_display_init(ds);
>          vnc_display_open(ds, vnc_display, &local_err);
>          if (local_err != NULL) {
> -            fprintf(stderr, "Failed to start VNC server on `%s': %s\n",
> -                    vnc_display, error_get_pretty(local_err));
> +            error_report("Failed to start VNC server on `%s': %s",
> +                         vnc_display, error_get_pretty(local_err));
>              error_free(local_err);
>              exit(1);
>          }
> @@ -4419,7 +4419,8 @@ int main(int argc, char **argv, char **envp)
>          Error *local_err = NULL;
>          qemu_start_incoming_migration(incoming, &local_err);
>          if (local_err) {
> -            fprintf(stderr, "-incoming %s: %s\n", incoming, error_get_pretty(local_err));
> +            error_report("-incoming %s: %s", incoming,
> +                         error_get_pretty(local_err));
>              error_free(local_err);
>              exit(1);
>          }
> -- 1.7.1
> 
>
diff mbox

Patch

diff --git a/arch_init.c b/arch_init.c
index 68a7ab7..94d45e1 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -1125,8 +1125,8 @@  void do_acpitable_option(const QemuOpts *opts)
 
     acpi_table_add(opts, &err);
     if (err) {
-        fprintf(stderr, "Wrong acpi table provided: %s\n",
-                error_get_pretty(err));
+        error_report("Wrong acpi table provided: %s",
+                     error_get_pretty(err));
         error_free(err);
         exit(1);
     }
diff --git a/hw/char/serial.c b/hw/char/serial.c
index 6025592..a31eb57 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -27,6 +27,7 @@ 
 #include "sysemu/char.h"
 #include "qemu/timer.h"
 #include "exec/address-spaces.h"
+#include "qemu/error-report.h"
 
 //#define DEBUG_SERIAL
 
@@ -696,7 +697,7 @@  SerialState *serial_init(int base, qemu_irq irq, int baudbase,
     s->chr = chr;
     serial_realize_core(s, &err);
     if (err != NULL) {
-        fprintf(stderr, "%s\n", error_get_pretty(err));
+        error_report("%s", error_get_pretty(err));
         error_free(err);
         exit(1);
     }
@@ -760,7 +761,7 @@  SerialState *serial_mm_init(MemoryRegion *address_space,
 
     serial_realize_core(s, &err);
     if (err != NULL) {
-        fprintf(stderr, "%s\n", error_get_pretty(err));
+        error_report("%s", error_get_pretty(err));
         error_free(err);
         exit(1);
     }
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index a2b9d88..5bce10f 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -979,7 +979,7 @@  void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge)
         cpu = pc_new_cpu(cpu_model, x86_cpu_apic_id_from_index(i),
                          icc_bridge, &error);
         if (error) {
-            fprintf(stderr, "%s\n", error_get_pretty(error));
+            error_report("%s", error_get_pretty(error));
             error_free(error);
             exit(1);
         }
@@ -1097,8 +1097,8 @@  void pc_acpi_init(const char *default_dsdt)
 
         acpi_table_add(opts, &err);
         if (err) {
-            fprintf(stderr, "WARNING: failed to load %s: %s\n", filename,
-                    error_get_pretty(err));
+            error_report("WARNING: failed to load %s: %s", filename,
+                         error_get_pretty(err));
             error_free(err);
         }
         g_free(arg);
diff --git a/qemu-char.c b/qemu-char.c
index 3f606c9..2e9a11d 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -3299,7 +3299,7 @@  CharDriverState *qemu_chr_new(const char *label, const char *filename, void (*in
 
     chr = qemu_chr_new_from_opts(opts, init, &err);
     if (error_is_set(&err)) {
-        fprintf(stderr, "%s\n", error_get_pretty(err));
+        error_report("%s", error_get_pretty(err));
         error_free(err);
     }
     if (chr && qemu_opt_get_bool(opts, "mux", 0)) {
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 71ab915..43061e2 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1843,7 +1843,7 @@  X86CPU *cpu_x86_init(const char *cpu_model)
 
 out:
     if (error) {
-        fprintf(stderr, "%s\n", error_get_pretty(error));
+        error_report("%s", error_get_pretty(error));
         error_free(error);
         if (cpu != NULL) {
             object_unref(OBJECT(cpu));
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 0724226..3cf74a2 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -27,6 +27,7 @@ 
 #include "cpu-models.h"
 #include "mmu-hash32.h"
 #include "mmu-hash64.h"
+#include "qemu/error-report.h"
 
 //#define PPC_DUMP_CPU
 //#define PPC_DEBUG_SPR
@@ -8177,7 +8178,7 @@  PowerPCCPU *cpu_ppc_init(const char *cpu_model)
 
     object_property_set_bool(OBJECT(cpu), true, "realized", &err);
     if (err != NULL) {
-        fprintf(stderr, "%s\n", error_get_pretty(err));
+        error_report("%s", error_get_pretty(err));
         error_free(err);
         object_unref(OBJECT(cpu));
         return NULL;
diff --git a/vl.c b/vl.c
index 25b8f2f..2e427d8 100644
--- a/vl.c
+++ b/vl.c
@@ -2393,7 +2393,7 @@  static int chardev_init_func(QemuOpts *opts, void *opaque)
 
     qemu_chr_new_from_opts(opts, NULL, &local_err);
     if (error_is_set(&local_err)) {
-        fprintf(stderr, "%s\n", error_get_pretty(local_err));
+        error_report("%s", error_get_pretty(local_err));
         error_free(local_err);
         return -1;
     }
@@ -4375,8 +4375,8 @@  int main(int argc, char **argv, char **envp)
         vnc_display_init(ds);
         vnc_display_open(ds, vnc_display, &local_err);
         if (local_err != NULL) {
-            fprintf(stderr, "Failed to start VNC server on `%s': %s\n",
-                    vnc_display, error_get_pretty(local_err));
+            error_report("Failed to start VNC server on `%s': %s",
+                         vnc_display, error_get_pretty(local_err));
             error_free(local_err);
             exit(1);
         }
@@ -4419,7 +4419,8 @@  int main(int argc, char **argv, char **envp)
         Error *local_err = NULL;
         qemu_start_incoming_migration(incoming, &local_err);
         if (local_err) {
-            fprintf(stderr, "-incoming %s: %s\n", incoming, error_get_pretty(local_err));
+            error_report("-incoming %s: %s", incoming,
+                         error_get_pretty(local_err));
             error_free(local_err);
             exit(1);
         }