diff options
author | Thomas Huth <thuth@redhat.com> | 2018-05-04 19:01:07 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2018-05-09 00:13:39 +0200 |
commit | 1217d6ca2bf28c0febe1bd7d5b3fa912bbf6af2a (patch) | |
tree | 4f854522c6ac02bb10ebdb9ebb13c396a8b857ac | |
parent | 281b95231d79a7a7ecc93a51ebb8e68b1ce7f1e5 (diff) | |
download | qemu-1217d6ca2bf28c0febe1bd7d5b3fa912bbf6af2a.zip qemu-1217d6ca2bf28c0febe1bd7d5b3fa912bbf6af2a.tar.gz qemu-1217d6ca2bf28c0febe1bd7d5b3fa912bbf6af2a.tar.bz2 |
qemu-options: Bail out on unsupported options instead of silently ignoring them
The dangling remainder of the -tdf option revealed a deficiency in our
option parsing: Options that have been declared, but are not supported
in the switch-case statement in vl.c and not handled in the OS-specifc
os_parse_cmd_args() functions are currently silently ignored. We should
rather tell the users that they specified something that we can not
handle, so let's print an error message and exit instead.
Reported-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1525453270-23074-3-git-send-email-thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | include/qemu-common.h | 2 | ||||
-rw-r--r-- | os-posix.c | 6 | ||||
-rw-r--r-- | os-win32.c | 4 | ||||
-rw-r--r-- | vl.c | 5 |
4 files changed, 12 insertions, 5 deletions
diff --git a/include/qemu-common.h b/include/qemu-common.h index 8a4f63c..85f4749 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -137,7 +137,7 @@ char *qemu_find_file(int type, const char *name); /* OS specific functions */ void os_setup_early_signal_handling(void); char *os_find_datadir(void); -void os_parse_cmd_args(int index, const char *optarg); +int os_parse_cmd_args(int index, const char *optarg); #include "qemu/module.h" @@ -165,7 +165,7 @@ static bool os_parse_runas_uid_gid(const char *optarg) * Parse OS specific command line options. * return 0 if option handled, -1 otherwise */ -void os_parse_cmd_args(int index, const char *optarg) +int os_parse_cmd_args(int index, const char *optarg) { switch (index) { #ifdef CONFIG_SLIRP @@ -199,7 +199,11 @@ void os_parse_cmd_args(int index, const char *optarg) fips_set_state(true); break; #endif + default: + return -1; } + + return 0; } static void change_process_uid(void) @@ -93,9 +93,9 @@ void os_set_line_buffering(void) * Parse OS specific command line options. * return 0 if option handled, -1 otherwise */ -void os_parse_cmd_args(int index, const char *optarg) +int os_parse_cmd_args(int index, const char *optarg) { - return; + return -1; } int qemu_create_pidfile(const char *filename) @@ -4033,7 +4033,10 @@ int main(int argc, char **argv, char **envp) } break; default: - os_parse_cmd_args(popt->index, optarg); + if (os_parse_cmd_args(popt->index, optarg)) { + error_report("Option not supported in this build"); + exit(1); + } } } } |