From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>
Cc: berrange@redhat.com, Markus Armbruster <armbru@redhat.com>
Subject: [Qemu-devel] [PATCH v2 2/5] qemu-options: Bail out on unsupported options instead of silently ignoring them
Date: Fri, 4 May 2018 19:01:07 +0200 [thread overview]
Message-ID: <1525453270-23074-3-git-send-email-thuth@redhat.com> (raw)
In-Reply-To: <1525453270-23074-1-git-send-email-thuth@redhat.com>
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>
---
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 806eec2..457e93b 100644
--- a/vl.c
+++ b/vl.c
@@ -4042,7 +4042,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
next prev parent reply other threads:[~2018-05-04 17:01 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-04 17:01 [Qemu-devel] [PATCH v2 0/5] Removal of deprecated -no-kvm* options Thomas Huth
2018-05-04 17:01 ` [Qemu-devel] [PATCH v2 1/5] qemu-options: Remove remainders of the -tdf option Thomas Huth
2018-05-04 17:01 ` Thomas Huth [this message]
2018-05-16 16:49 ` [Qemu-devel] [PATCH v2 2/5] qemu-options: Bail out on unsupported options instead of silently ignoring them Anthony PERARD
2018-05-16 16:51 ` Thomas Huth
2018-05-04 17:01 ` [Qemu-devel] [PATCH v2 3/5] qemu-options: Remove deprecated -no-kvm-pit-reinjection Thomas Huth
2018-05-04 17:01 ` [Qemu-devel] [PATCH v2 4/5] qemu-options: Remove deprecated -no-kvm-irqchip Thomas Huth
2018-05-04 17:01 ` [Qemu-devel] [PATCH v2 5/5] qemu-options: Remove deprecated -no-kvm Thomas Huth
2018-05-04 21:57 ` [Qemu-devel] [PATCH v2 0/5] Removal of deprecated -no-kvm* options Paolo Bonzini
2018-05-07 5:09 ` Thomas Huth
2018-05-07 5:37 ` Markus Armbruster
2018-05-07 5:45 ` Thomas Huth
2018-05-07 7:56 ` Markus Armbruster
2018-05-07 11:02 ` Paolo Bonzini
2018-05-07 11:56 ` Markus Armbruster
2018-05-07 12:44 ` Paolo Bonzini
2018-05-07 16:50 ` Markus Armbruster
2018-05-07 17:01 ` Paolo Bonzini
2018-05-16 16:59 ` Thomas Huth
2018-05-07 11:00 ` Paolo Bonzini
2018-05-07 11:47 ` Markus Armbruster
2018-05-04 21:58 ` Paolo Bonzini
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=1525453270-23074-3-git-send-email-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=pbonzini@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).