Patchwork [for-1.4,v2,6/6] vl: Exit unsuccessfully on option argument syntax error

login
register
mail settings
Submitter Markus Armbruster
Date Feb. 8, 2013, 4:17 p.m.
Message ID <1360340232-4670-7-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/219223/
State New
Headers show

Comments

Markus Armbruster - Feb. 8, 2013, 4:17 p.m.
We exit successfully after reporting syntax error for argument of
--sandbox and --add-fd.

We continue undaunted after reporting it for argument of --option-rom
and --object then.

Change all four to exit unsuccessfully, like the other options.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 vl.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
Luiz Capitulino - Feb. 8, 2013, 6 p.m.
On Fri,  8 Feb 2013 17:17:12 +0100
Markus Armbruster <armbru@redhat.com> wrote:

> We exit successfully after reporting syntax error for argument of
> --sandbox and --add-fd.
> 
> We continue undaunted after reporting it for argument of --option-rom
> and --object then.
> 
> Change all four to exit unsuccessfully, like the other options.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>

What about qemu_opts_parse() call in QEMU_OPTION_boot?

> ---
>  vl.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/vl.c b/vl.c
> index 73122d8..4245ccc 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -3623,6 +3623,9 @@ int main(int argc, char **argv, char **envp)
>  		    exit(1);
>  		}
>                  opts = qemu_opts_parse(qemu_find_opts("option-rom"), optarg, 1);
> +                if (!opts) {
> +                    exit(1);
> +                }
>                  option_rom[nb_option_roms].name = qemu_opt_get(opts, "romfile");
>                  option_rom[nb_option_roms].bootindex =
>                      qemu_opt_get_number(opts, "bootindex", -1);
> @@ -3780,14 +3783,14 @@ int main(int argc, char **argv, char **envp)
>              case QEMU_OPTION_sandbox:
>                  opts = qemu_opts_parse(qemu_find_opts("sandbox"), optarg, 1);
>                  if (!opts) {
> -                    exit(0);
> +                    exit(1);
>                  }
>                  break;
>              case QEMU_OPTION_add_fd:
>  #ifndef _WIN32
>                  opts = qemu_opts_parse(qemu_find_opts("add-fd"), optarg, 0);
>                  if (!opts) {
> -                    exit(0);
> +                    exit(1);
>                  }
>  #else
>                  error_report("File descriptor passing is disabled on this "
> @@ -3797,6 +3800,9 @@ int main(int argc, char **argv, char **envp)
>                  break;
>              case QEMU_OPTION_object:
>                  opts = qemu_opts_parse(qemu_find_opts("object"), optarg, 1);
> +                if (!opts) {
> +                    exit(1);
> +                }
>                  break;
>              default:
>                  os_parse_cmd_args(popt->index, optarg);
Markus Armbruster - Feb. 8, 2013, 6:30 p.m.
Luiz Capitulino <lcapitulino@redhat.com> writes:

> On Fri,  8 Feb 2013 17:17:12 +0100
> Markus Armbruster <armbru@redhat.com> wrote:
>
>> We exit successfully after reporting syntax error for argument of
>> --sandbox and --add-fd.
>> 
>> We continue undaunted after reporting it for argument of --option-rom
>> and --object then.
>> 
>> Change all four to exit unsuccessfully, like the other options.
>> 
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>
> Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
>
> What about qemu_opts_parse() call in QEMU_OPTION_boot?

You're right!  I fixed in my tree, but then the fix hid in a not-for-1.4
commit.  Will extract it for 1.4.

Patch

diff --git a/vl.c b/vl.c
index 73122d8..4245ccc 100644
--- a/vl.c
+++ b/vl.c
@@ -3623,6 +3623,9 @@  int main(int argc, char **argv, char **envp)
 		    exit(1);
 		}
                 opts = qemu_opts_parse(qemu_find_opts("option-rom"), optarg, 1);
+                if (!opts) {
+                    exit(1);
+                }
                 option_rom[nb_option_roms].name = qemu_opt_get(opts, "romfile");
                 option_rom[nb_option_roms].bootindex =
                     qemu_opt_get_number(opts, "bootindex", -1);
@@ -3780,14 +3783,14 @@  int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_sandbox:
                 opts = qemu_opts_parse(qemu_find_opts("sandbox"), optarg, 1);
                 if (!opts) {
-                    exit(0);
+                    exit(1);
                 }
                 break;
             case QEMU_OPTION_add_fd:
 #ifndef _WIN32
                 opts = qemu_opts_parse(qemu_find_opts("add-fd"), optarg, 0);
                 if (!opts) {
-                    exit(0);
+                    exit(1);
                 }
 #else
                 error_report("File descriptor passing is disabled on this "
@@ -3797,6 +3800,9 @@  int main(int argc, char **argv, char **envp)
                 break;
             case QEMU_OPTION_object:
                 opts = qemu_opts_parse(qemu_find_opts("object"), optarg, 1);
+                if (!opts) {
+                    exit(1);
+                }
                 break;
             default:
                 os_parse_cmd_args(popt->index, optarg);