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