[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 19/30] qemu-options: Bail out on unsupported options
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 19/30] qemu-options: Bail out on unsupported options instead of silently ignoring them |
Date: |
Wed, 9 May 2018 00:14:36 +0200 |
From: Thomas Huth <address@hidden>
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 <address@hidden>
Signed-off-by: Thomas Huth <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
include/qemu-common.h | 2 +-
os-posix.c | 6 +++++-
os-win32.c | 4 ++--
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"
diff --git a/os-posix.c b/os-posix.c
index 24eb700..9ce6f74 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -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)
diff --git a/os-win32.c b/os-win32.c
index 586a7c7..0674f94 100644
--- a/os-win32.c
+++ b/os-win32.c
@@ -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)
diff --git a/vl.c b/vl.c
index b928e3e..a23acb2 100644
--- a/vl.c
+++ b/vl.c
@@ -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);
+ }
}
}
}
--
1.8.3.1
- [Qemu-devel] [PULL 08/30] exec: small changes to flatview_do_translate, (continued)
- [Qemu-devel] [PULL 08/30] exec: small changes to flatview_do_translate, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 10/30] exec: reintroduce MemoryRegion caching, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 11/30] qemu-thread: always keep the posix wrapper layer, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 12/30] update-linux-headers: drop hyperv.h, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 07/30] exec: move memory access declarations to a common header, inline *_phys functions, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 13/30] accel: use g_strsplit for parsing accelerator names, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 14/30] opts: don't silently truncate long parameter keys, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 17/30] qemu-options: Mark -virtioconsole as deprecated, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 18/30] qemu-options: Remove remainders of the -tdf option, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 19/30] qemu-options: Bail out on unsupported options instead of silently ignoring them,
Paolo Bonzini <=
- [Qemu-devel] [PULL 20/30] qemu-options: Remove deprecated -no-kvm-pit-reinjection, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 16/30] target/i386: sev: fix memory leaks, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 15/30] opts: don't silently truncate long option values, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 21/30] qemu-options: Remove deprecated -no-kvm-irqchip, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 25/30] configure: Really use local libfdt if the system one is too old, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 22/30] qemu-doc: provide details of supported build platforms, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 23/30] glib: bump min required glib library version to 2.42, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 27/30] shippable: Remove Debian 8 libfdt kludge, Paolo Bonzini, 2018/05/08