Skip to contentSkip to conversation

hmp, qmp: 'info memory_size_summary', 'query-memory-size-summary', 'info numa' updates

PATCH In review Vadim Galitsyn 3 participants 13 messages Aug 29, 2017 – Sep 14, 2017

lore
Share & tools
lore
#1 lore raw

PATCH v7 1/3 hmp: extend "info numa" with hotplugged memory information

In reply to Vadim Galitsyn

Report amount of hotplugged memory in addition to total amount per NUMA node.

Cc Eduardo Habkost <[email protected]>
Cc David Hildenbrand <[email protected]>
---
 include/qemu/typedefs.h |  1 +
 include/sysemu/numa.h   |  7 ++++++-
 monitor.c               |  9 ++++++---
 numa.c                  | 18 +++++++++++++-----
 4 files changed, 26 insertions(+), 9 deletions(-)
include/qemu/typedefs.h +1 -0
index 39bc8351a3..163550214c 100644
@@ -58,6 +58,7 @@ typedef struct MSIMessage MSIMessage;
 typedef struct NetClientState NetClientState;
 typedef struct NetFilterState NetFilterState;
 typedef struct NICInfo NICInfo;
+typedef struct NumaNodeMem NumaNodeMem;
 typedef struct PcGuestInfo PcGuestInfo;
 typedef struct PCIBridge PCIBridge;
 typedef struct PCIBus PCIBus;
include/sysemu/numa.h +6 -1
index 610eece211..5c6df2820b 100644
@@ -24,9 +24,14 @@ struct node_info {
     uint8_t distance[MAX_NODES];
 };
 
+struct NumaNodeMem {
+    uint64_t node_mem;
+    uint64_t node_plugged_mem;
+};
+
 extern NodeInfo numa_info[MAX_NODES];
 void parse_numa_opts(MachineState *ms);
-void query_numa_node_mem(uint64_t node_mem[]);
+void query_numa_node_mem(NumaNodeMem node_mem[]);
 extern QemuOptsList qemu_numa_opts;
 void numa_set_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node);
 void numa_unset_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node);
monitor.c +6 -3
index e0f880107f..6c9d183caf 100644
@@ -1710,11 +1710,12 @@ static void hmp_info_mtree(Monitor *mon, const QDict *qdict)
 static void hmp_info_numa(Monitor *mon, const QDict *qdict)
 {
     int i;
-    uint64_t *node_mem;
+    NumaNodeMem *node_mem;
     CpuInfoList *cpu_list, *cpu;
 
     cpu_list = qmp_query_cpus(&error_abort);
-    node_mem = g_new0(uint64_t, nb_numa_nodes);
+    node_mem = g_new0(NumaNodeMem, nb_numa_nodes);
+
     query_numa_node_mem(node_mem);
     monitor_printf(mon, "%d nodes\n", nb_numa_nodes);
     for (i = 0; i < nb_numa_nodes; i++) {
@@ -1727,7 +1728,9 @@ static void hmp_info_numa(Monitor *mon, const QDict *qdict)
         }
         monitor_printf(mon, "\n");
         monitor_printf(mon, "node %d size: %" PRId64 " MB\n", i,
-                       node_mem[i] >> 20);
+                       node_mem[i].node_mem >> 20);
+        monitor_printf(mon, "node %d plugged: %" PRId64 " MB\n", i,
+                       node_mem[i].node_plugged_mem >> 20);
     }
     qapi_free_CpuInfoList(cpu_list);
     g_free(node_mem);
numa.c +13 -5
index e32af04cd2..fe066ad2f8 100644
@@ -591,11 +591,12 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
     }
 }
 
-static void numa_stat_memory_devices(uint64_t node_mem[])
+static void numa_stat_memory_devices(NumaNodeMem node_mem[])
 {
     MemoryDeviceInfoList *info_list = NULL;
     MemoryDeviceInfoList **prev = &info_list;
     MemoryDeviceInfoList *info;
+    PCDIMMDeviceInfo     *pcdimm_info;
 
     qmp_pc_dimm_device_list(qdev_get_machine(), &prev);
     for (info = info_list; info; info = info->next) {
@@ -603,9 +604,16 @@ static void numa_stat_memory_devices(uint64_t node_mem[])
 
         if (value) {
             switch (value->type) {
-            case MEMORY_DEVICE_INFO_KIND_DIMM:
-                node_mem[value->u.dimm.data->node] += value->u.dimm.data->size;
+            case MEMORY_DEVICE_INFO_KIND_DIMM: {
+                pcdimm_info = value->u.dimm.data;
+                node_mem[pcdimm_info->node].node_mem += pcdimm_info->size;
+                if (pcdimm_info->hotpluggable && pcdimm_info->hotplugged) {
+                    node_mem[pcdimm_info->node].node_plugged_mem +=
+                        pcdimm_info->size;
+                }
                 break;
+            }
+
             default:
                 break;
             }
@@ -614,7 +622,7 @@ static void numa_stat_memory_devices(uint64_t node_mem[])
     qapi_free_MemoryDeviceInfoList(info_list);
 }
 
-void query_numa_node_mem(uint64_t node_mem[])
+void query_numa_node_mem(NumaNodeMem node_mem[])
 {
     int i;
 
@@ -624,7 +632,7 @@ void query_numa_node_mem(uint64_t node_mem[])
 
     numa_stat_memory_devices(node_mem);
     for (i = 0; i < nb_numa_nodes; i++) {
-        node_mem[i] += numa_info[i].node_mem;
+        node_mem[i].node_mem += numa_info[i].node_mem;
     }
 }
 
Signature · 1 line
2.13.1.394.g41dd433
#2 lore raw

PATCH v7 2/3 qmp: introduce query-memory-size-summary command

In reply to Vadim Galitsyn

Add a new query-memory-size-summary command which provides the following memory information in bytes:

* base-memory - size of "base" memory specified with command line option -m.

* plugged-memory - amount of memory that was hot-plugged. If target does not have CONFIG_MEM_HOTPLUG enabled, no value is reported.

---
 qapi-schema.json                                   | 32 ++++++++++++++++++++++
 include/hw/mem/pc-dimm.h                           |  1 +
 hw/mem/pc-dimm.c                                   |  5 ++++
 qmp.c                                              | 13 +++++++++
 stubs/{qmp_pc_dimm_device_list.c => qmp_pc_dimm.c} |  5 ++++
 stubs/Makefile.objs                                |  2 +-
 6 files changed, 57 insertions(+), 1 deletion(-)
 rename stubs/{qmp_pc_dimm_device_list.c => qmp_pc_dimm.c} (68%)
qapi-schema.json +32 -0
index 802ea53d00..9402ac3b3a 100644
@@ -4407,6 +4407,38 @@
   'data': { 'name': 'str', '*migration-safe': 'bool', 'static': 'bool',
             '*unavailable-features': [ 'str' ], 'typename': 'str' } }
 
+##
+# @MemoryInfo:
+#
+# Actual memory information in bytes.
+#
+# @base-memory: size of "base" memory specified with command line
+#               option -m.
+#
+# @plugged-memory: size memory that can be hot-unplugged. This field
+#                  is omitted if target does support memory hotplug
+#                  (i.e. CONFIG_MEM_HOTPLUG not defined on build time).
+#
+# Since: 2.11.0
+##
+{ 'struct': 'MemoryInfo',
+  'data'  : { 'base-memory': 'size', '*plugged-memory': 'size' } }
+
+##
+# @query-memory-size-summary:
+#
+# Return the amount of initially allocated and hot-plugged (if
+# enabled) memory in bytes.
+#
+# Example:
+#
+# -> { "execute": "query-memory-size-summary" }
+# <- { "return": { "base-memory": 4294967296, "plugged-memory": 0 } }
+#
+# Since: 2.11.0
+##
+{ 'command': 'query-memory-size-summary', 'returns': 'MemoryInfo' }
+
 ##
 # @query-cpu-definitions:
 #
include/hw/mem/pc-dimm.h +1 -0
index 6f8c3eb1b3..d83b957829 100644
@@ -95,6 +95,7 @@ int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp);
 
 int qmp_pc_dimm_device_list(Object *obj, void *opaque);
 uint64_t pc_existing_dimms_capacity(Error **errp);
+uint64_t get_plugged_memory_size(void);
 void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
                          MemoryRegion *mr, uint64_t align, Error **errp);
 void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms,
hw/mem/pc-dimm.c +5 -0
index bdf6649083..66eace5a5c 100644
@@ -159,6 +159,11 @@ uint64_t pc_existing_dimms_capacity(Error **errp)
     return cap.size;
 }
 
+uint64_t get_plugged_memory_size(void)
+{
+    return pc_existing_dimms_capacity(&error_abort);
+}
+
 int qmp_pc_dimm_device_list(Object *obj, void *opaque)
 {
     MemoryDeviceInfoList ***prev = opaque;
qmp.c +13 -0
index b86201e349..e8c303116a 100644
@@ -709,3 +709,16 @@ ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error **errp)
 
     return head;
 }
+
+MemoryInfo *qmp_query_memory_size_summary(Error **errp)
+{
+    MemoryInfo *mem_info = g_malloc0(sizeof(MemoryInfo));
+
+    mem_info->base_memory = ram_size;
+
+    mem_info->plugged_memory = get_plugged_memory_size();
+    mem_info->has_plugged_memory =
+        mem_info->plugged_memory != (uint64_t)-1;
+
+    return mem_info;
+}
stubs/qmp_pc_dimm.c renamed from stubs/qmp_pc_dimm_device_list.c +5 -0
similarity index 68%
rename from stubs/qmp_pc_dimm_device_list.c
rename to stubs/qmp_pc_dimm.c
index def211564d..9ddc4f619a 100644
@@ -6,3 +6,8 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque)
 {
    return 0;
 }
+
+uint64_t get_plugged_memory_size(void)
+{
+    return (uint64_t)-1;
+}
stubs/Makefile.objs +1 -1
index e69c217aff..f5f139f310 100644
@@ -33,7 +33,7 @@ stub-obj-y += uuid.o
 stub-obj-y += vm-stop.o
 stub-obj-y += vmstate.o
 stub-obj-$(CONFIG_WIN32) += fd-register.o
-stub-obj-y += qmp_pc_dimm_device_list.o
+stub-obj-y += qmp_pc_dimm.o
 stub-obj-y += target-monitor-defs.o
 stub-obj-y += target-get-monitor-def.o
 stub-obj-y += pc_madt_cpu_entry.o
Signature · 1 line
2.13.1.394.g41dd433
#7 lore raw

PATCH v7 3/3 hmp: introduce 'info memory_size_summary' command

In reply to Vadim Galitsyn

Add 'info memory_size_summary' command which is a sibling of QMP command query-memory-size-summary. It provides the following memory information in bytes:

* base-memory - size of "base" memory specified with command line option -m.

* plugged-memory - amount of memory that was hot-plugged. If target does not have CONFIG_MEM_HOTPLUG enabled, no value is reported.

---
 hmp.h                |  1 +
 hmp.c                | 18 ++++++++++++++++++
 hmp-commands-info.hx | 16 ++++++++++++++++
 3 files changed, 35 insertions(+)
hmp.h +1 -0
index 1ff455295e..3605003e4c 100644
@@ -145,5 +145,6 @@ void hmp_info_dump(Monitor *mon, const QDict *qdict);
 void hmp_info_ramblock(Monitor *mon, const QDict *qdict);
 void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict);
 void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict);
+void hmp_info_memory_size_summary(Monitor *mon, const QDict *qdict);
 
 #endif
hmp.c +18 -0
index fd80dce758..b718dab4df 100644
@@ -2868,3 +2868,21 @@ void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, &err);
     qapi_free_GuidInfo(info);
 }
+
+void hmp_info_memory_size_summary(Monitor *mon, const QDict *qdict)
+{
+    Error *err = NULL;
+    MemoryInfo *info = qmp_query_memory_size_summary(&err);
+    if (info) {
+        monitor_printf(mon, "base memory: %" PRIu64 "\n",
+                       info->base_memory);
+
+        if (info->has_plugged_memory) {
+            monitor_printf(mon, "plugged memory: %" PRIu64 "\n",
+                           info->plugged_memory);
+        }
+
+        qapi_free_MemoryInfo(info);
+    }
+    hmp_handle_error(mon, &err);
+}
hmp-commands-info.hx +16 -0
index d9df238a5f..04c9db81f6 100644
@@ -849,6 +849,22 @@ ETEXI
         .cmd = hmp_info_vm_generation_id,
     },
 
+STEXI
+@item info memory_size_summary
+@findex memory_size_summary
+Display the amount of initially allocated and hot-plugged (if
+enabled) memory in bytes.
+ETEXI
+
+    {
+        .name       = "memory_size_summary",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show the amount of initially allocated and "
+                      "hot-plugged (if enabled) memory in bytes.",
+        .cmd        = hmp_info_memory_size_summary,
+    },
+
 STEXI
 @end table
 ETEXI
Signature · 1 line
2.13.1.394.g41dd433
#0 lore raw

v7 cover hmp, qmp: 'info memory_size_summary', 'query-memory-size-summary', 'info numa' updates

Hi Guys,

Sorry for the delay. This is continuation of
http://lists.nongnu.org/archive/html/qemu-devel/2017-08/msg02937.html.

I tried to update all the things according to your input regarding to v6 series. I am attaching all the versions history here in cover letter.

Best regards,
Vadim

v7:
* hmp: 'info numa': 'struct numa_node_mem' ->
'struct NumaNodeMem' (Eric);

* hmp: 'info numa': 'numa_node_mem.node_hotpluggable_mem' -> 'NumaNodeMem.node_plugged_mem' (in order to follow the same naming schema as in the rest patches from this series);

* hmp: hmp_info_memory_size_summary() no longer
uses &error_abort (David);

* qmp: documented when @plugged-memory info is omitted (Eric);

* qmp: added example usage of @query-memory-size-summary (Eric);

* qmp: 'Since: 2.10.0' -> 'Since: 2.11.0' (Eric);

* All commit messages updated according to Eric's recomendation.

v6:
* qmp: Renamed get_existing_hotpluggable_memory_size() -> get_plugged_memory_size();

* qmp: Renamed MemoryInfo.hotunpluggable_memory -> MemoryInfo.plugged_memory;

* qmp: Dropped superfluous parenthesis around the comparison while evaluating MemoryInfo.has_plugged_memory.

* hmp: Renamed 'info memory-size-summary' ->
'info memory_size_summary'

v5:
* hmp: Updated description and '.help' message for 'info memory-size-summary' command.

* hmp: Removed '-' characters from
'info memory-size-summary' output.

* Dropped ballooned memory information.

* get_existing_hotpluggable_memory_size() assumed to never fail; routine now has no arguments and returns uint64_t; in case if target does not support memory hotplug, (uint64_t)-1 is returned.

* MemoryInfo structure:
* Removed @balloon-actual-memory field.
* Field @hotpluggable-memory renamed
to @hotunpluggable-memory.
* Updated description for fields.

* qmp: Updated description for
query-memory-size-summary.

* Patch v4 splitted into series.

v4:
* Commands "info memory" and "query-memory" were renamed
to "info memory-size-summary" and "query-memory-size-summary" correspondingly.
* Descriptions for both commands as well as MemoryInfo structure fields were updated/renamed according to
http://lists.nongnu.org/archive/html/qemu-devel/2017-06/msg05972.html.
* In MemoryInfo structure following fields are now optional:
hotpluggable-memory and balloon-actual-memory.
* Field "hotpluggable-memory" now not displayed in HMP if target has no CONFIG_MEM_HOTPLUG enabled.
* Field "balloon-actual-memory" now not displayed in HMP if ballooning not enabled.
* qapi_free_MemoryInfo() used in order to free corresponding memory instead of g_free().
* #ifdef CONFIG_MEM_HOTPLUG was removed and replaced with stubs/ approach. get_exiting_hotpluggable_memory_size() function was introduced in hw/mem/pc-dimm.c (available for all targets which have CONFIG_MEM_HOTPLUG enabled). For other targets, there is a stub in stubs/qmp_pc_dimm.c. In addition, stubs/qmp_pc_dimm_device_list.c was renamed to stubs/qmp_pc_dimm.c in order to reflect actual source file content.
* Commit message was updated in order to reflect what was changed.

v3:
* Use PRIu64 instead of 'lu' when printing results via HMP.
* Report zero hot-plugged memory instead of reporting error when target architecture has no CONFIG_MEM_HOTPLUG enabled.

v2:
* Fixed build for targets which do not have CONFIG_MEM_HOTPLUG enabled.

#9 lore raw

Hi Guys,

Could you please let me know if you have an update on this topic?

Thank you,
Vadim

Quoted 104 lines · Vadim Galitsyn

Hi Guys,

Sorry for the delay. This is continuation of
http://lists.nongnu.org/archive/html/qemu-devel/2017-08/msg02937.html.

I tried to update all the things according to your input regarding to v6 series. I am attaching all the versions history here in cover letter.

Best regards,
Vadim

v7:
* hmp: 'info numa': 'struct numa_node_mem' ->
'struct NumaNodeMem' (Eric);

* hmp: 'info numa': 'numa_node_mem.node_hotpluggable_mem' -> 'NumaNodeMem.node_plugged_mem' (in order to follow the same naming schema as in the rest patches from this series);

* hmp: hmp_info_memory_size_summary() no longer
uses &error_abort (David);

* qmp: documented when @plugged-memory info is omitted (Eric);

* qmp: added example usage of @query-memory-size-summary (Eric);

* qmp: 'Since: 2.10.0' -> 'Since: 2.11.0' (Eric);

* All commit messages updated according to Eric's recomendation.

v6:
* qmp: Renamed get_existing_hotpluggable_memory_size() -> get_plugged_memory_size();

* qmp: Renamed MemoryInfo.hotunpluggable_memory -> MemoryInfo.plugged_memory;

* qmp: Dropped superfluous parenthesis around the comparison while evaluating MemoryInfo.has_plugged_memory.

* hmp: Renamed 'info memory-size-summary' ->
'info memory_size_summary'

v5:
* hmp: Updated description and '.help' message for 'info memory-size-summary' command.

* hmp: Removed '-' characters from
'info memory-size-summary' output.

* Dropped ballooned memory information.

* get_existing_hotpluggable_memory_size() assumed to never fail; routine now has no arguments and returns uint64_t; in case if target does not support memory hotplug, (uint64_t)-1 is returned.

* MemoryInfo structure:
* Removed @balloon-actual-memory field.
* Field @hotpluggable-memory renamed
to @hotunpluggable-memory.
* Updated description for fields.

* qmp: Updated description for
query-memory-size-summary.

* Patch v4 splitted into series.

v4:
* Commands "info memory" and "query-memory" were renamed
to "info memory-size-summary" and "query-memory-size-summary" correspondingly.
* Descriptions for both commands as well as MemoryInfo structure fields were updated/renamed according to
http://lists.nongnu.org/archive/html/qemu-devel/2017-06/msg05972.html.
* In MemoryInfo structure following fields are now optional:
hotpluggable-memory and balloon-actual-memory.
* Field "hotpluggable-memory" now not displayed in HMP if target has no CONFIG_MEM_HOTPLUG enabled.
* Field "balloon-actual-memory" now not displayed in HMP if ballooning not enabled.
* qapi_free_MemoryInfo() used in order to free corresponding memory instead of g_free().
* #ifdef CONFIG_MEM_HOTPLUG was removed and replaced with stubs/ approach. get_exiting_hotpluggable_memory_size() function was introduced in hw/mem/pc-dimm.c (available for all targets which have
CONFIG_MEM_HOTPLUG
enabled). For other targets, there is a stub in stubs/qmp_pc_dimm.c. In addition, stubs/qmp_pc_dimm_device_list.c was renamed to stubs/qmp_pc_dimm.c in order to reflect actual source file content.
* Commit message was updated in order to reflect what was changed.

v3:
* Use PRIu64 instead of 'lu' when printing results via HMP.
* Report zero hot-plugged memory instead of reporting error when target architecture has no CONFIG_MEM_HOTPLUG enabled.

v2:
* Fixed build for targets which do not have CONFIG_MEM_HOTPLUG enabled.

#3 lore raw

Re: [Qemu-devel] [PATCH v7 2/3] qmp: introduce query-memory-size-summary command

In reply to Vadim Galitsyn
Quoted 38 lines · On Tue, 29 Aug 2017 17:30:21 +0200 Vadim Galitsyn…

Add a new query-memory-size-summary command which provides the following memory information in bytes:

* base-memory - size of "base" memory specified with command line option -m.

* plugged-memory - amount of memory that was hot-plugged. If target does not have CONFIG_MEM_HOTPLUG enabled, no value is reported.

---
 qapi-schema.json                                   | 32 ++++++++++++++++++++++
 include/hw/mem/pc-dimm.h                           |  1 +
 hw/mem/pc-dimm.c                                   |  5 ++++
 qmp.c                                              | 13 +++++++++
 stubs/{qmp_pc_dimm_device_list.c => qmp_pc_dimm.c} |  5 ++++
 stubs/Makefile.objs                                |  2 +-
 6 files changed, 57 insertions(+), 1 deletion(-)
 rename stubs/{qmp_pc_dimm_device_list.c => qmp_pc_dimm.c} (68%)
qapi-schema.json +1 -0
index 802ea53d00..9402ac3b3a 100644
@@ -4407,6 +4407,38 @@
   'data': { 'name': 'str', '*migration-safe': 'bool', 'static': 'bool',
             '*unavailable-features': [ 'str' ], 'typename': 'str' } }
 
+##

qapi-schema.json line 4420

Quoted 10 lines
qapi-schema.json +10 -0
+# @MemoryInfo:
+#
+# Actual memory information in bytes.
+#
+# @base-memory: size of "base" memory specified with command line
+#               option -m.
+#
+# @plugged-memory: size memory that can be hot-unplugged. This field
+#                  is omitted if target does support memory hotplug
+#                  (i.e. CONFIG_MEM_HOTPLUG not defined on build time).

field description doesn't match what's actually reported. s/cat be/is/
s/does/doesn't/

qapi-schema.json line 4431

Quoted 11 lines
qapi-schema.json +11 -0
+#
+# Since: 2.11.0
+##
+{ 'struct': 'MemoryInfo',
+  'data'  : { 'base-memory': 'size', '*plugged-memory': 'size' } }
+
+##
+# @query-memory-size-summary:
+#
+# Return the amount of initially allocated and hot-plugged (if
+# enabled) memory in bytes.

it could count dimm's on CLI, so not only hotplugged

s/hot-plugged/present hotpluggable/

Quoted 91 lines
qapi-schema.json +10 -0
+#
+# Example:
+#
+# -> { "execute": "query-memory-size-summary" }
+# <- { "return": { "base-memory": 4294967296, "plugged-memory": 0 } }
+#
+# Since: 2.11.0
+##
+{ 'command': 'query-memory-size-summary', 'returns': 'MemoryInfo' }
+
 ##
 # @query-cpu-definitions:
 #
include/hw/mem/pc-dimm.h +1 -0
index 6f8c3eb1b3..d83b957829 100644
@@ -95,6 +95,7 @@ int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp);
 
 int qmp_pc_dimm_device_list(Object *obj, void *opaque);
 uint64_t pc_existing_dimms_capacity(Error **errp);
+uint64_t get_plugged_memory_size(void);
 void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
                          MemoryRegion *mr, uint64_t align, Error **errp);
 void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms,
hw/mem/pc-dimm.c +5 -0
index bdf6649083..66eace5a5c 100644
@@ -159,6 +159,11 @@ uint64_t pc_existing_dimms_capacity(Error **errp)
     return cap.size;
 }
 
+uint64_t get_plugged_memory_size(void)
+{
+    return pc_existing_dimms_capacity(&error_abort);
+}
+
 int qmp_pc_dimm_device_list(Object *obj, void *opaque)
 {
     MemoryDeviceInfoList ***prev = opaque;
qmp.c +13 -0
index b86201e349..e8c303116a 100644
@@ -709,3 +709,16 @@ ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error **errp)
 
     return head;
 }
+
+MemoryInfo *qmp_query_memory_size_summary(Error **errp)
+{
+    MemoryInfo *mem_info = g_malloc0(sizeof(MemoryInfo));
+
+    mem_info->base_memory = ram_size;
+
+    mem_info->plugged_memory = get_plugged_memory_size();
+    mem_info->has_plugged_memory =
+        mem_info->plugged_memory != (uint64_t)-1;
+
+    return mem_info;
+}
stubs/qmp_pc_dimm.c renamed from stubs/qmp_pc_dimm_device_list.c +5 -0
similarity index 68%
rename from stubs/qmp_pc_dimm_device_list.c
rename to stubs/qmp_pc_dimm.c
index def211564d..9ddc4f619a 100644
@@ -6,3 +6,8 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque)
 {
    return 0;
 }
+
+uint64_t get_plugged_memory_size(void)
+{
+    return (uint64_t)-1;
+}
stubs/Makefile.objs +1 -1
index e69c217aff..f5f139f310 100644
@@ -33,7 +33,7 @@ stub-obj-y += uuid.o
 stub-obj-y += vm-stop.o
 stub-obj-y += vmstate.o
 stub-obj-$(CONFIG_WIN32) += fd-register.o
-stub-obj-y += qmp_pc_dimm_device_list.o
+stub-obj-y += qmp_pc_dimm.o
 stub-obj-y += target-monitor-defs.o
 stub-obj-y += target-get-monitor-def.o
 stub-obj-y += pc_madt_cpu_entry.o
#8 lore raw

Re: [Qemu-devel] [PATCH v7 3/3] hmp: introduce 'info memory_size_summary' command

In reply to Vadim Galitsyn
Quoted 68 lines · On Tue, 29 Aug 2017 17:30:22 +0200 Vadim Galitsyn…

Add 'info memory_size_summary' command which is a sibling of QMP command query-memory-size-summary. It provides the following memory information in bytes:

* base-memory - size of "base" memory specified with command line option -m.

* plugged-memory - amount of memory that was hot-plugged. If target does not have CONFIG_MEM_HOTPLUG enabled, no value is reported.

---
 hmp.h                |  1 +
 hmp.c                | 18 ++++++++++++++++++
 hmp-commands-info.hx | 16 ++++++++++++++++
 3 files changed, 35 insertions(+)
hmp.h +1 -0
index 1ff455295e..3605003e4c 100644
@@ -145,5 +145,6 @@ void hmp_info_dump(Monitor *mon, const QDict *qdict);
 void hmp_info_ramblock(Monitor *mon, const QDict *qdict);
 void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict);
 void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict);
+void hmp_info_memory_size_summary(Monitor *mon, const QDict *qdict);
 
 #endif
hmp.c +18 -0
index fd80dce758..b718dab4df 100644
@@ -2868,3 +2868,21 @@ void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, &err);
     qapi_free_GuidInfo(info);
 }
+
+void hmp_info_memory_size_summary(Monitor *mon, const QDict *qdict)
+{
+    Error *err = NULL;
+    MemoryInfo *info = qmp_query_memory_size_summary(&err);
+    if (info) {
+        monitor_printf(mon, "base memory: %" PRIu64 "\n",
+                       info->base_memory);
+
+        if (info->has_plugged_memory) {
+            monitor_printf(mon, "plugged memory: %" PRIu64 "\n",
+                           info->plugged_memory);
+        }
+
+        qapi_free_MemoryInfo(info);
+    }
+    hmp_handle_error(mon, &err);
+}
hmp-commands-info.hx +0 -0
index d9df238a5f..04c9db81f6 100644

hmp-commands-info.hx ETEXI · line 855

Quoted 7 lines
hmp-commands-info.hx +4 -0
@@ -849,6 +849,22 @@ ETEXI
         .cmd = hmp_info_vm_generation_id,
     },
 
+STEXI
+@item info memory_size_summary
+@findex memory_size_summary
+Display the amount of initially allocated and hot-plugged (if

s/hot-plugged/present hotpluggable/

hmp-commands-info.hx ETEXI · line 864

Quoted 9 lines
hmp-commands-info.hx +9 -0
+enabled) memory in bytes.
+ETEXI
+
+    {
+        .name       = "memory_size_summary",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show the amount of initially allocated and "
+                      "hot-plugged (if enabled) memory in bytes.",

ditto

Quoted 6 lines
hmp-commands-info.hx +3 -0
+        .cmd        = hmp_info_memory_size_summary,
+    },
+
 STEXI
 @end table
 ETEXI
Reviewed-by
#10 lore raw
In reply to Vadim Galitsyn
Quoted 3 lines · On Thu, 14 Sep 2017 11:35:36 +0200 Vadim Galitsyn…

Hi Guys,

Could you please let me know if you have an update on this topic?

Series looks good to me.
so with comments I've made fixed up

Quoted 111 lines

Thank you,
Vadim

Quoted 104 lines · Vadim Galitsyn

Hi Guys,

Sorry for the delay. This is continuation of
http://lists.nongnu.org/archive/html/qemu-devel/2017-08/msg02937.html.

I tried to update all the things according to your input regarding to v6 series. I am attaching all the versions history here in cover letter.

Best regards,
Vadim

v7:
* hmp: 'info numa': 'struct numa_node_mem' ->
'struct NumaNodeMem' (Eric);

* hmp: 'info numa': 'numa_node_mem.node_hotpluggable_mem' -> 'NumaNodeMem.node_plugged_mem' (in order to follow the same naming schema as in the rest patches from this series);

* hmp: hmp_info_memory_size_summary() no longer
uses &error_abort (David);

* qmp: documented when @plugged-memory info is omitted (Eric);

* qmp: added example usage of @query-memory-size-summary (Eric);

* qmp: 'Since: 2.10.0' -> 'Since: 2.11.0' (Eric);

* All commit messages updated according to Eric's recomendation.

v6:
* qmp: Renamed get_existing_hotpluggable_memory_size() -> get_plugged_memory_size();

* qmp: Renamed MemoryInfo.hotunpluggable_memory -> MemoryInfo.plugged_memory;

* qmp: Dropped superfluous parenthesis around the comparison while evaluating MemoryInfo.has_plugged_memory.

* hmp: Renamed 'info memory-size-summary' ->
'info memory_size_summary'

v5:
* hmp: Updated description and '.help' message for 'info memory-size-summary' command.

* hmp: Removed '-' characters from
'info memory-size-summary' output.

* Dropped ballooned memory information.

* get_existing_hotpluggable_memory_size() assumed to never fail; routine now has no arguments and returns uint64_t; in case if target does not support memory hotplug, (uint64_t)-1 is returned.

* MemoryInfo structure:
* Removed @balloon-actual-memory field.
* Field @hotpluggable-memory renamed
to @hotunpluggable-memory.
* Updated description for fields.

* qmp: Updated description for
query-memory-size-summary.

* Patch v4 splitted into series.

v4:
* Commands "info memory" and "query-memory" were renamed
to "info memory-size-summary" and "query-memory-size-summary" correspondingly.
* Descriptions for both commands as well as MemoryInfo structure fields were updated/renamed according to
http://lists.nongnu.org/archive/html/qemu-devel/2017-06/msg05972.html.
* In MemoryInfo structure following fields are now optional:
hotpluggable-memory and balloon-actual-memory.
* Field "hotpluggable-memory" now not displayed in HMP if target has no CONFIG_MEM_HOTPLUG enabled.
* Field "balloon-actual-memory" now not displayed in HMP if ballooning not enabled.
* qapi_free_MemoryInfo() used in order to free corresponding memory instead of g_free().
* #ifdef CONFIG_MEM_HOTPLUG was removed and replaced with stubs/ approach. get_exiting_hotpluggable_memory_size() function was introduced in hw/mem/pc-dimm.c (available for all targets which have
CONFIG_MEM_HOTPLUG
enabled). For other targets, there is a stub in stubs/qmp_pc_dimm.c. In addition, stubs/qmp_pc_dimm_device_list.c was renamed to stubs/qmp_pc_dimm.c in order to reflect actual source file content.
* Commit message was updated in order to reflect what was changed.

v3:
* Use PRIu64 instead of 'lu' when printing results via HMP.
* Report zero hot-plugged memory instead of reporting error when target architecture has no CONFIG_MEM_HOTPLUG enabled.

v2:
* Fixed build for targets which do not have CONFIG_MEM_HOTPLUG enabled.

#11 lore raw
Quoted 8 lines · * Igor Mammedov ([email protected]) wrote:
Quoted 3 lines · On Thu, 14 Sep 2017 11:35:36 +0200 Vadim Galitsyn…

Hi Guys,

Could you please let me know if you have an update on this topic?

Series looks good to me.
so with comments I've made fixed up

OK, I can fix those comment comments up in a pull.

Quoted 1 line

Thanks,

Dave

Quoted 106 lines
Quoted 106 lines

Thank you,
Vadim

Quoted 98 lines · Vadim Galitsyn

Hi Guys,

Sorry for the delay. This is continuation of
http://lists.nongnu.org/archive/html/qemu-devel/2017-08/msg02937.html.

I tried to update all the things according to your input regarding to v6 series. I am attaching all the versions history here in cover letter.

Best regards,
Vadim

v7:
* hmp: 'info numa': 'struct numa_node_mem' ->
'struct NumaNodeMem' (Eric);

* hmp: 'info numa': 'numa_node_mem.node_hotpluggable_mem' -> 'NumaNodeMem.node_plugged_mem' (in order to follow the same naming schema as in the rest patches from this series);

* hmp: hmp_info_memory_size_summary() no longer
uses &error_abort (David);

* qmp: documented when @plugged-memory info is omitted (Eric);

* qmp: added example usage of @query-memory-size-summary (Eric);

* qmp: 'Since: 2.10.0' -> 'Since: 2.11.0' (Eric);

* All commit messages updated according to Eric's recomendation.

v6:
* qmp: Renamed get_existing_hotpluggable_memory_size() -> get_plugged_memory_size();

* qmp: Renamed MemoryInfo.hotunpluggable_memory -> MemoryInfo.plugged_memory;

* qmp: Dropped superfluous parenthesis around the comparison while evaluating MemoryInfo.has_plugged_memory.

* hmp: Renamed 'info memory-size-summary' ->
'info memory_size_summary'

v5:
* hmp: Updated description and '.help' message for 'info memory-size-summary' command.

* hmp: Removed '-' characters from
'info memory-size-summary' output.

* Dropped ballooned memory information.

* get_existing_hotpluggable_memory_size() assumed to never fail; routine now has no arguments and returns uint64_t; in case if target does not support memory hotplug, (uint64_t)-1 is returned.

* MemoryInfo structure:
* Removed @balloon-actual-memory field.
* Field @hotpluggable-memory renamed
to @hotunpluggable-memory.
* Updated description for fields.

* qmp: Updated description for
query-memory-size-summary.

* Patch v4 splitted into series.

v4:
* Commands "info memory" and "query-memory" were renamed
to "info memory-size-summary" and "query-memory-size-summary" correspondingly.
* Descriptions for both commands as well as MemoryInfo structure fields were updated/renamed according to
http://lists.nongnu.org/archive/html/qemu-devel/2017-06/msg05972.html.
* In MemoryInfo structure following fields are now optional:
hotpluggable-memory and balloon-actual-memory.
* Field "hotpluggable-memory" now not displayed in HMP if target has no CONFIG_MEM_HOTPLUG enabled.
* Field "balloon-actual-memory" now not displayed in HMP if ballooning not enabled.
* qapi_free_MemoryInfo() used in order to free corresponding memory instead of g_free().
* #ifdef CONFIG_MEM_HOTPLUG was removed and replaced with stubs/ approach. get_exiting_hotpluggable_memory_size() function was introduced in hw/mem/pc-dimm.c (available for all targets which have
CONFIG_MEM_HOTPLUG
enabled). For other targets, there is a stub in stubs/qmp_pc_dimm.c. In addition, stubs/qmp_pc_dimm_device_list.c was renamed to stubs/qmp_pc_dimm.c in order to reflect actual source file content.
* Commit message was updated in order to reflect what was changed.

v3:
* Use PRIu64 instead of 'lu' when printing results via HMP.
* Report zero hot-plugged memory instead of reporting error when target architecture has no CONFIG_MEM_HOTPLUG enabled.

Quoted 7 lines
Quoted 6 lines
Quoted 6 lines

v2:
* Fixed build for targets which do not have CONFIG_MEM_HOTPLUG enabled.

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#12 lore raw

Igor, David,

Thank you!

Best regards,
Vadim

Quoted 139 lines · Dr. David Alan Gilbert
Quoted 8 lines · * Igor Mammedov ([email protected]) wrote:
Quoted 3 lines · On Thu, 14 Sep 2017 11:35:36 +0200 Vadim Galitsyn…

Hi Guys,

Could you please let me know if you have an update on this topic?

Series looks good to me.
so with comments I've made fixed up

OK, I can fix those comment comments up in a pull.

Quoted 1 line

Thanks,

Dave

Quoted 5 lines
Quoted 5 lines

Thank you,
Vadim

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines · Vadim Galitsyn

Hi Guys,

Sorry for the delay. This is continuation of
http://lists.nongnu.org/archive/html/qemu-devel/2017-

08/msg02937.html.

Quoted 65 lines
Quoted 65 lines
Quoted 65 lines

I tried to update all the things according to your input regarding to v6 series. I am attaching all the versions history here in cover letter.

Best regards,
Vadim

v7:
* hmp: 'info numa': 'struct numa_node_mem' ->
'struct NumaNodeMem' (Eric);

* hmp: 'info numa': 'numa_node_mem.node_hotpluggable_mem' -> 'NumaNodeMem.node_plugged_mem' (in order to follow the same naming schema as in the rest patches from this series);

* hmp: hmp_info_memory_size_summary() no longer
uses &error_abort (David);

* qmp: documented when @plugged-memory info is omitted (Eric);

* qmp: added example usage of @query-memory-size-summary (Eric);

* qmp: 'Since: 2.10.0' -> 'Since: 2.11.0' (Eric);

* All commit messages updated according to Eric's recomendation.

v6:
* qmp: Renamed get_existing_hotpluggable_memory_size() -> get_plugged_memory_size();

* qmp: Renamed MemoryInfo.hotunpluggable_memory -> MemoryInfo.plugged_memory;

* qmp: Dropped superfluous parenthesis around the comparison while evaluating MemoryInfo.has_plugged_memory.

* hmp: Renamed 'info memory-size-summary' ->
'info memory_size_summary'

v5:
* hmp: Updated description and '.help' message for 'info memory-size-summary' command.

* hmp: Removed '-' characters from
'info memory-size-summary' output.

* Dropped ballooned memory information.

* get_existing_hotpluggable_memory_size() assumed to never fail; routine now has no arguments and returns uint64_t; in case if target does not support memory hotplug, (uint64_t)-1 is returned.

* MemoryInfo structure:
* Removed @balloon-actual-memory field.
* Field @hotpluggable-memory renamed
to @hotunpluggable-memory.
* Updated description for fields.

* qmp: Updated description for
query-memory-size-summary.

* Patch v4 splitted into series.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

v4:
* Commands "info memory" and "query-memory" were renamed to "info memory-size-summary" and "query-memory-size-summary" correspondingly.
* Descriptions for both commands as well as MemoryInfo structure fields were updated/renamed according to
http://lists.nongnu.org/archive/html/qemu-devel/2017-

06/msg05972.html.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

* In MemoryInfo structure following fields are now optional:
hotpluggable-memory and balloon-actual-memory.
* Field "hotpluggable-memory" now not displayed in HMP if target has no CONFIG_MEM_HOTPLUG enabled.
* Field "balloon-actual-memory" now not displayed in HMP if ballooning not enabled.
* qapi_free_MemoryInfo() used in order to free corresponding memory instead of g_free().
* #ifdef CONFIG_MEM_HOTPLUG was removed and replaced with stubs/

approach.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

get_exiting_hotpluggable_memory_size() function was introduced in hw/mem/pc-dimm.c (available for all targets which have
CONFIG_MEM_HOTPLUG
enabled). For other targets, there is a stub in

stubs/qmp_pc_dimm.c.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

In addition, stubs/qmp_pc_dimm_device_list.c was renamed to stubs/qmp_pc_dimm.c in order to reflect actual source file

content.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

* Commit message was updated in order to reflect what was changed.

v3:
* Use PRIu64 instead of 'lu' when printing results via HMP.
* Report zero hot-plugged memory instead of reporting error when target architecture has no CONFIG_MEM_HOTPLUG enabled.

Quoted 7 lines
Quoted 6 lines
Quoted 6 lines

v2:
* Fixed build for targets which do not have CONFIG_MEM_HOTPLUG enabled.

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#4 lore raw

Re: [Qemu-devel] [PATCH v7 2/3] qmp: introduce query-memory-size-summary command

In reply to Igor Mammedov
Quoted 40 lines · * Igor Mammedov ([email protected]) wrote:
Quoted 37 lines · On Tue, 29 Aug 2017 17:30:21 +0200 Vadim Galitsyn…

Add a new query-memory-size-summary command which provides the following memory information in bytes:

* base-memory - size of "base" memory specified with command line option -m.

* plugged-memory - amount of memory that was hot-plugged. If target does not have CONFIG_MEM_HOTPLUG enabled, no value is reported.

---
 qapi-schema.json                                   | 32 ++++++++++++++++++++++
 include/hw/mem/pc-dimm.h                           |  1 +
 hw/mem/pc-dimm.c                                   |  5 ++++
 qmp.c                                              | 13 +++++++++
 stubs/{qmp_pc_dimm_device_list.c => qmp_pc_dimm.c} |  5 ++++
 stubs/Makefile.objs                                |  2 +-
 6 files changed, 57 insertions(+), 1 deletion(-)
 rename stubs/{qmp_pc_dimm_device_list.c => qmp_pc_dimm.c} (68%)
qapi-schema.json +0 -0
index 802ea53d00..9402ac3b3a 100644
@@ -4407,6 +4407,38 @@
   'data': { 'name': 'str', '*migration-safe': 'bool', 'static': 'bool',
             '*unavailable-features': [ 'str' ], 'typename': 'str' } }
 
Quoted 13 lines

qapi-schema.json line 4420

Quoted 11 lines
qapi-schema.json +11 -0
+##
+# @MemoryInfo:
+#
+# Actual memory information in bytes.
+#
+# @base-memory: size of "base" memory specified with command line
+#               option -m.
+#
+# @plugged-memory: size memory that can be hot-unplugged. This field
+#                  is omitted if target does support memory hotplug
+#                  (i.e. CONFIG_MEM_HOTPLUG not defined on build time).

field description doesn't match what's actually reported. s/cat be/is/

Are you sure about that? That would read:
size memory that is hot-unplugged

which doesn't sound right, since it's not be hot-unplugged yet.

Dave

Quoted 100 lines

s/does/doesn't/

qapi-schema.json line 4431

Quoted 11 lines
qapi-schema.json +11 -0
+#
+# Since: 2.11.0
+##
+{ 'struct': 'MemoryInfo',
+  'data'  : { 'base-memory': 'size', '*plugged-memory': 'size' } }
+
+##
+# @query-memory-size-summary:
+#
+# Return the amount of initially allocated and hot-plugged (if
+# enabled) memory in bytes.

it could count dimm's on CLI, so not only hotplugged

s/hot-plugged/present hotpluggable/

Quoted 83 lines
qapi-schema.json +10 -0
+#
+# Example:
+#
+# -> { "execute": "query-memory-size-summary" }
+# <- { "return": { "base-memory": 4294967296, "plugged-memory": 0 } }
+#
+# Since: 2.11.0
+##
+{ 'command': 'query-memory-size-summary', 'returns': 'MemoryInfo' }
+
 ##
 # @query-cpu-definitions:
 #
include/hw/mem/pc-dimm.h +1 -0
index 6f8c3eb1b3..d83b957829 100644
@@ -95,6 +95,7 @@ int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp);
 
 int qmp_pc_dimm_device_list(Object *obj, void *opaque);
 uint64_t pc_existing_dimms_capacity(Error **errp);
+uint64_t get_plugged_memory_size(void);
 void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
                          MemoryRegion *mr, uint64_t align, Error **errp);
 void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms,
hw/mem/pc-dimm.c +5 -0
index bdf6649083..66eace5a5c 100644
@@ -159,6 +159,11 @@ uint64_t pc_existing_dimms_capacity(Error **errp)
     return cap.size;
 }
 
+uint64_t get_plugged_memory_size(void)
+{
+    return pc_existing_dimms_capacity(&error_abort);
+}
+
 int qmp_pc_dimm_device_list(Object *obj, void *opaque)
 {
     MemoryDeviceInfoList ***prev = opaque;
qmp.c +13 -0
index b86201e349..e8c303116a 100644
@@ -709,3 +709,16 @@ ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error **errp)
 
     return head;
 }
+
+MemoryInfo *qmp_query_memory_size_summary(Error **errp)
+{
+    MemoryInfo *mem_info = g_malloc0(sizeof(MemoryInfo));
+
+    mem_info->base_memory = ram_size;
+
+    mem_info->plugged_memory = get_plugged_memory_size();
+    mem_info->has_plugged_memory =
+        mem_info->plugged_memory != (uint64_t)-1;
+
+    return mem_info;
+}
stubs/qmp_pc_dimm.c renamed from stubs/qmp_pc_dimm_device_list.c +5 -0
similarity index 68%
rename from stubs/qmp_pc_dimm_device_list.c
rename to stubs/qmp_pc_dimm.c
index def211564d..9ddc4f619a 100644
@@ -6,3 +6,8 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque)
 {
    return 0;
 }
+
+uint64_t get_plugged_memory_size(void)
+{
+    return (uint64_t)-1;
+}
stubs/Makefile.objs +0 -0
index e69c217aff..f5f139f310 100644
@@ -33,7 +33,7 @@ stub-obj-y += uuid.o
Quoted 9 lines

stubs/Makefile.objs stub-obj-y += uuid.o · line 39

Quoted 8 lines
stubs/Makefile.objs +1 -1
 stub-obj-y += vm-stop.o
 stub-obj-y += vmstate.o
 stub-obj-$(CONFIG_WIN32) += fd-register.o
-stub-obj-y += qmp_pc_dimm_device_list.o
+stub-obj-y += qmp_pc_dimm.o
 stub-obj-y += target-monitor-defs.o
 stub-obj-y += target-get-monitor-def.o
 stub-obj-y += pc_madt_cpu_entry.o

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#5 lore raw

Re: [Qemu-devel] [PATCH v7 2/3] qmp: introduce query-memory-size-summary command

I think I made a typo here. It should be:

+# @plugged-memory: size *of* memory that can be hot-unplugged. This field
+# is omitted if target does *not* support memory hotplug
+# (i.e. CONFIG_MEM_HOTPLUG not defined on build time).

Quoted 184 lines · Dr. David Alan Gilbert
Quoted 7 lines · * Igor Mammedov ([email protected]) wrote:
Quoted 4 lines · On Tue, 29 Aug 2017 17:30:21 +0200 Vadim Galitsyn…

Add a new query-memory-size-summary command which provides the following memory information in bytes:

* base-memory - size of "base" memory specified with command line

option -m.

Quoted 6 lines
Quoted 6 lines

* plugged-memory - amount of memory that was hot-plugged. If target does not have CONFIG_MEM_HOTPLUG enabled, no value is reported.

profitbricks.com>

Quoted 11 lines
Quoted 11 lines
---
 qapi-schema.json                                   | 32

++++++++++++++++++++++

Quoted 8 lines
Quoted 8 lines
 include/hw/mem/pc-dimm.h                           |  1 +
 hw/mem/pc-dimm.c                                   |  5 ++++
 qmp.c                                              | 13 +++++++++
 stubs/{qmp_pc_dimm_device_list.c => qmp_pc_dimm.c} |  5 ++++
 stubs/Makefile.objs                                |  2 +-
 6 files changed, 57 insertions(+), 1 deletion(-)
 rename stubs/{qmp_pc_dimm_device_list.c => qmp_pc_dimm.c} (68%)
Quoted 6 lines

qapi-schema.json line 4407

Quoted 6 lines
qapi-schema.json +0 -0
index 802ea53d00..9402ac3b3a 100644
@@ -4407,6 +4407,38 @@
   'data': { 'name': 'str', '*migration-safe': 'bool', 'static':

'bool',

Quoted 13 lines

qapi-schema.json

Quoted 13 lines
qapi-schema.json +11 -0
             '*unavailable-features': [ 'str' ], 'typename': 'str' } }
 
+##
+# @MemoryInfo:
+#
+# Actual memory information in bytes.
+#
+# @base-memory: size of "base" memory specified with command line
+#               option -m.
+#
+# @plugged-memory: size memory that can be hot-unplugged. This field
+#                  is omitted if target does support memory hotplug
+#                  (i.e. CONFIG_MEM_HOTPLUG not defined on build

time).

Quoted 2 lines

field description doesn't match what's actually reported. s/cat be/is/

Are you sure about that? That would read:
size memory that is hot-unplugged

which doesn't sound right, since it's not be hot-unplugged yet.

Dave

Quoted 27 lines

s/does/doesn't/

qapi-schema.json line 4431

Quoted 11 lines
qapi-schema.json +11 -0
+#
+# Since: 2.11.0
+##
+{ 'struct': 'MemoryInfo',
+  'data'  : { 'base-memory': 'size', '*plugged-memory': 'size' } }
+
+##
+# @query-memory-size-summary:
+#
+# Return the amount of initially allocated and hot-plugged (if
+# enabled) memory in bytes.

it could count dimm's on CLI, so not only hotplugged

s/hot-plugged/present hotpluggable/

Quoted 10 lines
qapi-schema.json +10 -0
+#
+# Example:
+#
+# -> { "execute": "query-memory-size-summary" }
+# <- { "return": { "base-memory": 4294967296, "plugged-memory": 0 } }
+#
+# Since: 2.11.0
+##
+{ 'command': 'query-memory-size-summary', 'returns': 'MemoryInfo' }
+
Quoted 8 lines

include/hw/mem/pc-dimm.h int pc_dimm_get_free_slot(const int *hint, int

Quoted 8 lines
qapi-schema.json +0 -0
 ##
 # @query-cpu-definitions:
 #
include/hw/mem/pc-dimm.h +0 -0
index 6f8c3eb1b3..d83b957829 100644
@@ -95,6 +95,7 @@ int pc_dimm_get_free_slot(const int *hint, int

max_slots, Error **errp);

Quoted 6 lines

include/hw/mem/pc-dimm.h int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp);

Quoted 6 lines
include/hw/mem/pc-dimm.h +1 -0
 int qmp_pc_dimm_device_list(Object *obj, void *opaque);
 uint64_t pc_existing_dimms_capacity(Error **errp);
+uint64_t get_plugged_memory_size(void);
 void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
                          MemoryRegion *mr, uint64_t align, Error

**errp);

Quoted 1 line

include/hw/mem/pc-dimm.h int pc_dimm_get_free_slot(const int *hint, int · line 100

Quoted 1 line
include/hw/mem/pc-dimm.h +0 -0
 void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState

*hpms,

Quoted 8 lines
Quoted 8 lines
hw/mem/pc-dimm.c +0 -0
index bdf6649083..66eace5a5c 100644
@@ -159,6 +159,11 @@ uint64_t pc_existing_dimms_capacity(Error **errp)
     return cap.size;
 }
 
Quoted 13 lines

qmp.c ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error

Quoted 13 lines
hw/mem/pc-dimm.c +5 -0
+uint64_t get_plugged_memory_size(void)
+{
+    return pc_existing_dimms_capacity(&error_abort);
+}
+
 int qmp_pc_dimm_device_list(Object *obj, void *opaque)
 {
     MemoryDeviceInfoList ***prev = opaque;
qmp.c +0 -0
index b86201e349..e8c303116a 100644
@@ -709,3 +709,16 @@ ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error

**errp)

Quoted 37 lines
Quoted 37 lines
qmp.c +13 -0
     return head;
 }
+
+MemoryInfo *qmp_query_memory_size_summary(Error **errp)
+{
+    MemoryInfo *mem_info = g_malloc0(sizeof(MemoryInfo));
+
+    mem_info->base_memory = ram_size;
+
+    mem_info->plugged_memory = get_plugged_memory_size();
+    mem_info->has_plugged_memory =
+        mem_info->plugged_memory != (uint64_t)-1;
+
+    return mem_info;
+}
stubs/qmp_pc_dimm.c renamed from stubs/qmp_pc_dimm_device_list.c +5 -0
similarity index 68%
rename from stubs/qmp_pc_dimm_device_list.c
rename to stubs/qmp_pc_dimm.c
index def211564d..9ddc4f619a 100644
@@ -6,3 +6,8 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque)
 {
    return 0;
 }
+
+uint64_t get_plugged_memory_size(void)
+{
+    return (uint64_t)-1;
+}
stubs/Makefile.objs +0 -0
index e69c217aff..f5f139f310 100644
@@ -33,7 +33,7 @@ stub-obj-y += uuid.o
Quoted 9 lines

stubs/Makefile.objs stub-obj-y += uuid.o · line 39

Quoted 8 lines
stubs/Makefile.objs +1 -1
 stub-obj-y += vm-stop.o
 stub-obj-y += vmstate.o
 stub-obj-$(CONFIG_WIN32) += fd-register.o
-stub-obj-y += qmp_pc_dimm_device_list.o
+stub-obj-y += qmp_pc_dimm.o
 stub-obj-y += target-monitor-defs.o
 stub-obj-y += target-get-monitor-def.o
 stub-obj-y += pc_madt_cpu_entry.o

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#6 lore raw

Re: [Qemu-devel] [PATCH v7 2/3] qmp: introduce query-memory-size-summary command

Review

Quoted 5 lines · * Vadim Galitsyn ([email protected]) wrote:

I think I made a typo here. It should be:

(quoted diff) +3 -0
+# @plugged-memory: size *of* memory that can be hot-unplugged. This field
+#                  is omitted if target does *not* support memory hotplug
+#                  (i.e. CONFIG_MEM_HOTPLUG not defined on build time).

'of' added, took the 'don't' from Igor's review.

Dave

Quoted 187 lines
Quoted 181 lines · Dr. David Alan Gilbert
Quoted 7 lines · * Igor Mammedov ([email protected]) wrote:
Quoted 4 lines · On Tue, 29 Aug 2017 17:30:21 +0200 Vadim Galitsyn…

Add a new query-memory-size-summary command which provides the following memory information in bytes:

* base-memory - size of "base" memory specified with command line

option -m.

Quoted 6 lines
Quoted 6 lines

* plugged-memory - amount of memory that was hot-plugged. If target does not have CONFIG_MEM_HOTPLUG enabled, no value is reported.

profitbricks.com>

Quoted 11 lines
Quoted 11 lines
---
 qapi-schema.json                                   | 32

++++++++++++++++++++++

Quoted 8 lines
Quoted 8 lines
 include/hw/mem/pc-dimm.h                           |  1 +
 hw/mem/pc-dimm.c                                   |  5 ++++
 qmp.c                                              | 13 +++++++++
 stubs/{qmp_pc_dimm_device_list.c => qmp_pc_dimm.c} |  5 ++++
 stubs/Makefile.objs                                |  2 +-
 6 files changed, 57 insertions(+), 1 deletion(-)
 rename stubs/{qmp_pc_dimm_device_list.c => qmp_pc_dimm.c} (68%)
Quoted 6 lines

qapi-schema.json line 4407

Quoted 6 lines
qapi-schema.json +0 -0
index 802ea53d00..9402ac3b3a 100644
@@ -4407,6 +4407,38 @@
   'data': { 'name': 'str', '*migration-safe': 'bool', 'static':

'bool',

Quoted 13 lines

qapi-schema.json

Quoted 13 lines
qapi-schema.json +11 -0
             '*unavailable-features': [ 'str' ], 'typename': 'str' } }
 
+##
+# @MemoryInfo:
+#
+# Actual memory information in bytes.
+#
+# @base-memory: size of "base" memory specified with command line
+#               option -m.
+#
+# @plugged-memory: size memory that can be hot-unplugged. This field
+#                  is omitted if target does support memory hotplug
+#                  (i.e. CONFIG_MEM_HOTPLUG not defined on build

time).

Quoted 2 lines

field description doesn't match what's actually reported. s/cat be/is/

Are you sure about that? That would read:
size memory that is hot-unplugged

which doesn't sound right, since it's not be hot-unplugged yet.

Dave

Quoted 27 lines

s/does/doesn't/

qapi-schema.json line 4431

Quoted 11 lines
qapi-schema.json +11 -0
+#
+# Since: 2.11.0
+##
+{ 'struct': 'MemoryInfo',
+  'data'  : { 'base-memory': 'size', '*plugged-memory': 'size' } }
+
+##
+# @query-memory-size-summary:
+#
+# Return the amount of initially allocated and hot-plugged (if
+# enabled) memory in bytes.

it could count dimm's on CLI, so not only hotplugged

s/hot-plugged/present hotpluggable/

Quoted 10 lines
qapi-schema.json +10 -0
+#
+# Example:
+#
+# -> { "execute": "query-memory-size-summary" }
+# <- { "return": { "base-memory": 4294967296, "plugged-memory": 0 } }
+#
+# Since: 2.11.0
+##
+{ 'command': 'query-memory-size-summary', 'returns': 'MemoryInfo' }
+
Quoted 8 lines

include/hw/mem/pc-dimm.h int pc_dimm_get_free_slot(const int *hint, int

Quoted 8 lines
qapi-schema.json +0 -0
 ##
 # @query-cpu-definitions:
 #
include/hw/mem/pc-dimm.h +0 -0
index 6f8c3eb1b3..d83b957829 100644
@@ -95,6 +95,7 @@ int pc_dimm_get_free_slot(const int *hint, int

max_slots, Error **errp);

Quoted 6 lines

include/hw/mem/pc-dimm.h int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp);

Quoted 6 lines
include/hw/mem/pc-dimm.h +1 -0
 int qmp_pc_dimm_device_list(Object *obj, void *opaque);
 uint64_t pc_existing_dimms_capacity(Error **errp);
+uint64_t get_plugged_memory_size(void);
 void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
                          MemoryRegion *mr, uint64_t align, Error

**errp);

Quoted 1 line

include/hw/mem/pc-dimm.h int pc_dimm_get_free_slot(const int *hint, int · line 100

Quoted 1 line
include/hw/mem/pc-dimm.h +0 -0
 void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState

*hpms,

Quoted 8 lines
Quoted 8 lines
hw/mem/pc-dimm.c +0 -0
index bdf6649083..66eace5a5c 100644
@@ -159,6 +159,11 @@ uint64_t pc_existing_dimms_capacity(Error **errp)
     return cap.size;
 }
 
Quoted 13 lines

qmp.c ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error

Quoted 13 lines
hw/mem/pc-dimm.c +5 -0
+uint64_t get_plugged_memory_size(void)
+{
+    return pc_existing_dimms_capacity(&error_abort);
+}
+
 int qmp_pc_dimm_device_list(Object *obj, void *opaque)
 {
     MemoryDeviceInfoList ***prev = opaque;
qmp.c +0 -0
index b86201e349..e8c303116a 100644
@@ -709,3 +709,16 @@ ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error

**errp)

Quoted 46 lines
Quoted 45 lines
qmp.c +13 -0
     return head;
 }
+
+MemoryInfo *qmp_query_memory_size_summary(Error **errp)
+{
+    MemoryInfo *mem_info = g_malloc0(sizeof(MemoryInfo));
+
+    mem_info->base_memory = ram_size;
+
+    mem_info->plugged_memory = get_plugged_memory_size();
+    mem_info->has_plugged_memory =
+        mem_info->plugged_memory != (uint64_t)-1;
+
+    return mem_info;
+}
stubs/qmp_pc_dimm.c renamed from stubs/qmp_pc_dimm_device_list.c +5 -0
similarity index 68%
rename from stubs/qmp_pc_dimm_device_list.c
rename to stubs/qmp_pc_dimm.c
index def211564d..9ddc4f619a 100644
@@ -6,3 +6,8 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque)
 {
    return 0;
 }
+
+uint64_t get_plugged_memory_size(void)
+{
+    return (uint64_t)-1;
+}
stubs/Makefile.objs +1 -1
index e69c217aff..f5f139f310 100644
@@ -33,7 +33,7 @@ stub-obj-y += uuid.o
 stub-obj-y += vm-stop.o
 stub-obj-y += vmstate.o
 stub-obj-$(CONFIG_WIN32) += fd-register.o
-stub-obj-y += qmp_pc_dimm_device_list.o
+stub-obj-y += qmp_pc_dimm.o
 stub-obj-y += target-monitor-defs.o
 stub-obj-y += target-get-monitor-def.o
 stub-obj-y += pc_madt_cpu_entry.o
Quoted 3 lines
Quoted 3 lines

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK