From patchwork Wed Jan 16 15:24:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 212976 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 858A62C0090 for ; Thu, 17 Jan 2013 05:55:10 +1100 (EST) Received: from localhost ([::1]:48579 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvWEJ-0000wZ-9l for incoming@patchwork.ozlabs.org; Wed, 16 Jan 2013 11:52:47 -0500 Received: from eggs.gnu.org ([208.118.235.92]:48391) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvWD3-0007oU-GZ for qemu-devel@nongnu.org; Wed, 16 Jan 2013 11:51:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TvWCx-0005xd-QK for qemu-devel@nongnu.org; Wed, 16 Jan 2013 11:51:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32281) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvWCx-0005wj-9P for qemu-devel@nongnu.org; Wed, 16 Jan 2013 11:51:23 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0GGpLRL028494 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 16 Jan 2013 11:51:21 -0500 Received: from blackpad.lan.raisama.net (vpn1-7-107.gru2.redhat.com [10.97.7.107]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0GGpIvJ009165; Wed, 16 Jan 2013 11:51:19 -0500 Received: by blackpad.lan.raisama.net (Postfix, from userid 500) id DE223201752; Wed, 16 Jan 2013 13:24:13 -0200 (BRST) From: Eduardo Habkost To: qemu-devel@nongnu.org, Anthony Liguori Date: Wed, 16 Jan 2013 13:24:07 -0200 Message-Id: <1358349851-20960-5-git-send-email-ehabkost@redhat.com> In-Reply-To: <1358349851-20960-1-git-send-email-ehabkost@redhat.com> References: <1358349851-20960-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Chegu Vinod Subject: [Qemu-devel] [PATCH 4/8] vl.c: Check for NUMA node limit inside numa_add() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Instead of checking the limit before calling numa_add(), check the limit only when we already know we're going to add a new node. Signed-off-by: Eduardo Habkost --- Changes v2: - Implement the change without adding numa_node_add() function --- vl.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vl.c b/vl.c index 1cf8ba6..dabbba1 100644 --- a/vl.c +++ b/vl.c @@ -1255,6 +1255,12 @@ static void numa_add(const char *optarg) optarg++; } if (!strcmp(option, "node")) { + + if (nb_numa_nodes >= MAX_NODES) { + fprintf(stderr, "qemu: too many NUMA nodes\n"); + exit(1); + } + if (get_param_value(option, 128, "nodeid", optarg) == 0) { nodenr = nb_numa_nodes; } else { @@ -2960,10 +2966,6 @@ int main(int argc, char **argv, char **envp) } break; case QEMU_OPTION_numa: - if (nb_numa_nodes >= MAX_NODES) { - fprintf(stderr, "qemu: too many NUMA nodes\n"); - exit(1); - } numa_add(optarg); break; case QEMU_OPTION_display: