summaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorEduardo Otubo <otubo@linux.vnet.ibm.com>2012-08-14 18:44:08 -0300
committerAnthony Liguori <aliguori@us.ibm.com>2012-08-16 13:41:16 -0500
commit7d76ad4fa4405bb20c35fd24c3c848d2bc48f694 (patch)
tree647c18a62aa16508fcb15b2a61bd91de3bee3c36 /vl.c
parent452dfbef600837c0e430564ea9e35138ef48f24c (diff)
downloadqemu-7d76ad4fa4405bb20c35fd24c3c848d2bc48f694.tar.gz
qemu-7d76ad4fa4405bb20c35fd24c3c848d2bc48f694.tar.bz2
qemu-7d76ad4fa4405bb20c35fd24c3c848d2bc48f694.zip
Command line support for seccomp with -sandbox (v8)
Signed-off-by: Eduardo Otubo <otubo@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> --- v7 -> v8 - Parse options correctly (aliguori)
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/vl.c b/vl.c
index 1010248dcd..124d30d3e7 100644
--- a/vl.c
+++ b/vl.c
@@ -770,6 +770,26 @@ static int bt_parse(const char *opt)
return 1;
}
+static int parse_sandbox(QemuOpts *opts, void *opaque)
+{
+ /* FIXME: change this to true for 1.3 */
+ if (qemu_opt_get_bool(opts, "enable", false)) {
+#ifdef CONFIG_SECCOMP
+ if (seccomp_start() < 0) {
+ qerror_report(ERROR_CLASS_GENERIC_ERROR,
+ "failed to install seccomp syscall filter in the kernel");
+ return -1;
+ }
+#else
+ qerror_report(ERROR_CLASS_GENERIC_ERROR,
+ "sandboxing request but seccomp is not compiled into this build");
+ return -1;
+#endif
+ }
+
+ return 0;
+}
+
/***********************************************************/
/* QEMU Block devices */
@@ -2349,14 +2369,6 @@ int main(int argc, char **argv, char **envp)
const char *trace_events = NULL;
const char *trace_file = NULL;
-#ifdef CONFIG_SECCOMP
- if (seccomp_start() < 0) {
- fprintf(stderr,
- "seccomp: failed to install syscall filter in the kernel\n");
- exit(1);
- }
-#endif
-
atexit(qemu_run_exit_notifiers);
error_set_progname(argv[0]);
@@ -3260,6 +3272,12 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_qtest_log:
qtest_log = optarg;
break;
+ case QEMU_OPTION_sandbox:
+ opts = qemu_opts_parse(qemu_find_opts("sandbox"), optarg, 1);
+ if (!opts) {
+ exit(0);
+ }
+ break;
default:
os_parse_cmd_args(popt->index, optarg);
}
@@ -3267,6 +3285,10 @@ int main(int argc, char **argv, char **envp)
}
loc_set_none();
+ if (qemu_opts_foreach(qemu_find_opts("sandbox"), parse_sandbox, NULL, 0)) {
+ exit(1);
+ }
+
if (machine == NULL) {
fprintf(stderr, "No machine found.\n");
exit(1);