From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52353) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSqHF-0007MR-Qv for qemu-devel@nongnu.org; Tue, 03 Mar 2015 12:06:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YSqHC-0006sV-AT for qemu-devel@nongnu.org; Tue, 03 Mar 2015 12:06:37 -0500 Received: from mail-we0-f179.google.com ([74.125.82.179]:39619) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSqHC-0006s9-5T for qemu-devel@nongnu.org; Tue, 03 Mar 2015 12:06:34 -0500 Received: by wesx3 with SMTP id x3so41176540wes.6 for ; Tue, 03 Mar 2015 09:06:32 -0800 (PST) From: Ard Biesheuvel Date: Tue, 3 Mar 2015 18:06:20 +0100 Message-Id: <1425402380-10488-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [Qemu-devel] [PATCH] hw/arm/virt: fix cmdline parsing bug with CPU options and smp > 1 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: peter.maydell@linaro.org, qemu-devel@nongnu.org, alex.bennee@linaro.org, greg.bellows@linaro.org Cc: Ard Biesheuvel The recently introduced feature that allows 32 bit guests to be executed under KVM on a 64-bit host incorrectly handles the case where more than 1 cpu is specified using '-smp N' For instance, this invocation of qemu qemu-system-aarch64 -M virt -cpu cortex-a57,aarch64=off -smp 2 produces the following error qemu-system-aarch64: Expected key=value format, found aarch64 which is caused by the destructive parsing performed by cpu_common_parse_features(), resulting in subsequent attempts to parse the CPU option string (for each additional CPU) to fail. So duplicate the string before parsing it, and free it directly afterwards. Signed-off-by: Ard Biesheuvel --- hw/arm/virt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 69f51ac0da58..f8a6c46323dc 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -758,6 +758,7 @@ static void machvirt_init(MachineState *machine) CPUClass *cc = CPU_CLASS(oc); Object *cpuobj; Error *err = NULL; + char *cpuopts = g_strdup(cpustr[1]); if (!oc) { fprintf(stderr, "Unable to find CPU definition\n"); @@ -766,7 +767,8 @@ static void machvirt_init(MachineState *machine) cpuobj = object_new(object_class_get_name(oc)); /* Handle any CPU options specified by the user */ - cc->parse_features(CPU(cpuobj), cpustr[1], &err); + cc->parse_features(CPU(cpuobj), cpuopts, &err); + g_free(cpuopts); if (err) { error_report("%s", error_get_pretty(err)); exit(1); -- 1.8.3.2