qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH V5 10/12] NUMA: add hmp command set-mem-policy


From: Wanlong Gao
Subject: [Qemu-devel] [PATCH V5 10/12] NUMA: add hmp command set-mem-policy
Date: Wed, 17 Jul 2013 17:29:31 +0800

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 <address@hidden>
---
 hmp-commands.hx | 16 ++++++++++++++++
 hmp.c           | 36 ++++++++++++++++++++++++++++++++++++
 hmp.h           |  1 +
 3 files changed, 53 insertions(+)

diff --git a/hmp-commands.hx b/hmp-commands.hx
index 8c6b91a..fe3a26f 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -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
address@hidden set-mem-policy @var{nodeid} @var{args}
address@hidden set-mem-policy
+
+Set host memory policy for a guest NUMA node
+
+ETEXI
+
+    {
         .name       = "info",
         .args_type  = "item:s?",
         .params     = "[subcommand]",
diff --git a/hmp.c b/hmp.c
index dc4d8d4..7798339 100644
--- a/hmp.c
+++ b/hmp.c
@@ -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);
+}
diff --git a/hmp.h b/hmp.h
index 6c3bdcd..ae09525 100644
--- a/hmp.h
+++ b/hmp.h
@@ -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
-- 
1.8.3.2.634.g7a3187e




reply via email to

[Prev in Thread] Current Thread [Next in Thread]