diff options
author | Eduardo Habkost <ehabkost@redhat.com> | 2013-02-04 16:27:51 -0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2013-02-04 14:38:34 -0600 |
commit | 845e5bf9cd49873c72f84796cabf107c3f520f37 (patch) | |
tree | 0f319050e1c247fd0abdd9e36b83de2a8ec0e2df /vl.c | |
parent | 5f1399651eaab1b04e49107250d182968a227aa6 (diff) |
vl.c: Extract -numa "cpus" parsing to separate function
This will make it easier to refactor that code later.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'vl.c')
-rw-r--r-- | vl.c | 41 |
1 files changed, 23 insertions, 18 deletions
@@ -1244,15 +1244,34 @@ char *get_boot_devices_list(size_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++; @@ -1290,21 +1309,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 { |