Blame SOURCES/kvm-qom-Clean-up-error-reporting-in-user_creatable_add_o.patch

7711c0
From 2070eac10c75c262e8f803b3654f512c55c261c1 Mon Sep 17 00:00:00 2001
7711c0
From: John Snow <jsnow@redhat.com>
7711c0
Date: Wed, 27 Mar 2019 17:22:34 +0100
7711c0
Subject: [PATCH 095/163] qom: Clean up error reporting in
7711c0
 user_creatable_add_opts_foreach()
7711c0
MIME-Version: 1.0
7711c0
Content-Type: text/plain; charset=UTF-8
7711c0
Content-Transfer-Encoding: 8bit
7711c0
7711c0
RH-Author: John Snow <jsnow@redhat.com>
7711c0
Message-id: <20190327172308.31077-22-jsnow@redhat.com>
7711c0
Patchwork-id: 85216
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 21/55] qom: Clean up error reporting in user_creatable_add_opts_foreach()
7711c0
Bugzilla: 1691009
7711c0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
7711c0
RH-Acked-by: Max Reitz <mreitz@redhat.com>
7711c0
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
7711c0
From: Markus Armbruster <armbru@redhat.com>
7711c0
7711c0
Calling error_report() in a function that takes an Error ** argument
7711c0
is suspicious.  user_creatable_add_opts_foreach() does that, and then
7711c0
fails without setting an error.  Its caller main(), via
7711c0
qemu_opts_foreach(), is fine with it, but clean it up anyway.
7711c0
7711c0
Cc: Daniel P. Berrangé <berrange@redhat.com>
7711c0
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7711c0
Reviewed-by: Eric Blake <eblake@redhat.com>
7711c0
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
7711c0
Message-Id: <20181017082702.5581-20-armbru@redhat.com>
7711c0
(cherry picked from commit 7e1e0c11127bde81cff260fc6859690435c509d6)
7711c0
Signed-off-by: John Snow <jsnow@redhat.com>
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 qemu-io.c               |  8 +++-----
7711c0
 qemu-nbd.c              |  8 +++-----
7711c0
 qom/object_interfaces.c |  4 +---
7711c0
 vl.c                    | 16 ++++++----------
7711c0
 4 files changed, 13 insertions(+), 23 deletions(-)
7711c0
7711c0
diff --git a/qemu-io.c b/qemu-io.c
7711c0
index 13829f5..6df7731 100644
7711c0
--- a/qemu-io.c
7711c0
+++ b/qemu-io.c
7711c0
@@ -620,11 +620,9 @@ int main(int argc, char **argv)
7711c0
         exit(1);
7711c0
     }
7711c0
 
7711c0
-    if (qemu_opts_foreach(&qemu_object_opts,
7711c0
-                          user_creatable_add_opts_foreach,
7711c0
-                          NULL, NULL)) {
7711c0
-        exit(1);
7711c0
-    }
7711c0
+    qemu_opts_foreach(&qemu_object_opts,
7711c0
+                      user_creatable_add_opts_foreach,
7711c0
+                      NULL, &error_fatal);
7711c0
 
7711c0
     if (!trace_init_backends()) {
7711c0
         exit(1);
7711c0
diff --git a/qemu-nbd.c b/qemu-nbd.c
7711c0
index 0c92f62..51b55f2 100644
7711c0
--- a/qemu-nbd.c
7711c0
+++ b/qemu-nbd.c
7711c0
@@ -781,11 +781,9 @@ int main(int argc, char **argv)
7711c0
         exit(EXIT_FAILURE);
7711c0
     }
7711c0
 
7711c0
-    if (qemu_opts_foreach(&qemu_object_opts,
7711c0
-                          user_creatable_add_opts_foreach,
7711c0
-                          NULL, NULL)) {
7711c0
-        exit(EXIT_FAILURE);
7711c0
-    }
7711c0
+    qemu_opts_foreach(&qemu_object_opts,
7711c0
+                      user_creatable_add_opts_foreach,
7711c0
+                      NULL, &error_fatal);
7711c0
 
7711c0
     if (!trace_init_backends()) {
7711c0
         exit(1);
7711c0
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
7711c0
index 980ffc2..7491c69 100644
7711c0
--- a/qom/object_interfaces.c
7711c0
+++ b/qom/object_interfaces.c
7711c0
@@ -149,7 +149,6 @@ int user_creatable_add_opts_foreach(void *opaque, QemuOpts *opts, Error **errp)
7711c0
 {
7711c0
     bool (*type_predicate)(const char *) = opaque;
7711c0
     Object *obj = NULL;
7711c0
-    Error *err = NULL;
7711c0
     const char *type;
7711c0
 
7711c0
     type = qemu_opt_get(opts, "qom-type");
7711c0
@@ -158,9 +157,8 @@ int user_creatable_add_opts_foreach(void *opaque, QemuOpts *opts, Error **errp)
7711c0
         return 0;
7711c0
     }
7711c0
 
7711c0
-    obj = user_creatable_add_opts(opts, &err;;
7711c0
+    obj = user_creatable_add_opts(opts, errp);
7711c0
     if (!obj) {
7711c0
-        error_report_err(err);
7711c0
         return -1;
7711c0
     }
7711c0
     object_unref(obj);
7711c0
diff --git a/vl.c b/vl.c
7711c0
index dfe261d..92a98ab 100644
7711c0
--- a/vl.c
7711c0
+++ b/vl.c
7711c0
@@ -4407,11 +4407,9 @@ int main(int argc, char **argv, char **envp)
7711c0
     page_size_init();
7711c0
     socket_init();
7711c0
 
7711c0
-    if (qemu_opts_foreach(qemu_find_opts("object"),
7711c0
-                          user_creatable_add_opts_foreach,
7711c0
-                          object_create_initial, NULL)) {
7711c0
-        exit(1);
7711c0
-    }
7711c0
+    qemu_opts_foreach(qemu_find_opts("object"),
7711c0
+                      user_creatable_add_opts_foreach,
7711c0
+                      object_create_initial, &error_fatal);
7711c0
 
7711c0
     if (qemu_opts_foreach(qemu_find_opts("chardev"),
7711c0
                           chardev_init_func, NULL, NULL)) {
7711c0
@@ -4537,11 +4535,9 @@ int main(int argc, char **argv, char **envp)
7711c0
         exit(1);
7711c0
     }
7711c0
 
7711c0
-    if (qemu_opts_foreach(qemu_find_opts("object"),
7711c0
-                          user_creatable_add_opts_foreach,
7711c0
-                          object_create_delayed, NULL)) {
7711c0
-        exit(1);
7711c0
-    }
7711c0
+    qemu_opts_foreach(qemu_find_opts("object"),
7711c0
+                      user_creatable_add_opts_foreach,
7711c0
+                      object_create_delayed, &error_fatal);
7711c0
 
7711c0
     if (tpm_init() < 0) {
7711c0
         exit(1);
7711c0
-- 
7711c0
1.8.3.1
7711c0