From patchwork Wed Jan 16 15:24:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [7/8] vl.c: Extract -numa "cpus" parsing to separate function Date: Wed, 16 Jan 2013 05:24:10 -0000 From: Eduardo Habkost X-Patchwork-Id: 213038 Message-Id: <1358349851-20960-8-git-send-email-ehabkost@redhat.com> To: qemu-devel@nongnu.org, Anthony Liguori Cc: Chegu Vinod This will make it easier to refactor that code later. Signed-off-by: Eduardo Habkost --- Changes v2: - Implemented change without creation of numa_node_add() function --- vl.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/vl.c b/vl.c index 43ce607..98cf9f0 100644 --- a/vl.c +++ b/vl.c @@ -1241,15 +1241,34 @@ char *get_boot_devices_list(uint32_t *size) return list; } +static void numa_node_parse_cpus(int nodenr, const char *cpus) +{ + char *endptr; + unsigned long long value, endvalue; + + value = strtoull(cpus, &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); +} + static void numa_add(const char *optarg) { char option[128]; char *endptr; - unsigned long long value, endvalue; unsigned long long nodenr; - value = endvalue = 0ULL; - optarg = get_opt_name(option, 128, optarg, ','); if (*optarg == ',') { optarg++; @@ -1287,21 +1306,7 @@ static void numa_add(const char *optarg) 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 { - 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); + numa_node_parse_cpus(nodenr, option); } nb_numa_nodes++; } else {