@@ -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 {
@@ -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;
}
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 <gaowanlong@cn.fujitsu.com> --- include/sysemu/sysemu.h | 4 ++++ vl.c | 28 ++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-)