From patchwork Wed Jan 16 18:28:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4/8] vl.c: Check for NUMA node limit inside numa_add() Date: Wed, 16 Jan 2013 08:28:49 -0000 From: Eduardo Habkost X-Patchwork-Id: 212941 Message-Id: <1358360933-5323-5-git-send-email-ehabkost@redhat.com> To: qemu-devel@nongnu.org, Anthony Liguori Cc: Chegu Vinod 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 --- 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: