]> git.proxmox.com Git - mirror_qemu.git/commitdiff
cpu: make cpu_generic_init() abort QEMU on error
authorIgor Mammedov <imammedo@redhat.com>
Wed, 13 Sep 2017 16:04:54 +0000 (18:04 +0200)
committerEduardo Habkost <ehabkost@redhat.com>
Tue, 19 Sep 2017 12:09:32 +0000 (09:09 -0300)
Almost every user of cpu_generic_init() checks for
returned NULL and then reports failure in a custom way
and aborts process.
Some users assume that call can't fail and don't check
for failure, though they should have checked for it.

In either cases cpu_generic_init() failure is fatal,
so instead of checking for failure and reporting
it various ways, make cpu_generic_init() report
errors in consistent way and terminate QEMU on failure.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <1505318697-77161-3-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
38 files changed:
bsd-user/main.c
hw/alpha/dp264.c
hw/arm/musicpal.c
hw/arm/omap1.c
hw/arm/omap2.c
hw/arm/pxa2xx.c
hw/arm/strongarm.c
hw/lm32/lm32_boards.c
hw/lm32/milkymist.c
hw/m68k/an5206.c
hw/m68k/mcf5208.c
hw/mips/cps.c
hw/mips/mips_fulong2e.c
hw/mips/mips_jazz.c
hw/mips/mips_malta.c
hw/mips/mips_mipssim.c
hw/mips/mips_r4k.c
hw/moxie/moxiesim.c
hw/openrisc/openrisc_sim.c
hw/ppc/e500.c
hw/ppc/mac_newworld.c
hw/ppc/mac_oldworld.c
hw/ppc/ppc440_bamboo.c
hw/ppc/ppc4xx_devs.c
hw/ppc/prep.c
hw/ppc/virtex_ml507.c
hw/sh4/r2d.c
hw/sh4/shix.c
hw/sparc/leon3.c
hw/sparc/sun4m.c
hw/sparc64/sparc64.c
hw/tricore/tricore_testboard.c
hw/unicore32/puv3.c
hw/xtensa/sim.c
hw/xtensa/xtfpga.c
include/qom/cpu.h
linux-user/main.c
qom/cpu.c

index 8a6706a1c88494135dfba8a40515d65c7a1bfa4a..836daac15cee3cd9f38bda092f13d6f0e09355ea 100644 (file)
@@ -902,10 +902,6 @@ int main(int argc, char **argv)
     /* NOTE: we need to init the CPU at this stage to get
        qemu_host_page_size */
     cpu = cpu_init(cpu_model);
-    if (!cpu) {
-        fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
-    }
     env = cpu->env_ptr;
 #if defined(TARGET_SPARC) || defined(TARGET_PPC)
     cpu_reset(cpu);
index 1c5a177102946eb32aed0bbf5bd2ac4bcdb9cf21..1b121306c22e8757691a8824a28a885065d8f730 100644 (file)
@@ -68,10 +68,6 @@ static void clipper_init(MachineState *machine)
     memset(cpus, 0, sizeof(cpus));
     for (i = 0; i < smp_cpus; ++i) {
         cpus[i] = ALPHA_CPU(cpu_generic_init(TYPE_ALPHA_CPU, cpu_model));
-        if (!cpus[i]) {
-            error_report("Unable to find CPU definition");
-            exit(1);
-        }
     }
 
     cpus[0]->env.trap_arg0 = ram_size;
index ab4ba31a2495a53757340104a5b446a105cc691d..7a6c0a6deb07a84fac92303e4b256ac6d2bb7b85 100644 (file)
@@ -1594,10 +1594,6 @@ static void musicpal_init(MachineState *machine)
         cpu_model = "arm926";
     }
     cpu = ARM_CPU(cpu_generic_init(TYPE_ARM_CPU, cpu_model));
-    if (!cpu) {
-        fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
-    }
 
     /* For now we use a fixed - the original - RAM size */
     memory_region_allocate_system_memory(ram, NULL, "musicpal.ram",
index 400ba30c94b69ae074e62fac18691bfd1aefd4c8..04e65ce168d42db89f9c8490082637808a1abf1e 100644 (file)
@@ -3864,10 +3864,6 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *system_memory,
     /* Core */
     s->mpu_model = omap310;
     s->cpu = ARM_CPU(cpu_generic_init(TYPE_ARM_CPU, core));
-    if (s->cpu == NULL) {
-        fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
-    }
     s->sdram_size = sdram_size;
     s->sram_size = OMAP15XX_SRAM_SIZE;
 
index ece25ae744fc8ebb4713e785c6392bc0c631fbbb..5821477950e31af5c521f0a5fac1257547d264cd 100644 (file)
@@ -2262,10 +2262,6 @@ struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sysmem,
     /* Core */
     s->mpu_model = omap2420;
     s->cpu = ARM_CPU(cpu_generic_init(TYPE_ARM_CPU, core ?: "arm1136-r2"));
-    if (s->cpu == NULL) {
-        fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
-    }
     s->sdram_size = sdram_size;
     s->sram_size = OMAP242X_SRAM_SIZE;
 
index b0ac3cfd649a794869f236c9872795f53af556ea..c16657da862ce6e4ba9c191ed1f0b7894a403ce4 100644 (file)
@@ -2067,10 +2067,6 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
         revision = "pxa270";
 
     s->cpu = ARM_CPU(cpu_generic_init(TYPE_ARM_CPU, revision));
-    if (s->cpu == NULL) {
-        fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
-    }
     s->reset = qemu_allocate_irq(pxa2xx_reset, s, 0);
 
     /* SDRAM & Internal Memory Storage */
@@ -2197,10 +2193,6 @@ PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size)
     s = g_new0(PXA2xxState, 1);
 
     s->cpu = ARM_CPU(cpu_generic_init(TYPE_ARM_CPU, "pxa255"));
-    if (s->cpu == NULL) {
-        fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
-    }
     s->reset = qemu_allocate_irq(pxa2xx_reset, s, 0);
 
     /* SDRAM & Internal Memory Storage */
index 884242b2dc333909784435126736004561116e67..c1145dd7238bf6887278f75c5942382852f9ac35 100644 (file)
@@ -1599,11 +1599,6 @@ StrongARMState *sa1110_init(MemoryRegion *sysmem,
 
     s->cpu = ARM_CPU(cpu_generic_init(TYPE_ARM_CPU, rev));
 
-    if (!s->cpu) {
-        error_report("Unable to find CPU definition");
-        exit(1);
-    }
-
     memory_region_allocate_system_memory(&s->sdram, NULL, "strongarm.sdram",
                                          sdram_size);
     memory_region_add_subregion(sysmem, SA_SDCS0, &s->sdram);
index eccf0ac5a158856ea1b8de51858ffc616c24f1d1..b0bb3ef58af4af8234799c099d0a160fc4638e57 100644 (file)
@@ -105,10 +105,6 @@ static void lm32_evr_init(MachineState *machine)
         cpu_model = "lm32-full";
     }
     cpu = LM32_CPU(cpu_generic_init(TYPE_LM32_CPU, 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;
@@ -206,10 +202,6 @@ static void lm32_uclinux_init(MachineState *machine)
         cpu_model = "lm32-full";
     }
     cpu = LM32_CPU(cpu_generic_init(TYPE_LM32_CPU, 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 dffd8797bbc967896962390d85b0e41cc3e70d84..4db4d2d533842001d508430a0e8e153eb72b439e 100644 (file)
@@ -112,10 +112,6 @@ milkymist_init(MachineState *machine)
         cpu_model = "lm32-full";
     }
     cpu = LM32_CPU(cpu_generic_init(TYPE_LM32_CPU, 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 7b9b15d6c497713e3aaf06cf895e2bae8bed623a..9002c460e5e70d69734b46217ceb2d699d8c1ac6 100644 (file)
@@ -43,10 +43,6 @@ static void an5206_init(MachineState *machine)
         cpu_model = "m5206";
     }
     cpu = M68K_CPU(cpu_generic_init(TYPE_M68K_CPU, cpu_model));
-    if (!cpu) {
-        error_report("Unable to find m68k CPU definition");
-        exit(1);
-    }
     env = &cpu->env;
 
     /* Initialize CPU registers.  */
index 1a0f18073a01b370e6803619d22605d906fba65a..b9dde75106ddc831675186748b34a061572b462d 100644 (file)
@@ -233,10 +233,6 @@ static void mcf5208evb_init(MachineState *machine)
         cpu_model = "m5208";
     }
     cpu = M68K_CPU(cpu_generic_init(TYPE_M68K_CPU, cpu_model));
-    if (!cpu) {
-        fprintf(stderr, "Unable to find m68k CPU definition\n");
-        exit(1);
-    }
     env = &cpu->env;
 
     /* Initialize CPU registers.  */
index 4ef337d5c4ffb568662451c4934b60110feba944..79d4c5e30a7c2cdd87aede871455fbff363e0ce5 100644 (file)
@@ -72,10 +72,6 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)
 
     for (i = 0; i < s->num_vp; i++) {
         cpu = cpu_mips_init(s->cpu_model);
-        if (cpu == NULL) {
-            error_setg(errp, "%s: CPU initialization failed",  __func__);
-            return;
-        }
 
         /* Init internal devices */
         cpu_mips_irq_init_cpu(cpu);
index 3532399a131b853aa75056e0e14d922a486757e5..439a3d7a66cb423faa2baa4246d3517aa95069ee 100644 (file)
@@ -281,10 +281,6 @@ static void mips_fulong2e_init(MachineState *machine)
         cpu_model = "Loongson-2E";
     }
     cpu = cpu_mips_init(cpu_model);
-    if (cpu == NULL) {
-        fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
-    }
     env = &cpu->env;
 
     qemu_register_reset(main_cpu_reset, cpu);
index df2262a2a86403f5aea31f1a667aefb8ebce118d..ae10670efd3a66b28bb419d5e3734701b50f75b2 100644 (file)
@@ -152,10 +152,6 @@ static void mips_jazz_init(MachineState *machine,
         cpu_model = "R4000";
     }
     cpu = cpu_mips_init(cpu_model);
-    if (cpu == NULL) {
-        fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
-    }
     env = &cpu->env;
     qemu_register_reset(main_cpu_reset, cpu);
 
index af678f57845394f51324c7939d3a5a33395b399e..c82e0af3400566b73efaae2a9d85154cacc486eb 100644 (file)
@@ -932,10 +932,6 @@ static void create_cpu_without_cps(const char *cpu_model,
 
     for (i = 0; i < smp_cpus; i++) {
         cpu = cpu_mips_init(cpu_model);
-        if (cpu == NULL) {
-            fprintf(stderr, "Unable to find CPU definition\n");
-            exit(1);
-        }
 
         /* Init internal devices */
         cpu_mips_irq_init_cpu(cpu);
index 07fc4c2300d58cfe3f7742549d48a45792467794..49cd38d6808ed9cf95f70cbc9df99267c183e908 100644 (file)
@@ -164,10 +164,6 @@ mips_mipssim_init(MachineState *machine)
 #endif
     }
     cpu = cpu_mips_init(cpu_model);
-    if (cpu == NULL) {
-        fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
-    }
     env = &cpu->env;
 
     reset_info = g_malloc0(sizeof(ResetData));
index 2f5ced740973cddd1c28358e8a6ab6a41f75ab5b..60da6070bcf231c62b22db4e1545ab5bf38d0bfd 100644 (file)
@@ -194,10 +194,6 @@ void mips_r4k_init(MachineState *machine)
 #endif
     }
     cpu = cpu_mips_init(cpu_model);
-    if (cpu == NULL) {
-        fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
-    }
     env = &cpu->env;
 
     reset_info = g_malloc0(sizeof(ResetData));
index 4c27b45c46500dd6a462e5be7ba6f4d5134bcb4c..5ea8dd3a93aaa9e7bdf4b26377d53566a978f537 100644 (file)
@@ -119,10 +119,6 @@ static void moxiesim_init(MachineState *machine)
         cpu_model = "MoxieLite-moxie-cpu";
     }
     cpu = MOXIE_CPU(cpu_generic_init(TYPE_MOXIE_CPU, cpu_model));
-    if (!cpu) {
-        fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
-    }
     env = &cpu->env;
 
     qemu_register_reset(main_cpu_reset, cpu);
index 243d8020dbde2d51f9dfc4866e3d846fe1fc5bc9..86bf2849c4d711c0cdec8d276ab79bb1b0bf93e0 100644 (file)
@@ -110,10 +110,6 @@ static void openrisc_sim_init(MachineState *machine)
 
     for (n = 0; n < smp_cpus; n++) {
         cpu = OPENRISC_CPU(cpu_generic_init(TYPE_OPENRISC_CPU, cpu_model));
-        if (cpu == NULL) {
-            fprintf(stderr, "Unable to find CPU definition!\n");
-            exit(1);
-        }
         qemu_register_reset(main_cpu_reset, cpu);
         main_cpu_reset(cpu);
     }
index 55cad780f4b31ecfce453b73d28f71644bac3450..db0e49ab8f651d25fd96b458bd738f66c2f9d68d 100644 (file)
@@ -817,10 +817,6 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
 
         cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU,
                                            machine->cpu_model));
-        if (cpu == NULL) {
-            fprintf(stderr, "Unable to initialize CPU!\n");
-            exit(1);
-        }
         env = &cpu->env;
         cs = CPU(cpu);
 
index d4666349974ec5652a2f8ec639055f8d3b0ff9df..33b46cb50be7131a69efc28e8e977ce71158803a 100644 (file)
@@ -189,10 +189,6 @@ static void ppc_core99_init(MachineState *machine)
     for (i = 0; i < smp_cpus; i++) {
         cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU,
                                            machine->cpu_model));
-        if (cpu == NULL) {
-            fprintf(stderr, "Unable to find PowerPC CPU definition\n");
-            exit(1);
-        }
         env = &cpu->env;
 
         /* Set time-base frequency to 100 Mhz */
index fcac39956224680122d3d54c3f5e21eefc0ee780..193b9047d94dd5958f3959c9a3db018eab397ae7 100644 (file)
@@ -118,10 +118,6 @@ static void ppc_heathrow_init(MachineState *machine)
     for (i = 0; i < smp_cpus; i++) {
         cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU,
                                            machine->cpu_model));
-        if (cpu == NULL) {
-            fprintf(stderr, "Unable to find PowerPC CPU definition\n");
-            exit(1);
-        }
         env = &cpu->env;
 
         /* Set time-base frequency to 16.6 Mhz */
index ca26398036b84fcd63a0a040b22d4e55af5ddc4c..f92d47f28d9316178c0cd6141a61b5d942d6c189 100644 (file)
@@ -187,10 +187,6 @@ static void bamboo_init(MachineState *machine)
         machine->cpu_model = "440EP";
     }
     cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, machine->cpu_model));
-    if (cpu == NULL) {
-        fprintf(stderr, "Unable to initialize CPU!\n");
-        exit(1);
-    }
     env = &cpu->env;
 
     if (env->mmu_model != POWERPC_MMU_BOOKE) {
index ec90f132954c493b875270e33f282c010c1d5f17..6d7f7857fe9ddf773753bd228cc9cebd5d2d825e 100644 (file)
@@ -57,11 +57,6 @@ PowerPCCPU *ppc4xx_init(const char *cpu_model,
 
     /* init CPUs */
     cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, cpu_model));
-    if (cpu == NULL) {
-        fprintf(stderr, "Unable to find PowerPC %s CPU definition\n",
-                cpu_model);
-        exit(1);
-    }
     env = &cpu->env;
 
     cpu_clk->cb = NULL; /* We don't care about CPU clock frequency changes */
index 00f3321a6098e1fbe2c6f419d5d3ce7673070c50..94138a4e8c4c69666d743d86074585bfb82aa639 100644 (file)
@@ -522,10 +522,6 @@ static void ppc_prep_init(MachineState *machine)
     for (i = 0; i < smp_cpus; i++) {
         cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU,
                                            machine->cpu_model));
-        if (cpu == NULL) {
-            fprintf(stderr, "Unable to find PowerPC CPU definition\n");
-            exit(1);
-        }
         env = &cpu->env;
 
         if (env->flags & POWERPC_FLAG_RTC_CLK) {
@@ -726,11 +722,6 @@ static void ibm_40p_init(MachineState *machine)
         machine->cpu_model = "604";
     }
     cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, machine->cpu_model));
-    if (!cpu) {
-        error_report("could not initialize CPU '%s'",
-                     machine->cpu_model);
-        exit(1);
-    }
     env = &cpu->env;
     if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
         error_report("only 6xx bus is supported on this machine");
index d5fdc16b5973ac1e299f4d9768fac2cb58e1a122..ed9b406fd3e7f5b9931cbc11bad4a3b2b5ed4ac4 100644 (file)
@@ -97,10 +97,6 @@ static PowerPCCPU *ppc440_init_xilinx(ram_addr_t *ram_size,
     qemu_irq *irqs;
 
     cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, cpu_model));
-    if (cpu == NULL) {
-        fprintf(stderr, "Unable to initialize CPU!\n");
-        exit(1);
-    }
     env = &cpu->env;
 
     ppc_booke_timers_init(cpu, sysclk, 0/* no flags */);
index 22bc534e5f1db0353d4e87dc3725e359ef8d4eea..16b9ed2db24dcd62f2e1a6028aae4b989dff7a2e 100644 (file)
@@ -247,10 +247,6 @@ static void r2d_init(MachineState *machine)
     }
 
     cpu = SUPERH_CPU(cpu_generic_init(TYPE_SUPERH_CPU, cpu_model));
-    if (cpu == NULL) {
-        fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
-    }
     env = &cpu->env;
 
     reset_info = g_malloc0(sizeof(ResetData));
index 7f8a4b6484d6adf026dfdea8287025a4ef8fa196..50ee36a5c549ebb5c8c33174b88929cccebc106f 100644 (file)
@@ -57,10 +57,6 @@ static void shix_init(MachineState *machine)
         cpu_model = "any";
 
     cpu = SUPERH_CPU(cpu_generic_init(TYPE_SUPERH_CPU, cpu_model));
-    if (cpu == NULL) {
-        fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
-    }
 
     /* Allocate memory space */
     memory_region_init_ram(rom, NULL, "shix.rom", 0x4000, &error_fatal);
index 56512ecd00cf5903da3e235d20b8e869b3176ca3..ec2816bf9498b1834770b980b8e45e6ae4278551 100644 (file)
@@ -127,10 +127,6 @@ static void leon3_generic_hw_init(MachineState *machine)
     }
 
     cpu = SPARC_CPU(cpu_generic_init(TYPE_SPARC_CPU, cpu_model));
-    if (cpu == NULL) {
-        fprintf(stderr, "qemu: Unable to find Sparc CPU definition\n");
-        exit(1);
-    }
     env = &cpu->env;
 
     cpu_sparc_set_id(env, 0);
index cf47dca83af74f11e24cc0aaa3cae89316411c25..e1bdd4828d29cf650247067bdb36b351092a9fa3 100644 (file)
@@ -798,10 +798,6 @@ static void cpu_devinit(const char *cpu_model, unsigned int id,
     CPUSPARCState *env;
 
     cpu = SPARC_CPU(cpu_generic_init(TYPE_SPARC_CPU, cpu_model));
-    if (cpu == NULL) {
-        fprintf(stderr, "qemu: Unable to find Sparc CPU definition\n");
-        exit(1);
-    }
     env = &cpu->env;
 
     cpu_sparc_set_id(env, id);
index ecf38a45dab3208fd4e1f586ba8dba16810c5530..097d529ff10b98af754fcafbaac68a95b113e26d 100644 (file)
@@ -354,10 +354,6 @@ SPARCCPU *sparc64_cpu_devinit(const char *cpu_model,
         cpu_model = default_cpu_model;
     }
     cpu = SPARC_CPU(cpu_generic_init(TYPE_SPARC_CPU, cpu_model));
-    if (cpu == NULL) {
-        fprintf(stderr, "Unable to find Sparc CPU definition\n");
-        exit(1);
-    }
     env = &cpu->env;
 
     env->tick = cpu_timer_create("tick", cpu, tick_irq,
index 3fcd8bb70eebe071fe8ca60a1403d15ab1861d0b..0486f8a1d93dbc097dc276e547672dfc3f87b8c8 100644 (file)
@@ -75,10 +75,6 @@ static void tricore_testboard_init(MachineState *machine, int board_id)
         machine->cpu_model = "tc1796";
     }
     cpu = TRICORE_CPU(cpu_generic_init(TYPE_TRICORE_CPU, machine->cpu_model));
-    if (!cpu) {
-        error_report("Unable to find CPU definition");
-        exit(1);
-    }
     env = &cpu->env;
     memory_region_init_ram(ext_cram, NULL, "powerlink_ext_c.ram",
                            2 * 1024 * 1024, &error_fatal);
index eb9862fa2f7c1d5abd01c0c7c4ad57c4f53b346c..504ea46211e01dac2a3e2a7c49511966ee137e14 100644 (file)
@@ -128,10 +128,6 @@ static void puv3_init(MachineState *machine)
     }
 
     cpu = UNICORE32_CPU(cpu_generic_init(TYPE_UNICORE32_CPU, cpu_model));
-    if (!cpu) {
-        error_report("Unable to find CPU definition");
-        exit(1);
-    }
     env = &cpu->env;
 
     puv3_soc_init(env);
index 1b4767f58b82a88ede7c39a60fd80788dd8b79d5..b3580b11fafef7410aa67a97965ea1c6aef3d9b8 100644 (file)
@@ -85,11 +85,6 @@ static void xtensa_sim_init(MachineState *machine)
 
     for (n = 0; n < smp_cpus; n++) {
         cpu = XTENSA_CPU(cpu_generic_init(TYPE_XTENSA_CPU, cpu_model));
-        if (cpu == NULL) {
-            error_report("unable to find CPU definition '%s'",
-                         cpu_model);
-            exit(EXIT_FAILURE);
-        }
         env = &cpu->env;
 
         env->sregs[PRID] = n;
index 182ec1e31c201f03353ed799c22a41cc0601f19f..a19ccebdba895a08725ee472a5a49732b2db5b41 100644 (file)
@@ -233,11 +233,6 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine)
 
     for (n = 0; n < smp_cpus; n++) {
         cpu = XTENSA_CPU(cpu_generic_init(TYPE_XTENSA_CPU, cpu_model));
-        if (cpu == NULL) {
-            error_report("unable to find CPU definition '%s'",
-                         cpu_model);
-            exit(EXIT_FAILURE);
-        }
         env = &cpu->env;
 
         env->sregs[PRID] = n;
index 885276c0cfd6eccf11f3cd67633acb69837d0964..6d33cf1878aebd6e022e145aa103e50949049ef1 100644 (file)
@@ -661,7 +661,8 @@ CPUState *cpu_create(const char *typename);
  *
  * processes optional parameters and registers them as global properties
  *
- * Returns: type of CPU to create or %NULL if an error occurred.
+ * Returns: type of CPU to create or prints error and terminates process
+ *          if an error occurred.
  */
 const char *cpu_parse_cpu_model(const char *typename, const char *cpu_model);
 
index 03666ef657b9fc904baa72e2e4a5079a7262473e..829f9746626f10010a587a4ee085775ff1eae8f8 100644 (file)
@@ -4323,10 +4323,6 @@ int main(int argc, char **argv, char **envp)
     /* NOTE: we need to init the CPU at this stage to get
        qemu_host_page_size */
     cpu = cpu_init(cpu_model);
-    if (!cpu) {
-        fprintf(stderr, "Unable to find CPU definition\n");
-        exit(EXIT_FAILURE);
-    }
     env = cpu->env_ptr;
     cpu_reset(cpu);
 
index 483f26a5fb847d0de35ff061c275bc8ac9e9834d..94fa8fe0051c2042b17db9bc331ae2991fb78247 100644 (file)
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -62,7 +62,7 @@ CPUState *cpu_create(const char *typename)
     if (err != NULL) {
         error_report_err(err);
         object_unref(OBJECT(cpu));
-        return NULL;
+        exit(EXIT_FAILURE);
     }
     return cpu;
 }
@@ -71,7 +71,6 @@ const char *cpu_parse_cpu_model(const char *typename, const char *cpu_model)
 {
     ObjectClass *oc;
     CPUClass *cc;
-    Error *err = NULL;
     gchar **model_pieces;
     const char *cpu_type;
 
@@ -79,18 +78,15 @@ const char *cpu_parse_cpu_model(const char *typename, const char *cpu_model)
 
     oc = cpu_class_by_name(typename, model_pieces[0]);
     if (oc == NULL) {
+        error_report("unable to find CPU model '%s'", model_pieces[0]);
         g_strfreev(model_pieces);
-        return NULL;
+        exit(EXIT_FAILURE);
     }
 
     cpu_type = object_class_get_name(oc);
     cc = CPU_CLASS(oc);
-    cc->parse_features(cpu_type, model_pieces[1], &err);
+    cc->parse_features(cpu_type, model_pieces[1], &error_fatal);
     g_strfreev(model_pieces);
-    if (err != NULL) {
-        error_report_err(err);
-        return NULL;
-    }
     return cpu_type;
 }
 
@@ -99,12 +95,7 @@ CPUState *cpu_generic_init(const char *typename, const char *cpu_model)
     /* TODO: all callers of cpu_generic_init() need to be converted to
      * call cpu_parse_features() only once, before calling cpu_generic_init().
      */
-    const char *cpu_type = cpu_parse_cpu_model(typename, cpu_model);
-
-    if (cpu_type) {
-        return cpu_create(cpu_type);
-    }
-    return NULL;
+    return cpu_create(cpu_parse_cpu_model(typename, cpu_model));
 }
 
 bool cpu_paging_enabled(const CPUState *cpu)