[PATCH v2] qmp: Report page size in query-memory-size-summary

Andrei Gudkov via posted 1 patch 10 months ago
Failed in applying to current master (apply log)
qapi/machine.json          | 8 ++++++--
hw/core/machine-qmp-cmds.c | 3 +++
2 files changed, 9 insertions(+), 2 deletions(-)
[PATCH v2] qmp: Report page size in query-memory-size-summary
Posted by Andrei Gudkov via 10 months ago
Some commands (query-migrate and calc-dirty-rate) report values
in units of pages. However, currently the only place where we can
get page size is through query-migrate and only after migration
has started. query-memory-size-summary seems like an appropritate
place where it should be reported instead.

Signed-off-by: Andrei Gudkov <gudkov.andrei@huawei.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 qapi/machine.json          | 8 ++++++--
 hw/core/machine-qmp-cmds.c | 3 +++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/qapi/machine.json b/qapi/machine.json
index 37660d8f2a..b53afc1352 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -1125,10 +1125,13 @@
 #     field is omitted if target doesn't support memory hotplug (i.e.
 #     CONFIG_MEM_DEVICE not defined at build time).
 #
+# @page-size: size of target page in bytes (since 8.1)
+#
 # Since: 2.11
 ##
 { 'struct': 'MemoryInfo',
-  'data'  : { 'base-memory': 'size', '*plugged-memory': 'size' } }
+  'data'  : { 'base-memory': 'size', '*plugged-memory': 'size',
+              'page-size': 'size' } }
 
 ##
 # @query-memory-size-summary:
@@ -1139,7 +1142,8 @@
 # Example:
 #
 # -> { "execute": "query-memory-size-summary" }
-# <- { "return": { "base-memory": 4294967296, "plugged-memory": 0 } }
+# <- { "return": { "page-size": 4096, "base-memory": 34359738368,
+#      "plugged-memory": 0 } }
 #
 # Since: 2.11
 ##
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index 3860a50c3b..b768ff372f 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -27,6 +27,7 @@
 #include "sysemu/numa.h"
 #include "sysemu/runstate.h"
 #include "sysemu/sysemu.h"
+#include "exec/target_page.h"
 
 /*
  * fast means: we NEVER interrupt vCPU threads to retrieve
@@ -289,6 +290,8 @@ MemoryInfo *qmp_query_memory_size_summary(Error **errp)
     mem_info->has_plugged_memory =
         mem_info->plugged_memory != (uint64_t)-1;
 
+    mem_info->page_size = qemu_target_page_size();
+
     return mem_info;
 }
 
-- 
2.30.2