@@ -1587,6 +1587,22 @@ Executes a qemu-io command on the given block device.
ETEXI
{
+ .name = "set-mem-policy",
+ .args_type = "nodeid:i,args:s?",
+ .params = "nodeid [args]",
+ .help = "set host memory policy for a guest NUMA node",
+ .mhandler.cmd = hmp_set_mem_policy,
+ },
+
+STEXI
+@item set-mem-policy @var{nodeid} @var{args}
+@findex set-mem-policy
+
+Set host memory policy for a guest NUMA node
+
+ETEXI
+
+ {
.name = "info",
.args_type = "item:s?",
.params = "[subcommand]",
@@ -1510,3 +1510,39 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict)
hmp_handle_error(mon, &err);
}
+
+void hmp_set_mem_policy(Monitor *mon, const QDict *qdict)
+{
+ Error *local_err = NULL;
+ bool has_policy = true;
+ bool has_host_nodes = true;
+ const char *policy = NULL;
+ const char *host_nodes = NULL;
+ QemuOpts *opts;
+
+ uint64_t nodeid = qdict_get_int(qdict, "nodeid");
+ const char *args = qdict_get_try_str(qdict, "args");
+
+ if (args == NULL) {
+ has_policy = false;
+ has_host_nodes = false;
+ } else {
+ opts = qemu_opts_parse(qemu_find_opts("numa"), args, 1);
+ if (opts == NULL) {
+ monitor_printf(mon, "Parsing memory policy args failed\n");
+ return;
+ } else {
+ policy = qemu_opt_get(opts, "policy");
+ if (policy == NULL) {
+ has_policy = false;
+ }
+ host_nodes = qemu_opt_get(opts, "hostnode");
+ if (host_nodes == NULL) {
+ has_host_nodes = false;
+ }
+ }
+ }
+
+ qmp_set_mem_policy(nodeid, has_policy, policy, has_host_nodes, host_nodes, &local_err);
+ hmp_handle_error(mon, &local_err);
+}
@@ -87,5 +87,6 @@ void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict);
void hmp_chardev_add(Monitor *mon, const QDict *qdict);
void hmp_chardev_remove(Monitor *mon, const QDict *qdict);
void hmp_qemu_io(Monitor *mon, const QDict *qdict);
+void hmp_set_mem_policy(Monitor *mon, const QDict *qdict);
#endif
Add hmp command set-mem-policy to set host memory policy for a guest NUMA node. Then we can also set node's memory policy using the monitor command like: (qemu) set-mem-policy 0 policy=membind,host-nodes=0-1 Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> --- hmp-commands.hx | 16 ++++++++++++++++ hmp.c | 36 ++++++++++++++++++++++++++++++++++++ hmp.h | 1 + 3 files changed, 53 insertions(+)