958e1b
From 82cd74f8a796d59fb527bea82b0557bfe558d2cc Mon Sep 17 00:00:00 2001
958e1b
From: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
Date: Wed, 11 Jun 2014 06:39:28 -0500
958e1b
Subject: [CHANGE 01/29] vl.c: Output error on invalid machine type
958e1b
To: rhvirt-patches@redhat.com,
958e1b
    jen@redhat.com
958e1b
958e1b
RH-Author: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
Message-id: <1402468768-15574-1-git-send-email-mrezanin@redhat.com>
958e1b
Patchwork-id: 59190
958e1b
O-Subject: [RHEL7 qemu-kvm PATCH] vl.c: Output error on invalid machine type
958e1b
Bugzilla: 990724
958e1b
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
958e1b
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
958e1b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
958e1b
958e1b
From: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
958e1b
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=990724
958e1b
Brew: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7564904
958e1b
958e1b
Output error message using qemu's error_report() function when user
958e1b
provides the invalid machine type on the command line. This also saves
958e1b
time to find what issue is when you downgrade from one version of qemu
958e1b
to another that doesn't support required machine type yet (the version
958e1b
user downgraded to have to have this patch applied too, of course).
958e1b
958e1b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
[Replace printf with error_printf, suggested by Markus Armbruster. - Paolo]
958e1b
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
958e1b
958e1b
Signed-off-by: jen <jen@redhat.com>
958e1b
958e1b
Conflicts:
958e1b
	vl.c - missing commit 261747f176f6f2d88f8268aaebfdd1a1afe887e2
958e1b
           (vl: Use MachineClass instead of global QEMUMachine list)
958e1b
958e1b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
(cherry-picked from commit 025172d56e11ba3d86d0937933a23aab3b8606b1)
958e1b
---
958e1b
 vl.c | 17 +++++++++++------
958e1b
 1 file changed, 11 insertions(+), 6 deletions(-)
958e1b
958e1b
Signed-off-by: jen <jen@redhat.com>
958e1b
---
958e1b
 vl.c | 17 +++++++++++------
958e1b
 1 file changed, 11 insertions(+), 6 deletions(-)
958e1b
958e1b
diff --git a/vl.c b/vl.c
958e1b
index 6ff06cc..a0099f6 100644
958e1b
--- a/vl.c
958e1b
+++ b/vl.c
958e1b
@@ -2578,13 +2578,18 @@ static QEMUMachine *machine_parse(const char *name)
958e1b
     if (machine) {
958e1b
         return machine;
958e1b
     }
958e1b
-    printf("Supported machines are:\n");
958e1b
-    for (m = first_machine; m != NULL; m = m->next) {
958e1b
-        if (m->alias) {
958e1b
-            printf("%-20s %s (alias of %s)\n", m->alias, m->desc, m->name);
958e1b
+    if (name && !is_help_option(name)) {
958e1b
+        error_report("Unsupported machine type");
958e1b
+        error_printf("Use -machine help to list supported machines!\n");
958e1b
+    } else {
958e1b
+        printf("Supported machines are:\n");
958e1b
+        for (m = first_machine; m != NULL; m = m->next) {
958e1b
+            if (m->alias) {
958e1b
+                printf("%-20s %s (alias of %s)\n", m->alias, m->desc, m->name);
958e1b
+            }
958e1b
+            printf("%-20s %s%s\n", m->name, m->desc,
958e1b
+                   m->is_default ? " (default)" : "");
958e1b
         }
958e1b
-        printf("%-20s %s%s\n", m->name, m->desc,
958e1b
-               m->is_default ? " (default)" : "");
958e1b
     }
958e1b
     exit(!name || !is_help_option(name));
958e1b
 }
958e1b
-- 
958e1b
1.9.3
958e1b