qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Thomas Huth" <thuth@redhat.com>,
	"Daniel P . Berrangé" <berrange@redhat.com>,
	"Juan Quintela" <quintela@redhat.com>,
	"Peter Xu" <peterx@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Cornelia Huck" <cornelia.huck@de.ibm.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PATCH 01/16] error: Use error_fatal to simplify obvious fatal errors (again)
Date: Tue, 20 Jul 2021 14:53:53 +0200	[thread overview]
Message-ID: <20210720125408.387910-2-armbru@redhat.com> (raw)
In-Reply-To: <20210720125408.387910-1-armbru@redhat.com>

We did this with scripts/coccinelle/use-error_fatal.cocci before, in
commit 50beeb68094 and 007b06578ab.  This commit cleans up rarer
variations that don't seem worth matching with Coccinelle.

Cc: Thomas Huth <thuth@redhat.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Juan Quintela <quintela@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/s390x/ipl.c        |  6 +-----
 migration/migration.c |  7 +------
 qemu-img.c            |  6 +-----
 qemu-io.c             |  6 +-----
 qemu-nbd.c            |  5 +----
 scsi/qemu-pr-helper.c | 11 +++--------
 softmmu/vl.c          |  7 +------
 target/i386/sev.c     |  8 +-------
 ui/console.c          |  6 ++----
 ui/spice-core.c       |  7 +------
 10 files changed, 13 insertions(+), 56 deletions(-)

diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index 8c863cf386..1821c6faee 100644
--- a/hw/s390x/ipl.c
+++ b/hw/s390x/ipl.c
@@ -711,7 +711,6 @@ int s390_ipl_pv_unpack(void)
 void s390_ipl_prepare_cpu(S390CPU *cpu)
 {
     S390IPLState *ipl = get_ipl_device();
-    Error *err = NULL;
 
     cpu->env.psw.addr = ipl->start_addr;
     cpu->env.psw.mask = IPL_PSW_MASK;
@@ -723,10 +722,7 @@ void s390_ipl_prepare_cpu(S390CPU *cpu)
         }
     }
     if (ipl->netboot) {
-        if (load_netboot_image(&err) < 0) {
-            error_report_err(err);
-            exit(1);
-        }
+        load_netboot_image(&error_fatal);
         ipl->qipl.netboot_start_addr = cpu_to_be64(ipl->start_addr);
     }
     s390_ipl_set_boot_menu(ipl);
diff --git a/migration/migration.c b/migration/migration.c
index 2d306582eb..231dc24414 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -187,8 +187,6 @@ static gint page_request_addr_cmp(gconstpointer ap, gconstpointer bp)
 
 void migration_object_init(void)
 {
-    Error *err = NULL;
-
     /* This can only be called once. */
     assert(!current_migration);
     current_migration = MIGRATION_OBJ(object_new(TYPE_MIGRATION));
@@ -209,10 +207,7 @@ void migration_object_init(void)
     qemu_mutex_init(&current_incoming->page_request_mutex);
     current_incoming->page_requested = g_tree_new(page_request_addr_cmp);
 
-    if (!migration_object_check(current_migration, &err)) {
-        error_report_err(err);
-        exit(1);
-    }
+    migration_object_check(current_migration, &error_fatal);
 
     blk_mig_init();
     ram_mig_init();
diff --git a/qemu-img.c b/qemu-img.c
index 797742a443..e0b438182e 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -5310,7 +5310,6 @@ int main(int argc, char **argv)
 {
     const img_cmd_t *cmd;
     const char *cmdname;
-    Error *local_error = NULL;
     int c;
     static const struct option long_options[] = {
         {"help", no_argument, 0, 'h'},
@@ -5328,10 +5327,7 @@ int main(int argc, char **argv)
     module_call_init(MODULE_INIT_TRACE);
     qemu_init_exec_dir(argv[0]);
 
-    if (qemu_init_main_loop(&local_error)) {
-        error_report_err(local_error);
-        exit(EXIT_FAILURE);
-    }
+    qemu_init_main_loop(&error_fatal);
 
     qcrypto_init(&error_fatal);
 
diff --git a/qemu-io.c b/qemu-io.c
index 57f07501df..3924639b92 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -529,7 +529,6 @@ int main(int argc, char **argv)
     int flags = BDRV_O_UNMAP;
     int ret;
     bool writethrough = true;
-    Error *local_error = NULL;
     QDict *opts = NULL;
     const char *format = NULL;
     bool force_share = false;
@@ -629,10 +628,7 @@ int main(int argc, char **argv)
         exit(1);
     }
 
-    if (qemu_init_main_loop(&local_error)) {
-        error_report_err(local_error);
-        exit(1);
-    }
+    qemu_init_main_loop(&error_fatal);
 
     if (!trace_init_backends()) {
         exit(1);
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 26ffbf15af..65ebec598f 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -963,10 +963,7 @@ int main(int argc, char **argv)
         }
     }
 
-    if (qemu_init_main_loop(&local_err)) {
-        error_report_err(local_err);
-        exit(EXIT_FAILURE);
-    }
+    qemu_init_main_loop(&error_fatal);
     bdrv_init();
     atexit(qemu_nbd_shutdown);
 
diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c
index 7b9389b47b..f281daeced 100644
--- a/scsi/qemu-pr-helper.c
+++ b/scsi/qemu-pr-helper.c
@@ -1044,10 +1044,7 @@ int main(int argc, char **argv)
         }
     }
 
-    if (qemu_init_main_loop(&local_err)) {
-        error_report_err(local_err);
-        exit(EXIT_FAILURE);
-    }
+    qemu_init_main_loop(&error_fatal);
 
     server_watch = qio_channel_add_watch(QIO_CHANNEL(server_ioc),
                                          G_IO_IN,
@@ -1061,10 +1058,8 @@ int main(int argc, char **argv)
         }
     }
 
-    if ((daemonize || pidfile_specified) &&
-        !qemu_write_pidfile(pidfile, &local_err)) {
-        error_report_err(local_err);
-        exit(EXIT_FAILURE);
+    if (daemonize || pidfile_specified) {
+        qemu_write_pidfile(pidfile, &error_fatal);
     }
 
 #ifdef CONFIG_LIBCAP_NG
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 4df1496101..0d2db1abc3 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2673,12 +2673,7 @@ void qmp_x_exit_preconfig(Error **errp)
     qemu_machine_creation_done();
 
     if (loadvm) {
-        Error *local_err = NULL;
-        if (!load_snapshot(loadvm, NULL, false, NULL, &local_err)) {
-            error_report_err(local_err);
-            autostart = 0;
-            exit(1);
-        }
+        load_snapshot(loadvm, NULL, false, NULL, &error_fatal);
     }
     if (replay_mode != REPLAY_MODE_NONE) {
         replay_vmstate_init();
diff --git a/target/i386/sev.c b/target/i386/sev.c
index 83df8c09f6..0b2c8f594a 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -737,7 +737,6 @@ static void
 sev_launch_finish(SevGuestState *sev)
 {
     int ret, error;
-    Error *local_err = NULL;
 
     trace_kvm_sev_launch_finish();
     ret = sev_ioctl(sev->sev_fd, KVM_SEV_LAUNCH_FINISH, 0, &error);
@@ -752,12 +751,7 @@ sev_launch_finish(SevGuestState *sev)
     /* add migration blocker */
     error_setg(&sev_mig_blocker,
                "SEV: Migration is not implemented");
-    ret = migrate_add_blocker(sev_mig_blocker, &local_err);
-    if (local_err) {
-        error_report_err(local_err);
-        error_free(sev_mig_blocker);
-        exit(1);
-    }
+    migrate_add_blocker(sev_mig_blocker, &error_fatal);
 }
 
 static void
diff --git a/ui/console.c b/ui/console.c
index 1103b65314..5d2e6178ff 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1508,7 +1508,6 @@ void register_displaychangelistener(DisplayChangeListener *dcl)
         "This VM has no graphic display device.";
     static DisplaySurface *dummy;
     QemuConsole *con;
-    Error *err = NULL;
 
     assert(!dcl->ds);
 
@@ -1523,9 +1522,8 @@ void register_displaychangelistener(DisplayChangeListener *dcl)
         dcl->con->gl = dcl;
     }
 
-    if (dcl->con && !dpy_compatible_with(dcl->con, dcl, &err)) {
-        error_report_err(err);
-        exit(1);
+    if (dcl->con) {
+        dpy_compatible_with(dcl->con, dcl, &error_fatal);
     }
 
     trace_displaychangelistener_register(dcl, dcl->ops->dpy_name);
diff --git a/ui/spice-core.c b/ui/spice-core.c
index 86d43783ac..bbd7ad070b 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -671,18 +671,13 @@ static void qemu_spice_init(void)
     }
     passwordSecret = qemu_opt_get(opts, "password-secret");
     if (passwordSecret) {
-        Error *local_err = NULL;
         if (qemu_opt_get(opts, "password")) {
             error_report("'password' option is mutually exclusive with "
                          "'password-secret'");
             exit(1);
         }
         password = qcrypto_secret_lookup_as_utf8(passwordSecret,
-                                                 &local_err);
-        if (!password) {
-            error_report_err(local_err);
-            exit(1);
-        }
+                                                 &error_fatal);
     } else {
         str = qemu_opt_get(opts, "password");
         if (str) {
-- 
2.31.1



  reply	other threads:[~2021-07-20 13:06 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-20 12:53 [PATCH 00/16] Various error handling fixes and cleanups Markus Armbruster
2021-07-20 12:53 ` Markus Armbruster [this message]
2021-07-20 13:42   ` [PATCH 01/16] error: Use error_fatal to simplify obvious fatal errors (again) Eric Blake
2021-07-20 17:55   ` Peter Xu
2021-08-02 19:02   ` Philippe Mathieu-Daudé
2021-08-03  5:44     ` Markus Armbruster
2021-07-20 12:53 ` [PATCH 02/16] spapr: Plug memory leak when we can't add a migration blocker Markus Armbruster
2021-07-20 13:12   ` David Gibson
2021-08-02 18:54   ` Philippe Mathieu-Daudé
2021-07-20 12:53 ` [PATCH 03/16] spapr: Explain purpose of ->fwnmi_migration_blocker more clearly Markus Armbruster
2021-07-21  6:08   ` David Gibson
2021-07-20 12:53 ` [PATCH 04/16] multi-process: Fix pci_proxy_dev_realize() error handling Markus Armbruster
2021-07-20 18:02   ` Philippe Mathieu-Daudé
2021-07-20 20:02   ` Jag Raman
2021-07-20 12:53 ` [PATCH 05/16] vhost-scsi: Plug memory leak on migrate_add_blocker() failure Markus Armbruster
2021-07-20 12:53 ` [PATCH 06/16] i386: Never free migration blocker objects instead of sometimes Markus Armbruster
2021-07-20 12:53 ` [PATCH 07/16] vfio: Avoid error_propagate() after migrate_add_blocker() Markus Armbruster
2021-07-20 18:03   ` Philippe Mathieu-Daudé
2021-07-21  6:24   ` Kirti Wankhede
2021-07-21  9:26   ` Paolo Bonzini
2021-07-21 14:12     ` Markus Armbruster
2021-07-20 12:54 ` [PATCH 08/16] whpx nvmm: Drop useless migrate_del_blocker() Markus Armbruster
2021-07-22  8:04   ` Reinoud Zandijk
2021-07-20 12:54 ` [PATCH 09/16] migration: Unify failure check for migrate_add_blocker() Markus Armbruster
2021-07-20 18:05   ` Philippe Mathieu-Daudé
2021-07-20 12:54 ` [PATCH 10/16] migration: Handle migration_incoming_setup() errors consistently Markus Armbruster
2021-07-20 18:53   ` Eric Blake
2021-07-21 14:12     ` Markus Armbruster
2021-07-20 21:55   ` Pankaj Gupta
2021-08-02 17:53   ` Dr. David Alan Gilbert
2021-08-03  5:58     ` Markus Armbruster
2021-08-31 12:47       ` Markus Armbruster
2021-07-20 12:54 ` [PATCH 11/16] microvm: Drop dead error handling in microvm_machine_state_init() Markus Armbruster
2021-07-20 13:36   ` Sergio Lopez
2021-07-20 18:06   ` Philippe Mathieu-Daudé
2021-07-20 21:59   ` Pankaj Gupta
2021-07-20 12:54 ` [PATCH 12/16] vhost: Clean up how VhostOpts method vhost_get_config() fails Markus Armbruster
2021-08-02 18:56   ` Philippe Mathieu-Daudé
2021-08-02 18:58   ` Philippe Mathieu-Daudé
2021-08-03  5:48     ` Markus Armbruster
2021-07-20 12:54 ` [PATCH 13/16] vhost: Clean up how VhostOpts method vhost_backend_init() fails Markus Armbruster
2021-08-02 18:59   ` Philippe Mathieu-Daudé
2021-07-20 12:54 ` [PATCH 14/16] Remove superfluous ERRP_GUARD() Markus Armbruster
2021-08-02 19:00   ` Philippe Mathieu-Daudé
2021-07-20 12:54 ` [PATCH 15/16] vl: Clean up -smp error handling Markus Armbruster
2021-07-20 18:07   ` Philippe Mathieu-Daudé
2021-07-20 12:54 ` [PATCH 16/16] vl: Don't continue after -smp help Markus Armbruster
2021-07-20 18:08   ` [PATCH-for-6.1? " Philippe Mathieu-Daudé
2021-07-20 21:57   ` [PATCH " Pankaj Gupta
2021-07-24  0:30 ` [PATCH 00/16] Various error handling fixes and cleanups Michael S. Tsirkin
2021-07-29 13:23 ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210720125408.387910-2-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=kraxel@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).