[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 17/38] seccomp: Clean up error reporting in parse
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PATCH v4 17/38] seccomp: Clean up error reporting in parse_sandbox() |
Date: |
Wed, 17 Oct 2018 10:26:41 +0200 |
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 <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Acked-by: Eduardo Otubo <address@hidden>
---
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 ff50199e64..643121e5d4 100644
--- a/vl.c
+++ b/vl.c
@@ -3972,8 +3972,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.1
- [Qemu-devel] [PATCH v4 29/38] tpm: Clean up error reporting in tpm_init_tpmdev(), (continued)
- [Qemu-devel] [PATCH v4 29/38] tpm: Clean up error reporting in tpm_init_tpmdev(), Markus Armbruster, 2018/10/17
- [Qemu-devel] [PATCH v4 32/38] vl: Assert drive_new() does not fail in default_drive(), Markus Armbruster, 2018/10/17
- [Qemu-devel] [PATCH v4 34/38] vl: Fix exit status for -drive format=help, Markus Armbruster, 2018/10/17
- [Qemu-devel] [PATCH v4 35/38] vl: Simplify call of parse_name(), Markus Armbruster, 2018/10/17
- [Qemu-devel] [PATCH v4 07/38] char: Use error_printf() to print help and such, Markus Armbruster, 2018/10/17
- [Qemu-devel] [PATCH v4 31/38] fsdev: Clean up error reporting in qemu_fsdev_add(), Markus Armbruster, 2018/10/17
- [Qemu-devel] [PATCH v4 36/38] block: Clean up bdrv_img_create()'s error reporting, Markus Armbruster, 2018/10/17
- [Qemu-devel] [PATCH v4 09/38] pc: Fix machine property nvdimm-persistence error handling, Markus Armbruster, 2018/10/17
- [Qemu-devel] [PATCH v4 10/38] ioapic: Fix error handling in realize(), Markus Armbruster, 2018/10/17
- [Qemu-devel] [PATCH v4 17/38] seccomp: Clean up error reporting in parse_sandbox(),
Markus Armbruster <=
- [Qemu-devel] [PATCH v4 05/38] vfio: Use warn_report() & friends to report warnings, Markus Armbruster, 2018/10/17
- [Qemu-devel] [PATCH v4 25/38] ui/keymaps: Fix handling of erroneous include files, Markus Armbruster, 2018/10/17
- [Qemu-devel] [PATCH v4 26/38] ui: Convert vnc_display_init(), init_keyboard_layout() to Error, Markus Armbruster, 2018/10/17
- [Qemu-devel] [PATCH v4 04/38] cpus hw target: Use warn_report() & friends to report warnings, Markus Armbruster, 2018/10/17
- [Qemu-devel] [PATCH v4 37/38] raw: Convert a warning to warn_report(), Markus Armbruster, 2018/10/17