From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: libvir-list@redhat.com, Chegu Vinod <chegu_vinod@hp.com>,
Anthony Liguori <anthony@codemonkey.ws>
Subject: [Qemu-devel] [PATCH 05/10] vl.c: Extract -numa "cpus" parsing to separate function
Date: Fri, 11 Jan 2013 16:15:03 -0200 [thread overview]
Message-ID: <1357928108-21066-6-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1357928108-21066-1-git-send-email-ehabkost@redhat.com>
This will make it easier to refactor that code later.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
vl.c | 40 ++++++++++++++++++++++------------------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/vl.c b/vl.c
index 2c3bbb9..03a826e 100644
--- a/vl.c
+++ b/vl.c
@@ -1052,15 +1052,33 @@ 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_node_add(const char *optarg)
{
char option[128];
char *endptr;
- unsigned long long value, endvalue;
int nodenr;
- value = endvalue = 0ULL;
-
if (nb_numa_nodes >= MAX_NODES) {
fprintf(stderr, "qemu: too many NUMA nodes\n");
exit(1);
@@ -1084,21 +1102,7 @@ static void numa_node_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++;
}
--
1.7.11.7
next prev parent reply other threads:[~2013-01-11 18:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-11 18:14 [Qemu-devel] [PATCH 00/10] -numa option parsing fixes & improvements Eduardo Habkost
2013-01-11 18:14 ` [Qemu-devel] [PATCH 01/10] vl.c: Fix off-by-one bug when handling "-numa node" argument Eduardo Habkost
2013-01-11 18:15 ` [Qemu-devel] [PATCH 02/10] vl.c: Abort on unknown -numa option type Eduardo Habkost
2013-01-11 18:15 ` [Qemu-devel] [PATCH 03/10] vl.c: Isolate code specific to "-numa node" " Eduardo Habkost
2013-01-11 21:06 ` [Qemu-devel] [libvirt] " Eric Blake
2013-01-11 21:19 ` Eduardo Habkost
2013-01-11 18:15 ` [Qemu-devel] [PATCH 04/10] vl.c: Check for NUMA node limit inside numa_node_add() Eduardo Habkost
2013-01-11 18:15 ` Eduardo Habkost [this message]
2013-01-11 18:15 ` [Qemu-devel] [PATCH 06/10] vl.c: handle invalid NUMA CPU ranges properly Eduardo Habkost
2013-01-11 21:32 ` [Qemu-devel] [libvirt] " Eric Blake
2013-01-14 13:30 ` Eduardo Habkost
2013-01-11 18:15 ` [Qemu-devel] [PATCH 07/10] vl.c: numa_add_node(): Validate nodeid before using it Eduardo Habkost
2013-01-11 18:15 ` [Qemu-devel] [PATCH 08/10] vl.c: Support multiple CPU ranges on -numa option Eduardo Habkost
2013-01-11 18:15 ` [Qemu-devel] [RFC 09/10] vl.c: Introduce QemuOpts-friendly "-numa-node" config option Eduardo Habkost
2013-01-11 18:15 ` [Qemu-devel] [RFC 10/10] vl.c: Handle legacy "-numa node, cpus=A, B, C, D" format Eduardo Habkost
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1357928108-21066-6-git-send-email-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=chegu_vinod@hp.com \
--cc=libvir-list@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).