[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 03/10] vl.c: Isolate code specific to "-numa node" o
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [PATCH 03/10] vl.c: Isolate code specific to "-numa node" option type |
Date: |
Fri, 11 Jan 2013 16:15:01 -0200 |
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 <address@hidden>
---
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);
--
1.7.11.7
- [Qemu-devel] [PATCH 00/10] -numa option parsing fixes & improvements, Eduardo Habkost, 2013/01/11
- [Qemu-devel] [PATCH 08/10] vl.c: Support multiple CPU ranges on -numa option, Eduardo Habkost, 2013/01/11
- [Qemu-devel] [PATCH 01/10] vl.c: Fix off-by-one bug when handling "-numa node" argument, Eduardo Habkost, 2013/01/11
- [Qemu-devel] [PATCH 06/10] vl.c: handle invalid NUMA CPU ranges properly, Eduardo Habkost, 2013/01/11
- [Qemu-devel] [RFC 09/10] vl.c: Introduce QemuOpts-friendly "-numa-node" config option, Eduardo Habkost, 2013/01/11
- [Qemu-devel] [PATCH 03/10] vl.c: Isolate code specific to "-numa node" option type,
Eduardo Habkost <=
- [Qemu-devel] [PATCH 04/10] vl.c: Check for NUMA node limit inside numa_node_add(), Eduardo Habkost, 2013/01/11
- [Qemu-devel] [PATCH 05/10] vl.c: Extract -numa "cpus" parsing to separate function, Eduardo Habkost, 2013/01/11
- [Qemu-devel] [RFC 10/10] vl.c: Handle legacy "-numa node, cpus=A, B, C, D" format, Eduardo Habkost, 2013/01/11
- [Qemu-devel] [PATCH 02/10] vl.c: Abort on unknown -numa option type, Eduardo Habkost, 2013/01/11
- [Qemu-devel] [PATCH 07/10] vl.c: numa_add_node(): Validate nodeid before using it, Eduardo Habkost, 2013/01/11