qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Wanlong Gao <gaowanlong@cn.fujitsu.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com, ehabkost@redhat.com, lersek@redhat.com,
	peter.huangpeng@huawei.com, lcapitulino@redhat.com,
	drjones@redhat.com, bsd@redhat.com, hutao@cn.fujitsu.com,
	y-goto@jp.fujitsu.com, pbonzini@redhat.com, afaerber@suse.de,
	gaowanlong@cn.fujitsu.com
Subject: [Qemu-devel] [PATCH V12 13/13] NUMA: convert hmp command info_numa to use qmp command query_numa
Date: Wed, 4 Sep 2013 17:03:42 +0800	[thread overview]
Message-ID: <1378285422-7361-14-git-send-email-gaowanlong@cn.fujitsu.com> (raw)
In-Reply-To: <1378285422-7361-1-git-send-email-gaowanlong@cn.fujitsu.com>

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
---
 hmp.c     | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 hmp.h     |  1 +
 monitor.c | 21 +--------------------
 3 files changed, 56 insertions(+), 20 deletions(-)

diff --git a/hmp.c b/hmp.c
index ae695b0..2d878c6 100644
--- a/hmp.c
+++ b/hmp.c
@@ -27,6 +27,7 @@
 #include "qapi-visit.h"
 #include "qapi/opts-visitor.h"
 #include "qapi/dealloc-visitor.h"
+#include "sysemu/sysemu.h"
 
 static void hmp_handle_error(Monitor *mon, Error **errp)
 {
@@ -1579,3 +1580,56 @@ error:
 
     hmp_handle_error(mon, &local_err);
 }
+
+void hmp_info_numa(Monitor *mon, const QDict *qdict)
+{
+    NUMAInfoList *node_list, *node;
+    uint16List *head;
+    int nodeid;
+    char *policy_str = NULL;
+
+    node_list = qmp_query_numa(NULL);
+
+    monitor_printf(mon, "%d nodes\n", nb_numa_nodes);
+    for (node = node_list; node; node = node->next) {
+        nodeid = node->value->nodeid;
+        monitor_printf(mon, "node %d cpus:", nodeid);
+        head = node->value->cpus;
+        for (head = node->value->cpus; head != NULL; head = head->next) {
+            monitor_printf(mon, " %d", (int)head->value);
+        }
+        monitor_printf(mon, "\n");
+        monitor_printf(mon, "node %d size: %" PRId64 " MB\n",
+                       nodeid, node->value->memory >> 20);
+        switch (node->value->policy) {
+        case NUMA_NODE_POLICY_DEFAULT:
+            policy_str = g_strdup("default");
+            break;
+        case NUMA_NODE_POLICY_PREFERRED:
+            policy_str = g_strdup("preferred");
+            break;
+        case NUMA_NODE_POLICY_MEMBIND:
+            policy_str = g_strdup("membind");
+            break;
+        case NUMA_NODE_POLICY_INTERLEAVE:
+            policy_str = g_strdup("interleave");
+            break;
+        default:
+            break;
+        }
+        monitor_printf(mon, "node %d policy: %s\n",
+                       nodeid, policy_str ? : " ");
+        if (policy_str) {
+            free(policy_str);
+        }
+        monitor_printf(mon, "node %d relative: %s\n", nodeid,
+                       node->value->relative ? "true" : "false");
+        monitor_printf(mon, "node %d host-nodes:", nodeid);
+        for (head = node->value->host_nodes; head != NULL; head = head->next) {
+            monitor_printf(mon, " %d", (int)head->value);
+        }
+        monitor_printf(mon, "\n");
+    }
+
+    qapi_free_NUMAInfoList(node_list);
+}
diff --git a/hmp.h b/hmp.h
index ae09525..56a5efd 100644
--- a/hmp.h
+++ b/hmp.h
@@ -37,6 +37,7 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict);
 void hmp_info_pci(Monitor *mon, const QDict *qdict);
 void hmp_info_block_jobs(Monitor *mon, const QDict *qdict);
 void hmp_info_tpm(Monitor *mon, const QDict *qdict);
+void hmp_info_numa(Monitor *mon, const QDict *qdict);
 void hmp_quit(Monitor *mon, const QDict *qdict);
 void hmp_stop(Monitor *mon, const QDict *qdict);
 void hmp_system_reset(Monitor *mon, const QDict *qdict);
diff --git a/monitor.c b/monitor.c
index be34488..ce9dfe7 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1995,25 +1995,6 @@ static void do_info_mtree(Monitor *mon, const QDict *qdict)
     mtree_info((fprintf_function)monitor_printf, mon);
 }
 
-static void do_info_numa(Monitor *mon, const QDict *qdict)
-{
-    int i;
-    CPUState *cpu;
-
-    monitor_printf(mon, "%d nodes\n", nb_numa_nodes);
-    for (i = 0; i < nb_numa_nodes; i++) {
-        monitor_printf(mon, "node %d cpus:", i);
-        CPU_FOREACH(cpu) {
-            if (cpu->numa_node == i) {
-                monitor_printf(mon, " %d", cpu->cpu_index);
-            }
-        }
-        monitor_printf(mon, "\n");
-        monitor_printf(mon, "node %d size: %" PRId64 " MB\n", i,
-            numa_info[i].node_mem >> 20);
-    }
-}
-
 #ifdef CONFIG_PROFILER
 
 int64_t qemu_time;
@@ -2781,7 +2762,7 @@ static mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show NUMA information",
-        .mhandler.cmd = do_info_numa,
+        .mhandler.cmd = hmp_info_numa,
     },
     {
         .name       = "usb",
-- 
1.8.4.21.g992c386

  parent reply	other threads:[~2013-09-04  9:05 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-04  9:03 [Qemu-devel] [PATCH V12 00/13] Add support for binding guest numa nodes to host numa nodes Wanlong Gao
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 01/13] NUMA: move numa related code to new file numa.c Wanlong Gao
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 02/13] NUMA: check if the total numa memory size is equal to ram_size Wanlong Gao
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 03/13] NUMA: Add numa_info structure to contain numa nodes info Wanlong Gao
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 04/13] NUMA: convert -numa option to use OptsVisitor Wanlong Gao
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 05/13] NUMA: introduce NumaMemOptions Wanlong Gao
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 06/13] NUMA: add "-numa mem," options Wanlong Gao
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 07/13] NUMA: expand MAX_NODES from 64 to 128 Wanlong Gao
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 08/13] NUMA: parse guest numa nodes memory policy Wanlong Gao
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 09/13] NUMA: set " Wanlong Gao
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 10/13] NUMA: add qmp command set-mem-policy to set memory policy for NUMA node Wanlong Gao
2013-09-09 21:02   ` Luiz Capitulino
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 11/13] NUMA: add hmp command set-mem-policy Wanlong Gao
2013-09-10 13:36   ` Luiz Capitulino
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 12/13] NUMA: add qmp command query-numa Wanlong Gao
2013-09-10 13:50   ` Luiz Capitulino
2013-09-04  9:03 ` Wanlong Gao [this message]
2013-09-10 14:03   ` [Qemu-devel] [PATCH V12 13/13] NUMA: convert hmp command info_numa to use qmp command query_numa Luiz Capitulino
2013-09-09  6:59 ` [Qemu-devel] [PATCH V12 00/13] Add support for binding guest numa nodes to host numa nodes Wanlong Gao

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=1378285422-7361-14-git-send-email-gaowanlong@cn.fujitsu.com \
    --to=gaowanlong@cn.fujitsu.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=bsd@redhat.com \
    --cc=drjones@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=hutao@cn.fujitsu.com \
    --cc=lcapitulino@redhat.com \
    --cc=lersek@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=y-goto@jp.fujitsu.com \
    /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).