From bc563c4bf589ac463ac2e8639bcab28bec4744ef Mon Sep 17 00:00:00 2001
Message-Id: <bc563c4bf589ac463ac2e8639bcab28bec4744ef.1376498713.git.minovotn@redhat.com>
In-Reply-To: <d671b9e07fb7eebffdff501100443924d26a4eab.1376498713.git.minovotn@redhat.com>
References: <d671b9e07fb7eebffdff501100443924d26a4eab.1376498713.git.minovotn@redhat.com>
From: Laszlo Ersek <lersek@redhat.com>
Date: Wed, 14 Aug 2013 09:46:22 +0200
Subject: [PATCH 2/2] Convert stderr message calling error_get_pretty() to
 error_report()

RH-Author: Laszlo Ersek <lersek@redhat.com>
Message-id: <1376473582-31743-3-git-send-email-lersek@redhat.com>
Patchwork-id: 53362
O-Subject: [RHEL-6.5 qemu-kvm PATCH 2/2] Convert stderr message calling error_get_pretty() to error_report()
Bugzilla: 906931
RH-Acked-by: Michal Novotny <minovotn@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Luiz Capitulino <lcapitulino@redhat.com>

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.

RHEL-6 notes:
- This is a manual reimplementation of
  <http://thread.gmane.org/gmane.comp.emulators.qemu/226570>. The upstream
  patch didn't make it into qemu-1.6, but Hitachi would like us to
  backport it anyway. Luiz suggested I could go ahead without an upstream
  commit hash.
- In order to reflect the intent of the upstream patch, I grepped the
  RHEL-6 tree for "error_get_pretty", and converted those call sites that
  used to pass the error string to fprintf(stderr, ...). The resultant
  patch is a subset of the upstream patch.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 qemu-char.c |    2 +-
 vl.c        |    8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 qemu-char.c | 2 +-
 vl.c        | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/qemu-char.c b/qemu-char.c
index 5926615..86f838a 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2989,7 +2989,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/vl.c b/vl.c
index e90e9c8..bcd73f0 100644
--- a/vl.c
+++ b/vl.c
@@ -4793,7 +4793,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;
     }
@@ -6499,8 +6499,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);
         }
@@ -6558,7 +6558,7 @@ int main(int argc, char **argv, char **envp)
         int ret = qemu_start_incoming_migration(incoming, &errp);
         if (ret < 0) {
             if (error_is_set(&errp)) {
-                fprintf(stderr, "Migrate: %s\n", error_get_pretty(errp));
+                error_report("Migrate: %s", error_get_pretty(errp));
                 error_free(errp);
             }
             fprintf(stderr, "Migration failed. Exit code %s(%d), exiting.\n",
-- 
1.7.11.7

