From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiACi-0008N9-MQ for qemu-devel@nongnu.org; Wed, 07 May 2014 18:20:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WiACb-0003Dr-6J for qemu-devel@nongnu.org; Wed, 07 May 2014 18:20:44 -0400 Received: from cantor2.suse.de ([195.135.220.15]:40282 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiACa-0003CI-Vz for qemu-devel@nongnu.org; Wed, 07 May 2014 18:20:37 -0400 Message-ID: <536AB1B2.4030709@suse.de> Date: Thu, 08 May 2014 00:20:34 +0200 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <1399493987-14285-1-git-send-email-ehabkost@redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] vl.c: Check max_cpus limit instead of smp_cpus List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell , Eduardo Habkost Cc: Igor Mammedov , Marcelo Tosatti , QEMU Developers , Anthony Liguori Am 07.05.2014 23:48, schrieb Peter Maydell: > On 7 May 2014 21:19, Eduardo Habkost wrote: >> If a given machine have max_cpus set, not just smp_cpus needs to be >> limited, but the total number of CPUs (considering CPU hotplug) for th= e >> machine. >> >> As smp_parse() already ensures smp_cpus <=3D max_cpus, we just need to >> check if max_cpus exceeds the limit. >> >> Signed-off-by: Eduardo Habkost >> --- >> vl.c | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/vl.c b/vl.c >> index 236f95e..e317cc9 100644 >> --- a/vl.c >> +++ b/vl.c >> @@ -4039,9 +4039,9 @@ int main(int argc, char **argv, char **envp) >> smp_parse(qemu_opts_find(qemu_find_opts("smp-opts"), NULL)); >> >> machine->max_cpus =3D machine->max_cpus ?: 1; /* Default to UP */ >> - if (smp_cpus > machine->max_cpus) { >> - fprintf(stderr, "Number of SMP cpus requested (%d), exceeds m= ax cpus " >> - "supported by machine `%s' (%d)\n", smp_cpus, machin= e->name, >> + if (max_cpus > machine->max_cpus) { >> + fprintf(stderr, "Total number of CPUs (%d), exceeds maximum " >> + "supported by machine `%s' (%d)\n", max_cpus, machin= e->name, >> machine->max_cpus); >> exit(1); >=20 >=20 > This is confusing. What is max_cpus Specified via -smp, defaults to actual CPUs. > and why do we not > just set max_cpus =3D machine->max_cpus ? For the PC, machine->max_cpus specifies the technical (APIC/ACPI/...) upper limit, whereas -smp limits it to saner values. If you think KVM, then many machines today will have less than the maximum number of CPUs and you may want to run multiple VMs and you may not want their vCPUs competing too much for existing CPUs, so a limit makes sense. An interesting question for the 2.x era would be whether we may want to change the default from no hot-add to machine maximum - does recent libvirt specify max_cpus by default? Regards, Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=C3=B6rffer; HRB 16746 AG N=C3=BC= rnberg