From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48395) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPWa6-0004JB-Th for qemu-devel@nongnu.org; Mon, 17 Mar 2014 08:23:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WPWZy-0003UP-7p for qemu-devel@nongnu.org; Mon, 17 Mar 2014 08:23:50 -0400 Received: from mail-qg0-x232.google.com ([2607:f8b0:400d:c04::232]:52546) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPWZy-0003UG-3M for qemu-devel@nongnu.org; Mon, 17 Mar 2014 08:23:42 -0400 Received: by mail-qg0-f50.google.com with SMTP id q108so16331362qgd.9 for ; Mon, 17 Mar 2014 05:23:41 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 17 Mar 2014 13:23:17 +0100 Message-Id: <1395058997-19660-5-git-send-email-pbonzini@redhat.com> In-Reply-To: <1395058997-19660-1-git-send-email-pbonzini@redhat.com> References: <1395058997-19660-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 4/4] vl.c: Output error on invalid machine type List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Miroslav Rezanina From: Miroslav Rezanina Output error message using qemu's error_report() function when user provides the invalid machine type on the command line. This also saves time to find what issue is when you downgrade from one version of qemu to another that doesn't support required machine type yet (the version user downgraded to have to have this patch applied too, of course). Signed-off-by: Miroslav Rezanina [Replace printf with error_printf, suggested by Markus Armbruster. - Paolo] Signed-off-by: Paolo Bonzini --- vl.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/vl.c b/vl.c index 842e897..b363a21 100644 --- a/vl.c +++ b/vl.c @@ -2651,15 +2651,20 @@ static MachineClass *machine_parse(const char *name) if (mc) { return mc; } - printf("Supported machines are:\n"); - for (el = machines; el; el = el->next) { - MachineClass *mc = el->data; - QEMUMachine *m = mc->qemu_machine; - if (m->alias) { - printf("%-20s %s (alias of %s)\n", m->alias, m->desc, m->name); + if (name && !is_help_option(name)) { + error_report("Unsupported machine type"); + error_printf("Use -machine help to list supported machines!\n"); + } else { + printf("Supported machines are:\n"); + for (el = machines; el; el = el->next) { + MachineClass *mc = el->data; + QEMUMachine *m = mc->qemu_machine; + if (m->alias) { + printf("%-20s %s (alias of %s)\n", m->alias, m->desc, m->name); + } + printf("%-20s %s%s\n", m->name, m->desc, + m->is_default ? " (default)" : ""); } - printf("%-20s %s%s\n", m->name, m->desc, - m->is_default ? " (default)" : ""); } g_slist_free(machines); -- 1.8.5.3