From patchwork Tue Jun 21 16:34:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 70575 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp2108992qgy; Tue, 21 Jun 2016 09:35:53 -0700 (PDT) X-Received: by 10.237.33.69 with SMTP id 63mr9617583qtc.45.1466526953102; Tue, 21 Jun 2016 09:35:53 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [208.118.235.17]) by mx.google.com with ESMTPS id 3si450113qkk.272.2016.06.21.09.35.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 21 Jun 2016 09:35:53 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:52977 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFOeW-0004P5-Mh for patch@linaro.org; Tue, 21 Jun 2016 12:35:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFOcu-0002gt-Iu for qemu-devel@nongnu.org; Tue, 21 Jun 2016 12:34:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bFOcs-00056I-KR for qemu-devel@nongnu.org; Tue, 21 Jun 2016 12:34:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36576) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFOcs-00056D-Ec for qemu-devel@nongnu.org; Tue, 21 Jun 2016 12:34:10 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F2D57A325C for ; Tue, 21 Jun 2016 16:34:09 +0000 (UTC) Received: from hawk.localdomain.com (dhcp-1-122.brq.redhat.com [10.34.1.122]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5LGY8XB018558; Tue, 21 Jun 2016 12:34:08 -0400 From: Andrew Jones To: qemu-devel@nongnu.org Date: Tue, 21 Jun 2016 18:34:04 +0200 Message-Id: <1466526844-29245-1-git-send-email-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 21 Jun 2016 16:34:10 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] vl: smp_parse: fix regression X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Commit 0544edd88a "vl: smp_parse: cleanups" regressed any -smp config that left either cores or threads unspecified, and specified a topology supporting more cpus than the given online cpus. The correct way to calculate the missing parameter would be to use maxcpus, but it's too late to change that now. Restore the old way, which is to calculate it with the online cpus (as is still done), but then, if the result is zero, just set it to one. Signed-off-by: Andrew Jones --- vl.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.4.11 diff --git a/vl.c b/vl.c index c85833a63c28e..b2137ca87078d 100644 --- a/vl.c +++ b/vl.c @@ -1234,8 +1234,10 @@ static void smp_parse(QemuOpts *opts) } else if (cores == 0) { threads = threads > 0 ? threads : 1; cores = cpus / (sockets * threads); + cores = cores > 0 ? cores : 1; } else if (threads == 0) { threads = cpus / (cores * sockets); + threads = threads > 0 ? threads : 1; } else if (sockets * cores * threads < cpus) { error_report("cpu topology: " "sockets (%u) * cores (%u) * threads (%u) < "