hw/lm32: print error if cpu model is not found
authorMichael Walle <michael@walle.cc>
Thu, 28 Nov 2013 18:09:33 +0000 (19:09 +0100)
committerMichael Walle <michael@walle.cc>
Tue, 4 Feb 2014 18:47:39 +0000 (19:47 +0100)
QEMU crashed if a the given cpu_model is not found.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
hw/lm32/lm32_boards.c
hw/lm32/milkymist.c

index c032bb8b963c854ae173a201aa7922b3343bdc49..5e22e9b4d7deced740f6c48a10bca80f7a254008 100644 (file)
@@ -101,6 +101,11 @@ static void lm32_evr_init(QEMUMachineInitArgs *args)
         cpu_model = "lm32-full";
     }
     cpu = cpu_lm32_init(cpu_model);
+    if (cpu == NULL) {
+        fprintf(stderr, "qemu: unable to find CPU '%s'\n", cpu_model);
+        exit(1);
+    }
+
     env = &cpu->env;
     reset_info->cpu = cpu;
 
@@ -198,6 +203,11 @@ static void lm32_uclinux_init(QEMUMachineInitArgs *args)
         cpu_model = "lm32-full";
     }
     cpu = cpu_lm32_init(cpu_model);
+    if (cpu == NULL) {
+        fprintf(stderr, "qemu: unable to find CPU '%s'\n", cpu_model);
+        exit(1);
+    }
+
     env = &cpu->env;
     reset_info->cpu = cpu;
 
index 15053c4c3756fe4d6eb7ff2cfd2b76241319d59a..baf234ce04d555a0b7445274ea1368d6917266bc 100644 (file)
@@ -108,6 +108,11 @@ milkymist_init(QEMUMachineInitArgs *args)
         cpu_model = "lm32-full";
     }
     cpu = cpu_lm32_init(cpu_model);
+    if (cpu == NULL) {
+        fprintf(stderr, "qemu: unable to find CPU '%s'\n", cpu_model);
+        exit(1);
+    }
+
     env = &cpu->env;
     reset_info->cpu = cpu;