From patchwork Fri Jan 11 18:15:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 211396 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 331062C032C for ; Sat, 12 Jan 2013 05:14:55 +1100 (EST) Received: from localhost ([::1]:41244 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ttj81-0003aw-9q for incoming@patchwork.ozlabs.org; Fri, 11 Jan 2013 13:14:53 -0500 Received: from eggs.gnu.org ([208.118.235.92]:46034) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ttj6w-0001Ts-Ic for qemu-devel@nongnu.org; Fri, 11 Jan 2013 13:13:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ttj6p-00032A-Sq for qemu-devel@nongnu.org; Fri, 11 Jan 2013 13:13:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55048) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ttj6p-00031d-Lp for qemu-devel@nongnu.org; Fri, 11 Jan 2013 13:13:39 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0BIDbqW018372 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 11 Jan 2013 13:13:37 -0500 Received: from blackpad.lan.raisama.net (vpn1-7-42.gru2.redhat.com [10.97.7.42]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0BIDa6e022359; Fri, 11 Jan 2013 13:13:37 -0500 Received: by blackpad.lan.raisama.net (Postfix, from userid 500) id 3EC812014A2; Fri, 11 Jan 2013 16:15:18 -0200 (BRST) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 11 Jan 2013 16:15:01 -0200 Message-Id: <1357928108-21066-4-git-send-email-ehabkost@redhat.com> In-Reply-To: <1357928108-21066-1-git-send-email-ehabkost@redhat.com> References: <1357928108-21066-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: libvir-list@redhat.com, Chegu Vinod , Anthony Liguori Subject: [Qemu-devel] [PATCH 03/10] vl.c: Isolate code specific to "-numa node" option type 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 Extract the code that's specific for the "node" -numa option type (the only one, today) to a separate function. The extracted code will eventually become a function specific for a "numa-node" config section, independent from the numa_add() code. Signed-off-by: Eduardo Habkost --- vl.c | 75 +++++++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/vl.c b/vl.c index 042cc7f..94cc6fd 100644 --- a/vl.c +++ b/vl.c @@ -1052,7 +1052,7 @@ char *get_boot_devices_list(uint32_t *size) return list; } -static void numa_add(const char *optarg) +static void numa_node_add(const char *optarg) { char option[128]; char *endptr; @@ -1061,46 +1061,53 @@ static void numa_add(const char *optarg) value = endvalue = 0ULL; - optarg = get_opt_name(option, 128, optarg, ','); - if (*optarg == ',') { - optarg++; + if (get_param_value(option, 128, "nodeid", optarg) == 0) { + nodenr = nb_numa_nodes; + } else { + nodenr = strtoull(option, NULL, 10); } - if (!strcmp(option, "node")) { - if (get_param_value(option, 128, "nodeid", optarg) == 0) { - nodenr = nb_numa_nodes; + + if (get_param_value(option, 128, "mem", optarg) == 0) { + node_mem[nodenr] = 0; + } else { + int64_t sval; + sval = strtosz(option, &endptr); + if (sval < 0 || *endptr) { + fprintf(stderr, "qemu: invalid numa mem size: %s\n", optarg); + exit(1); + } + node_mem[nodenr] = sval; + } + if (get_param_value(option, 128, "cpus", optarg) != 0) { + value = strtoull(option, &endptr, 10); + if (*endptr == '-') { + endvalue = strtoull(endptr+1, &endptr, 10); } else { - nodenr = strtoull(option, NULL, 10); + endvalue = value; } - if (get_param_value(option, 128, "mem", optarg) == 0) { - node_mem[nodenr] = 0; - } else { - int64_t sval; - sval = strtosz(option, &endptr); - if (sval < 0 || *endptr) { - fprintf(stderr, "qemu: invalid numa mem size: %s\n", optarg); - exit(1); - } - node_mem[nodenr] = sval; + if (!(endvalue < MAX_CPUMASK_BITS)) { + endvalue = MAX_CPUMASK_BITS - 1; + fprintf(stderr, + "A max of %d CPUs are supported in a guest\n", + MAX_CPUMASK_BITS); } - if (get_param_value(option, 128, "cpus", optarg) != 0) { - value = strtoull(option, &endptr, 10); - if (*endptr == '-') { - endvalue = strtoull(endptr+1, &endptr, 10); - } else { - endvalue = value; - } - if (!(endvalue < MAX_CPUMASK_BITS)) { - endvalue = MAX_CPUMASK_BITS - 1; - fprintf(stderr, - "A max of %d CPUs are supported in a guest\n", - MAX_CPUMASK_BITS); - } + bitmap_set(node_cpumask[nodenr], value, endvalue-value+1); + } + nb_numa_nodes++; +} - bitmap_set(node_cpumask[nodenr], value, endvalue-value+1); - } - nb_numa_nodes++; +static void numa_add(const char *optarg) +{ + char option[128]; + + optarg = get_opt_name(option, 128, optarg, ','); + if (*optarg == ',') { + optarg++; + } + if (!strcmp(option, "node")) { + numa_node_add(optarg); } else { fprintf(stderr, "Invalid -numa option: %s\n", option); exit(1);