From nobody Mon Nov 10 19:44:26 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1558271103; cv=none; d=zoho.com; s=zohoarc; b=DALBzt1l2QGnAtYSAMa5OS3zXdWmWGJLtq0U+u7NYHqgkiv1voHTROcjJeoC3pKJN/bi3Xu+XpkQeZe+6ll0StymYyM85OZnH+ml20P3bbOzaQpkTuT9LmbaMH8udgQJnyOSarmECPA9iYSJSHZ3bRf0pLBzP4cGVR9qZbo++AM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558271103; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=z3KCml62A2bosmO64rDVD/hJZgVTBXU7KViYJJbyccM=; b=AFP+cNtfDvzscfWlD9gdkmB5FmFYRWGBmk1v9aaxGN8oCOBmC9pXpf+c3zkhl0BZ2W7solSG5K2xlecUAKfuIOjYKXtCuLvhITefklzObCV1xfAiqX4X5XZC/NSixvQaF9zugKHhfM3M+MRGlW83hytp7vuCdR0C8KpUC9YFRYQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15582711033031016.3228600926124; Sun, 19 May 2019 06:05:03 -0700 (PDT) Received: from localhost ([127.0.0.1]:48515 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSLUU-000629-Q6 for importer@patchew.org; Sun, 19 May 2019 09:04:38 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44621) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSLMh-0007x4-FJ for qemu-devel@nongnu.org; Sun, 19 May 2019 08:56:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSLMg-0002K8-93 for qemu-devel@nongnu.org; Sun, 19 May 2019 08:56:35 -0400 Received: from mga14.intel.com ([192.55.52.115]:2557) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hSLMd-0002Di-5b; Sun, 19 May 2019 08:56:31 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 May 2019 05:56:30 -0700 Received: from clx-ap-likexu.sh.intel.com ([10.239.48.98]) by fmsmga001.fm.intel.com with ESMTP; 19 May 2019 05:56:29 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 From: Like Xu To: qemu-trivial@nongnu.org Date: Sun, 19 May 2019 04:54:28 +0800 Message-Id: <20190518205428.90532-11-like.xu@linux.intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190518205428.90532-1-like.xu@linux.intel.com> References: <20190518205428.90532-1-like.xu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.115 Subject: [Qemu-devel] [PATCH v3 10/10] vl.c: Replace smp global variables with smp machine properties 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: Peter Maydell , Eduardo Habkost , qemu-devel@nongnu.org, "Dr . David Alan Gilbert" , Alistair Francis , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The global smp variables in vl.c are completely replaced with machine prope= rties. Form this commit, the smp_cpus/smp_cores/smp_threads/max_cpus are deprecated and only machine properties within MachineState are fully applied and enabl= ed. Signed-off-by: Like Xu Reviewed-by: Alistair Francis Reviewed-by: Eduardo Habkost --- vl.c | 53 ++++++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/vl.c b/vl.c index 15d519e371..a700c93c77 100644 --- a/vl.c +++ b/vl.c @@ -162,10 +162,6 @@ static Chardev **serial_hds; Chardev *parallel_hds[MAX_PARALLEL_PORTS]; int win2k_install_hack =3D 0; int singlestep =3D 0; -int smp_cpus; -unsigned int max_cpus; -int smp_cores =3D 1; -int smp_threads =3D 1; int acpi_enabled =3D 1; int no_hpet =3D 0; int fd_bootchk =3D 1; @@ -1282,8 +1278,9 @@ static void smp_parse(QemuOpts *opts) 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); + current_machine->smp.max_cpus =3D + qemu_opt_get_number(opts, "maxcpus", cpus); + sockets =3D current_machine->smp.max_cpus / (cores * threa= ds); } } else if (cores =3D=3D 0) { threads =3D threads > 0 ? threads : 1; @@ -1300,34 +1297,37 @@ static void smp_parse(QemuOpts *opts) exit(1); } =20 - max_cpus =3D qemu_opt_get_number(opts, "maxcpus", cpus); + current_machine->smp.max_cpus =3D + qemu_opt_get_number(opts, "maxcpus", cpus); =20 - if (max_cpus < cpus) { + if (current_machine->smp.max_cpus < cpus) { error_report("maxcpus must be equal to or greater than smp"); exit(1); } =20 - if (sockets * cores * threads > max_cpus) { + if (sockets * cores * threads > current_machine->smp.max_cpus) { error_report("cpu topology: " "sockets (%u) * cores (%u) * threads (%u) > " "maxcpus (%u)", - sockets, cores, threads, max_cpus); + sockets, cores, threads, + current_machine->smp.max_cpus); exit(1); } =20 - if (sockets * cores * threads !=3D max_cpus) { + if (sockets * cores * threads !=3D current_machine->smp.max_cpus) { warn_report("Invalid CPU topology deprecated: " "sockets (%u) * cores (%u) * threads (%u) " "!=3D maxcpus (%u)", - sockets, cores, threads, max_cpus); + sockets, cores, threads, + current_machine->smp.max_cpus); } =20 - smp_cpus =3D cpus; - smp_cores =3D cores; - smp_threads =3D threads; + current_machine->smp.cpus =3D cpus; + current_machine->smp.cores =3D cores; + current_machine->smp.threads =3D threads; } =20 - if (smp_cpus > 1) { + if (current_machine->smp.cpus > 1) { Error *blocker =3D NULL; error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "smp"); replay_add_blocker(blocker); @@ -4128,26 +4128,25 @@ int main(int argc, char **argv, char **envp) machine_class->default_cpus =3D machine_class->default_cpus ?: 1; =20 /* default to machine_class->default_cpus */ - smp_cpus =3D machine_class->default_cpus; - max_cpus =3D machine_class->default_cpus; + current_machine->smp.cpus =3D machine_class->default_cpus; + current_machine->smp.max_cpus =3D machine_class->default_cpus; + current_machine->smp.cores =3D 1; + current_machine->smp.threads =3D 1; =20 smp_parse(qemu_opts_find(qemu_find_opts("smp-opts"), NULL)); =20 - current_machine->smp.cpus =3D smp_cpus; - current_machine->smp.max_cpus =3D max_cpus; - current_machine->smp.cores =3D smp_cores; - current_machine->smp.threads =3D smp_threads; - /* sanity-check smp_cpus and max_cpus against machine_class */ - if (smp_cpus < machine_class->min_cpus) { + if (current_machine->smp.cpus < machine_class->min_cpus) { error_report("Invalid SMP CPUs %d. The min CPUs " - "supported by machine '%s' is %d", smp_cpus, + "supported by machine '%s' is %d", + current_machine->smp.cpus, machine_class->name, machine_class->min_cpus); exit(1); } - if (max_cpus > machine_class->max_cpus) { + if (current_machine->smp.max_cpus > machine_class->max_cpus) { error_report("Invalid SMP CPUs %d. The max CPUs " - "supported by machine '%s' is %d", max_cpus, + "supported by machine '%s' is %d", + current_machine->smp.max_cpus, machine_class->name, machine_class->max_cpus); exit(1); } --=20 2.21.0