From patchwork Mon Feb 4 18:27:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 218037 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 EED7D2C02B0 for ; Tue, 5 Feb 2013 05:58:14 +1100 (EST) Received: from localhost ([::1]:46523 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U2QlX-0001Tn-MY for incoming@patchwork.ozlabs.org; Mon, 04 Feb 2013 13:27:39 -0500 Received: from eggs.gnu.org ([208.118.235.92]:52597) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U2QkH-00070n-JK for qemu-devel@nongnu.org; Mon, 04 Feb 2013 13:26:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U2QkC-0002ut-9d for qemu-devel@nongnu.org; Mon, 04 Feb 2013 13:26:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3555) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U2QkC-0002uP-1g for qemu-devel@nongnu.org; Mon, 04 Feb 2013 13:26:16 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r14IQEpf021946 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 4 Feb 2013 13:26:14 -0500 Received: from blackpad.lan.raisama.net (vpn1-7-242.gru2.redhat.com [10.97.7.242]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r14IQDAw031951; Mon, 4 Feb 2013 13:26:14 -0500 Received: by blackpad.lan.raisama.net (Postfix, from userid 500) id 8F7C8203603; Mon, 4 Feb 2013 16:27:59 -0200 (BRST) From: Eduardo Habkost To: Anthony Liguori , qemu-devel@nongnu.org Date: Mon, 4 Feb 2013 16:27:48 -0200 Message-Id: <1360002472-17628-5-git-send-email-ehabkost@redhat.com> In-Reply-To: <1360002472-17628-1-git-send-email-ehabkost@redhat.com> References: <1360002472-17628-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Laszlo Ersek 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 Reviewed-by: Eric Blake --- vl.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vl.c b/vl.c index 586aa9a..89de003 100644 --- a/vl.c +++ b/vl.c @@ -1258,6 +1258,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 { @@ -3003,10 +3009,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: