qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] vl.c: Report unknown machines correctly
@ 2019-09-15 20:20 Palmer Dabbelt
  2019-09-17 14:10 ` Paolo Bonzini
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Palmer Dabbelt @ 2019-09-15 20:20 UTC (permalink / raw)
  To: pbonzini; +Cc: Palmer Dabbelt, qemu-devel

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);
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-09-23 13:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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é
2019-09-23 13:03 ` Markus Armbruster

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).