From patchwork Wed Feb 5 13:44:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miroslav Rezanina X-Patchwork-Id: 317141 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 869D72C0040 for ; Thu, 6 Feb 2014 00:45:07 +1100 (EST) Received: from localhost ([::1]:59295 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WB2mn-0003Yu-61 for incoming@patchwork.ozlabs.org; Wed, 05 Feb 2014 08:45:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39575) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WB2mN-0003Qn-1T for qemu-devel@nongnu.org; Wed, 05 Feb 2014 08:44:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WB2mG-0001XV-O4 for qemu-devel@nongnu.org; Wed, 05 Feb 2014 08:44:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55310) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WB2mG-0001Wz-Fs for qemu-devel@nongnu.org; Wed, 05 Feb 2014 08:44:32 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s15DiVtV030472 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 5 Feb 2014 08:44:31 -0500 Received: from lws-ntb.brq.redhat.com (dhcp-27-185.brq.redhat.com [10.34.27.185]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s15DiURh022018 for ; Wed, 5 Feb 2014 08:44:30 -0500 From: mrezanin@redhat.com To: qemu-devel@nongnu.org Date: Wed, 5 Feb 2014 14:44:23 +0100 Message-Id: <90998dac0113b5e791189eb3240d60c13446c709.1391607703.git.mrezanin@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v6] vl.c: Output error on invalid machine type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- v6: - print help instead of list supported machines on error vl.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/vl.c b/vl.c index 383be1b..3297c0a 100644 --- a/vl.c +++ b/vl.c @@ -2600,13 +2600,19 @@ static QEMUMachine *machine_parse(const char *name) if (machine) { return machine; } - printf("Supported machines are:\n"); - for (m = first_machine; m != NULL; m = m->next) { - 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"); + printf("\nUse '-M help' to list supported machines!\n"); + } else { + printf("Supported machines are:\n"); + for (m = first_machine; m != NULL; m = m->next) { + 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)" : ""); } exit(!name || !is_help_option(name)); }