From nobody Thu Nov 6 06:39:18 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1536769640870963.8261675957922; Wed, 12 Sep 2018 09:27:20 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA80B30001EE; Wed, 12 Sep 2018 16:27:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ABC6860BE5; Wed, 12 Sep 2018 16:27:18 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5B3404BB7F; Wed, 12 Sep 2018 16:27:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8CGRGaa013977 for ; Wed, 12 Sep 2018 12:27:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 642E863F46; Wed, 12 Sep 2018 16:27:16 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB050FA98D; Wed, 12 Sep 2018 16:27:15 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Wed, 12 Sep 2018 18:19:15 +0200 Message-Id: <1536769155-269737-3-git-send-email-imammedo@redhat.com> In-Reply-To: <1536769155-269737-1-git-send-email-imammedo@redhat.com> References: <1536769155-269737-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com, ehabkost@redhat.com Subject: [libvirt] [PATCH v7 2/2] vl:c: make sure that sockets are calculated correctly in '-smp X' case X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Wed, 12 Sep 2018 16:27:19 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" commit (5cdc9b76e3 vl.c: Remove dead assignment) removed sockets calculation when 'sockets' weren't provided on CLI since there wasn't any users for it back then. Exiting checks are neither reachable } else if (sockets * cores * threads < cpus) { or nor triggable if (sockets * cores * threads > max_cpus) so we weren't noticing wrong topology since then, since users recalculate sockets adhoc on their own. However with deprecation check it becomes noticable, for example -smp 2 will start printing warning: "warning: Invalid CPU topology deprecated: sockets (1) * cores (1) * thre= ads (1) !=3D maxcpus (2)" calculating sockets if they weren't specified. Fix it by returning back sockets calculation if it's omited on CLI. Signed-off-by: Igor Mammedov Reviewed-by: Andrew Jones --- vl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vl.c b/vl.c index 7fd700e..9e56696 100644 --- a/vl.c +++ b/vl.c @@ -1210,11 +1210,14 @@ static void smp_parse(QemuOpts *opts) =20 /* compute missing values, prefer sockets over cores over threads = */ if (cpus =3D=3D 0 || sockets =3D=3D 0) { - sockets =3D sockets > 0 ? sockets : 1; cores =3D cores > 0 ? cores : 1; threads =3D threads > 0 ? threads : 1; if (cpus =3D=3D 0) { + sockets =3D sockets > 0 ? sockets : 1; cpus =3D cores * threads * sockets; + } else { + max_cpus =3D qemu_opt_get_number(opts, "maxcpus", cpus); + sockets =3D max_cpus / (cores * threads); } } else if (cores =3D=3D 0) { threads =3D threads > 0 ? threads : 1; --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list