[PULL 15/16] vl.c: select_machine(): add selected machine type to error message

Michael Tokarev posted 16 patches 2 months, 2 weeks ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, "Dr. David Alan Gilbert" <dave@treblig.org>, Peter Maydell <peter.maydell@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Yanan Wang <wangyanan55@huawei.com>, Laurent Vivier <laurent@vivier.eu>, Pavel Pisa <pisa@cmp.felk.cvut.cz>, Vikram Garhwal <fnu.vikram@xilinx.com>, Jason Wang <jasowang@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
[PULL 15/16] vl.c: select_machine(): add selected machine type to error message
Posted by Michael Tokarev 2 months, 2 weeks ago
From: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 system/vl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/system/vl.c b/system/vl.c
index 92fc29c193..bdd2f6ecf6 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -1674,7 +1674,7 @@ static MachineClass *select_machine(QDict *qdict, Error **errp)
         machine_class = find_machine(machine_type, machines);
         qdict_del(qdict, "type");
         if (!machine_class) {
-            error_setg(errp, "unsupported machine type");
+            error_setg(errp, "unsupported machine type: \"%s\"", optarg);
         }
     } else {
         machine_class = find_default_machine(machines);
-- 
2.39.2


Re: [PULL 15/16] vl.c: select_machine(): add selected machine type to error message
Posted by Peter Maydell 3 weeks, 4 days ago
On Sun, 30 Jun 2024 at 17:57, Michael Tokarev <mjt@tls.msk.ru> wrote:
>
> From: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
> ---
>  system/vl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/system/vl.c b/system/vl.c
> index 92fc29c193..bdd2f6ecf6 100644
> --- a/system/vl.c
> +++ b/system/vl.c
> @@ -1674,7 +1674,7 @@ static MachineClass *select_machine(QDict *qdict, Error **errp)
>          machine_class = find_machine(machine_type, machines);
>          qdict_del(qdict, "type");
>          if (!machine_class) {
> -            error_setg(errp, "unsupported machine type");
> +            error_setg(errp, "unsupported machine type: \"%s\"", optarg);
>          }
>      } else {
>          machine_class = find_default_machine(machines);

Hi. This patch doesn't do the right thing:

$ ./build/x86/qemu-system-aarch64 -M bang
qemu-system-aarch64: unsupported machine type: "(null)"
Use -machine help to list supported machines

"optarg" is a global, and at the point where we call
select_machine() it isn't valid (we've finished parsing
the options entirely). The thing the error message should
be printing is the local variable "machine_type".

I'll send a patch in a moment.

thanks
-- PMM