qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Palmer Dabbelt <palmer@sifive.com>, pbonzini@redhat.com
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] vl.c: Report unknown machines correctly
Date: Tue, 17 Sep 2019 18:40:19 +0200	[thread overview]
Message-ID: <00d5a1a7-5bbe-176b-6272-f5b015a8e13e@redhat.com> (raw)
In-Reply-To: <20190915202011.30459-1-palmer@sifive.com>

On 9/15/19 10:20 PM, Palmer Dabbelt wrote:
> I was recently typing in a QEMU command line, and ended up with
> something like
> 
>     qemu-system-riscv64 -machine virt ... -M 8G
> 
> which is, in retrospect, obviously incorrect: there is no "8G" machine.
> I should have typed something like
> 
>     qemu-system-riscv64 -machine virt ... -m 8G
> 
> but since QEMU was giving me the excessively unhelpful error message
> 
>     qemu-system-riscv64: -machine virt: unsupported machine type
>     Use -machine help to list supported machines
> 
> I had to spend a few minutes scratching my head to figure out what was
> going on.  For some reason I felt like I'd done that before, so I
> figured I'd take a whack at fixing the problem this time.  It turns out
> the error reporting for non-existant machines is just wrong: the invalid
> machine is detected after we've lost the argument pointer, so it just
> prints out the first instance of "-machine" instead of the one we're
> actually looking for.
> 
> I've fixed this by just printing out "-machine $NAME" directly, but I
> feel like there's a better way to do this.  Specifically, my issue is
> that it always prints out "-machine" instead of "-M" -- that's actually
> a regression for users just passing a single invalid machine via "-M",
> which I assume is the more common case.
> 
> I'm not sure how to do this right, though, and my flight is boarding so
> I figured I'd send this out as a way to ask the question.  I didn't have
> time to run the test suite or figure out how to add a test for this, as
> I'm assuming there's a better way to do it.
> 
> Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
> ---
>  vl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/vl.c b/vl.c
> index 630f5c5e9c..821a5d91c8 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2487,7 +2487,7 @@ static MachineClass *machine_parse(const char *name, GSList *machines)
>  
>      mc = find_machine(name, machines);
>      if (!mc) {
> -        error_report("unsupported machine type");
> +        error_printf("-machine %s: unsupported machine type\n", name);
>          error_printf("Use -machine help to list supported machines\n");
>          exit(1);
>      }
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


  parent reply	other threads:[~2019-09-17 16:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-15 20:20 [Qemu-devel] [PATCH] vl.c: Report unknown machines correctly Palmer Dabbelt
2019-09-17 14:10 ` Paolo Bonzini
2019-09-17 16:40 ` Philippe Mathieu-Daudé [this message]
2019-09-23 13:03 ` Markus Armbruster

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=00d5a1a7-5bbe-176b-6272-f5b015a8e13e@redhat.com \
    --to=philmd@redhat.com \
    --cc=palmer@sifive.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).