From patchwork Tue Jun 1 23:03:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: pc: push setting default cpu_model down a level Date: Tue, 01 Jun 2010 13:03:00 -0000 From: Alex Williamson X-Patchwork-Id: 54333 Message-Id: <20100601230235.14944.69041.stgit@localhost.localdomain> To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, kvm@vger.kernel.org Not that CPU hotplug currently works, but if you make the mistake of trying it on a VM started without specifying a -cpu value, you hit a segfault from trying to strdup(NULL) in cpu_x86_find_by_name(). Signed-off-by: Alex Williamson --- hw/pc.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/pc.c b/hw/pc.c index 9b85c42..a79586c 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -771,6 +771,14 @@ static CPUState *pc_new_cpu(const char *cpu_model) { CPUState *env; + if (cpu_model == NULL) { +#ifdef TARGET_X86_64 + cpu_model = "qemu64"; +#else + cpu_model = "qemu32"; +#endif + } + env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find x86 CPU definition\n"); @@ -791,14 +799,6 @@ void pc_cpus_init(const char *cpu_model) int i; /* init CPUs */ - if (cpu_model == NULL) { -#ifdef TARGET_X86_64 - cpu_model = "qemu64"; -#else - cpu_model = "qemu32"; -#endif - } - for(i = 0; i < smp_cpus; i++) { pc_new_cpu(cpu_model); }