[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH V2 6/9] NUMA: handle Error in mpol and hostnode pars
From: |
Wanlong Gao |
Subject: |
[Qemu-devel] [PATCH V2 6/9] NUMA: handle Error in mpol and hostnode parser |
Date: |
Fri, 21 Jun 2013 14:25:57 +0800 |
As Paolo pointed out that, handle Error in mpol and hostnode parser
will make it easier to be used for example in mem-hotplug in the future.
And this will be used later in set-mpol QMP command.
Signed-off-by: Wanlong Gao <address@hidden>
---
include/sysemu/sysemu.h | 4 ++++
vl.c | 28 ++++++++++++++++++++++------
2 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 993b8e0..0f135fe 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -144,6 +144,10 @@ struct node_info {
unsigned int flags;
};
extern struct node_info numa_info[MAX_NODES];
+extern void numa_node_parse_mpol(int nodenr, const char *hostnode,
+ Error **errp);
+extern void numa_node_parse_hostnode(int nodenr, const char *hostnode,
+ Error **errp);
#define MAX_OPTION_ROMS 16
typedef struct QEMUOptionRom {
diff --git a/vl.c b/vl.c
index 4dbf5cc..4933d22 100644
--- a/vl.c
+++ b/vl.c
@@ -1382,9 +1382,10 @@ error:
exit(1);
}
-static void numa_node_parse_mpol(int nodenr, const char *mpol)
+void numa_node_parse_mpol(int nodenr, const char *mpol, Error **errp)
{
if (!mpol) {
+ error_setg(errp, "Should specify memory policy");
return;
}
@@ -1395,11 +1396,11 @@ static void numa_node_parse_mpol(int nodenr, const char
*mpol)
} else if (!strcmp(mpol, "membind")) {
numa_info[nodenr].flags |= NODE_HOST_BIND;
} else {
- fprintf(stderr, "qemu: Invalid memory policy: %s\n", mpol);
+ error_setg(errp, "Invalid memory policy: %s", mpol);
}
}
-static void numa_node_parse_hostnode(int nodenr, const char *hostnode)
+void numa_node_parse_hostnode(int nodenr, const char *hostnode, Error **errp)
{
unsigned long long value, endvalue;
char *endptr;
@@ -1452,7 +1453,7 @@ static void numa_node_parse_hostnode(int nodenr, const
char *hostnode)
return;
error:
- fprintf(stderr, "qemu: Invalid host NUMA nodes range: %s\n", hostnode);
+ error_setg(errp, "Invalid host NUMA nodes range: %s", hostnode);
return;
}
@@ -1469,19 +1470,34 @@ static int numa_add_cpus(const char *name, const char
*value, void *opaque)
static int numa_add_mpol(const char *name, const char *value, void *opaque)
{
int *nodenr = opaque;
+ Error *err = NULL;
if (!strcmp(name, "mem-policy")) {
- numa_node_parse_mpol(*nodenr, value);
+ numa_node_parse_mpol(*nodenr, value, &err);
}
+ if (error_is_set(&err)) {
+ fprintf(stderr, "qemu: %s\n", error_get_pretty(err));
+ error_free(err);
+ return -1;
+ }
+
return 0;
}
static int numa_add_hostnode(const char *name, const char *value, void *opaque)
{
int *nodenr = opaque;
+ Error *err = NULL;
+
if (!strcmp(name, "mem-hostnode")) {
- numa_node_parse_hostnode(*nodenr, value);
+ numa_node_parse_hostnode(*nodenr, value, &err);
}
+ if (error_is_set(&err)) {
+ fprintf(stderr, "qemu: %s\n", error_get_pretty(err));
+ error_free(err);
+ return -1;
+ }
+
return 0;
}
--
1.8.3.1.448.gfb7dfaa
- [Qemu-devel] [PATCH V2 0/9] Add support for binding guest numa nodes to host numa nodes, Wanlong Gao, 2013/06/21
- [Qemu-devel] [PATCH V2 1/9] NUMA: Support multiple CPU ranges on -numa option, Wanlong Gao, 2013/06/21
- [Qemu-devel] [PATCH V2 5/9] NUMA: set guest numa nodes memory policy, Wanlong Gao, 2013/06/21
- [Qemu-devel] [PATCH V2 2/9] NUMA: Add numa_info structure to contain numa nodes info, Wanlong Gao, 2013/06/21
- [Qemu-devel] [PATCH V2 7/9] NUMA: add qmp command set-mpol to set memory policy for NUMA node, Wanlong Gao, 2013/06/21
- [Qemu-devel] [PATCH V2 4/9] NUMA: parse guest numa nodes memory policy, Wanlong Gao, 2013/06/21
- [Qemu-devel] [PATCH V2 3/9] NUMA: Add Linux libnuma detection, Wanlong Gao, 2013/06/21
- [Qemu-devel] [PATCH V2 9/9] NUMA: show host memory policy info in info numa command, Wanlong Gao, 2013/06/21
- [Qemu-devel] [PATCH V2 8/9] NUMA: add hmp command set-mpol, Wanlong Gao, 2013/06/21
- [Qemu-devel] [PATCH V2 6/9] NUMA: handle Error in mpol and hostnode parser,
Wanlong Gao <=