qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: Eduardo Otubo <otubo@redhat.com>
Subject: [Qemu-devel] [PULL 19/40] seccomp: Clean up error reporting in parse_sandbox()
Date: Mon, 22 Oct 2018 14:33:52 +0200	[thread overview]
Message-ID: <20181022123413.28044-20-armbru@redhat.com> (raw)
In-Reply-To: <20181022123413.28044-1-armbru@redhat.com>

Calling error_report() in a function that takes an Error ** argument
is suspicious.  parse_sandbox() does that, and then fails without
setting an error.  Its caller main(), via qemu_opts_foreach(), is fine
with it, but clean it up anyway.

Cc: Eduardo Otubo <otubo@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Eduardo Otubo <otubo@redhat.com>
Message-Id: <20181017082702.5581-18-armbru@redhat.com>
---
 qemu-seccomp.c | 18 +++++++++---------
 vl.c           |  4 ++--
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/qemu-seccomp.c b/qemu-seccomp.c
index 1baa5c69ed..5c73e6ad05 100644
--- a/qemu-seccomp.c
+++ b/qemu-seccomp.c
@@ -12,11 +12,12 @@
  * Contributions after 2012-01-13 are licensed under the terms of the
  * GNU GPL, version 2 or (at your option) any later version.
  */
+
 #include "qemu/osdep.h"
+#include "qapi/error.h"
 #include "qemu/config-file.h"
 #include "qemu/option.h"
 #include "qemu/module.h"
-#include "qemu/error-report.h"
 #include <sys/prctl.h>
 #include <seccomp.h>
 #include "sysemu/seccomp.h"
@@ -190,7 +191,7 @@ int parse_sandbox(void *opaque, QemuOpts *opts, Error **errp)
                  * to provide a little bit of consistency for
                  * the command line */
             } else {
-                error_report("invalid argument for obsolete");
+                error_setg(errp, "invalid argument for obsolete");
                 return -1;
             }
         }
@@ -205,14 +206,13 @@ int parse_sandbox(void *opaque, QemuOpts *opts, Error **errp)
                 /* calling prctl directly because we're
                  * not sure if host has CAP_SYS_ADMIN set*/
                 if (prctl(PR_SET_NO_NEW_PRIVS, 1)) {
-                    error_report("failed to set no_new_privs "
-                                 "aborting");
+                    error_setg(errp, "failed to set no_new_privs aborting");
                     return -1;
                 }
             } else if (g_str_equal(value, "allow")) {
                 /* default value */
             } else {
-                error_report("invalid argument for elevateprivileges");
+                error_setg(errp, "invalid argument for elevateprivileges");
                 return -1;
             }
         }
@@ -224,7 +224,7 @@ int parse_sandbox(void *opaque, QemuOpts *opts, Error **errp)
             } else if (g_str_equal(value, "allow")) {
                 /* default value */
             } else {
-                error_report("invalid argument for spawn");
+                error_setg(errp, "invalid argument for spawn");
                 return -1;
             }
         }
@@ -236,14 +236,14 @@ int parse_sandbox(void *opaque, QemuOpts *opts, Error **errp)
             } else if (g_str_equal(value, "allow")) {
                 /* default value */
             } else {
-                error_report("invalid argument for resourcecontrol");
+                error_setg(errp, "invalid argument for resourcecontrol");
                 return -1;
             }
         }
 
         if (seccomp_start(seccomp_opts) < 0) {
-            error_report("failed to install seccomp syscall filter "
-                         "in the kernel");
+            error_setg(errp, "failed to install seccomp syscall filter "
+                       "in the kernel");
             return -1;
         }
     }
diff --git a/vl.c b/vl.c
index db83cfe2e9..d7b604c97e 100644
--- a/vl.c
+++ b/vl.c
@@ -3973,8 +3973,8 @@ int main(int argc, char **argv, char **envp)
 
 #ifdef CONFIG_SECCOMP
     olist = qemu_find_opts_err("sandbox", NULL);
-    if (olist && qemu_opts_foreach(olist, parse_sandbox, NULL, NULL)) {
-        exit(1);
+    if (olist) {
+        qemu_opts_foreach(olist, parse_sandbox, NULL, &error_fatal);
     }
 #endif
 
-- 
2.17.2

  parent reply	other threads:[~2018-10-22 12:34 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-22 12:33 [Qemu-devel] [PULL 00/40] Error reporting patches for 2018-10-22 Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 01/40] scripts: Remove check-qerror.sh Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 02/40] vl: Print error when using incorrect backend for debugcon Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 03/40] error: Fix use of error_prepend() with &error_fatal, &error_abort Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 04/40] Use error_fatal to simplify obvious fatal errors (again) Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 05/40] block: Use warn_report() & friends to report warnings Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 06/40] cpus hw target: " Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 07/40] vfio: " Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 08/40] vfio: Clean up error reporting after previous commit Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 09/40] char: Use error_printf() to print help and such Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 10/40] 9pfs: Fix CLI parsing crash on error Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 11/40] pc: Fix machine property nvdimm-persistence error handling Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 12/40] ioapic: Fix error handling in realize() Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 13/40] smbios: Clean up error handling in smbios_add() Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 14/40] migration: Fix !replay_can_snapshot() error handling Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 15/40] l2tpv3: Improve -netdev/netdev_add/-net/... error reporting Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 16/40] net/socket: Fix invalid socket type error handling Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 17/40] numa: Fix QMP command set-numa-node " Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 18/40] xen/pt: Fix incomplete conversion to realize() Markus Armbruster
2018-10-22 12:33 ` Markus Armbruster [this message]
2018-10-22 12:33 ` [Qemu-devel] [PULL 20/40] vl: Clean up error reporting in parse_add_fd() Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 21/40] qom: Clean up error reporting in user_creatable_add_opts_foreach() Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 22/40] vl: Clean up error reporting in chardev_init_func() Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 23/40] vl: Clean up error reporting in machine_set_property() Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 24/40] vl: Clean up error reporting in mon_init_func() Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 25/40] vl: Clean up error reporting in parse_fw_cfg() Markus Armbruster
2018-10-22 12:33 ` [Qemu-devel] [PULL 26/40] vl: Clean up error reporting in device_init_func() Markus Armbruster
2018-10-22 12:34 ` [Qemu-devel] [PULL 27/40] ui/keymaps: Fix handling of erroneous include files Markus Armbruster
2018-10-22 12:34 ` [Qemu-devel] [PULL 28/40] ui: Convert vnc_display_init(), init_keyboard_layout() to Error Markus Armbruster
2018-10-22 12:34 ` [Qemu-devel] [PULL 29/40] vnc: Clean up error reporting in vnc_init_func() Markus Armbruster
2018-10-22 12:34 ` [Qemu-devel] [PULL 30/40] numa: Clean up error reporting in parse_numa() Markus Armbruster
2018-10-22 12:34 ` [Qemu-devel] [PULL 31/40] tpm: Clean up error reporting in tpm_init_tpmdev() Markus Armbruster
2018-10-22 12:34 ` [Qemu-devel] [PULL 32/40] spice: Clean up error reporting in add_channel() Markus Armbruster
2018-10-22 12:34 ` [Qemu-devel] [PULL 33/40] fsdev: Clean up error reporting in qemu_fsdev_add() Markus Armbruster
2018-10-22 12:34 ` [Qemu-devel] [PULL 34/40] vl: Assert drive_new() does not fail in default_drive() Markus Armbruster
2018-10-22 12:34 ` [Qemu-devel] [PULL 35/40] blockdev: Convert drive_new() to Error Markus Armbruster
2018-10-22 12:34 ` [Qemu-devel] [PULL 36/40] vl: Fix exit status for -drive format=help Markus Armbruster
2018-10-22 12:34 ` [Qemu-devel] [PULL 37/40] vl: Simplify call of parse_name() Markus Armbruster
2018-10-22 12:34 ` [Qemu-devel] [PULL 38/40] block: Clean up bdrv_img_create()'s error reporting Markus Armbruster
2018-10-22 12:34 ` [Qemu-devel] [PULL 39/40] vpc: Fail open on bad header checksum Markus Armbruster
2018-10-22 12:34 ` [Qemu-devel] [PULL 40/40] error: Drop bogus "use error_setg() instead" admonitions Markus Armbruster
2018-10-23 18:58 ` [Qemu-devel] [PULL 00/40] Error reporting patches for 2018-10-22 Peter Maydell

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=20181022123413.28044-20-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=otubo@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).