Received: from eggs.gnu.org ([208.118.235.92]:35725) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvXHG-0002PV-Nh for qemu-devel@nongnu.org; Wed, 16 Jan 2013 12:59:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TvX6I-0005TK-8J for qemu-devel@nongnu.org; Wed, 16 Jan 2013 12:48:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3019) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvX6H-0005T7-Tf for qemu-devel@nongnu.org; Wed, 16 Jan 2013 12:48:34 -0500 Date: Wed, 16 Jan 2013 15:50:09 -0200 From: Eduardo Habkost Message-ID: <20130116175008.GE10683@otherpad.lan.raisama.net> References: <1358349851-20960-1-git-send-email-ehabkost@redhat.com> <1358349851-20960-9-git-send-email-ehabkost@redhat.com> <50F6E3B1.4020307@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <50F6E3B1.4020307@redhat.com> Subject: Re: [Qemu-devel] [PATCH 8/8] vl.c: validate -numa "cpus" parameter properly List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Chegu Vinod , qemu-devel@nongnu.org, Anthony Liguori On Wed, Jan 16, 2013 at 10:30:25AM -0700, Eric Blake wrote: > On 01/16/2013 08:24 AM, Eduardo Habkost wrote: > > - Accept empty strings without aborting > > - Use parse_uint*() to parse numbers > > - Abort if anything except '-' or end-of-string is found after the first > > number. > > - Check for endvalue < value > > > > Also change the MAX_CPUMASK_BITS warning message from "A max of %d CPUs > > are supported in a guest" to "qemu: NUMA: A max of %d VCPUs are > > supported". > > > > Signed-off-by: Eduardo Habkost > > --- > > Cc: Eric Blake > > --- > > vl.c | 32 +++++++++++++++++++++++++++----- > > 1 file changed, 27 insertions(+), 5 deletions(-) > > > > > > > - value = strtoull(cpus, &endptr, 10); > > + /* Empty CPU range strings will be considered valid, they will simply > > + * not set any bit in the CPU bitmap. > > + */ > > + if (!*cpus) { > > + return; > > Does the code behave correctly when there are no bits in the CPU bitmap, > or do you require that at least one bit be set? If no bits are set on any node, QEMU will divide the VCPUs equally through all nodes. More exactly, each VCPU (i) would go to NUMA node (i % nb_numa_nodes). It is also possible to build ACPI tables where a node have no CPUs, just RAM regions. It doesn't mean it is a good idea or that guest OSes will be able to handle it properly, but QEMU will do exactly what you asked for. > > > + } > > + > > + if (parse_uint(cpus, &value, &endptr) < 0) { > > + goto error; > > Again, another case of accepting octal where you used to only accept > binary; if the change of interpretation of 010 is intentional, it would > be worth documenting in the commit message. Otherwise, it might be > worth refactoring 1/8 to add a 'base' parameter to parse_uint[_full] to > allow the caller to control whether they want base 0 or base 10. True. Thanks for catching it, again. I plan to take the same approach proposed on my reply to patch 6/8. -- Eduardo