@@ -1653,6 +1653,8 @@ show device tree
show qdev device model list
@item info roms
show roms
+@item info memory-total
+show memory-total
@item info tpm
show the TPM device
@end table
@@ -675,6 +675,14 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict)
qapi_free_TPMInfoList(info_list);
}
+void hmp_info_memory(Monitor *mon, const QDict *qdict)
+{
+ MemoryInfo *mem;
+ mem = qmp_query_memory(NULL);
+ monitor_printf(mon, "MemTotal: %" PRIu64 "\n", mem->total);
+ qapi_free_MemoryInfo(mem);
+}
+
void hmp_quit(Monitor *mon, const QDict *qdict)
{
monitor_suspend(mon);
@@ -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_memory(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);
@@ -185,6 +185,20 @@ void dimm_setup_fwcfg_layout(uint64_t *fw_cfg_slots)
}
}
+uint64_t get_hp_memory_total(void)
+{
+ DimmBus *bus;
+ DimmDevice *slot;
+ uint64_t info = 0;
+
+ QLIST_FOREACH(bus, &memory_buses, next) {
+ QTAILQ_FOREACH(slot, &bus->dimmlist, nextdimm) {
+ info += slot->size;
+ }
+ }
+ return info;
+}
+
static void dimm_realize(DeviceState *s, Error **errp)
{
DimmBus *bus = DIMM_BUS(qdev_get_parent_bus(s));
@@ -73,5 +73,6 @@ DimmBus *dimm_bus_create(Object *parent, const char *name, uint32_t max_dimms,
dimm_calcoffset_fn pmc_set_offset);
void dimm_config_create(char *id, uint64_t size, const char *bus, uint64_t node,
uint32_t dimm_idx);
+uint64_t get_hp_memory_total(void);
#endif
@@ -2760,6 +2760,13 @@ static mon_cmd_t info_cmds[] = {
.mhandler.cmd = hmp_info_tpm,
},
{
+ .name = "memory",
+ .args_type = "",
+ .params = "",
+ .help = "show memory informations including total memory size",
+ .mhandler.cmd = hmp_info_memory,
+ },
+ {
.name = NULL,
},
};
@@ -3608,3 +3608,16 @@
'*cpuid-input-ecx': 'int',
'cpuid-register': 'X86CPURegister32',
'features': 'int' } }
+
+##
+# @query-memory:
+#
+# Returns total memory in bytes, including hotplugged dimms
+#
+# Returns: int
+#
+# Since: 1.6
+##
+{ 'type': 'MemoryInfo',
+ 'data': { 'total': 'int' } }
+{ 'command': 'query-memory', 'returns': 'MemoryInfo' }
@@ -2997,3 +2997,25 @@ Example:
<- { "return": {} }
EQMP
+
+ {
+ .name = "query-memory",
+ .args_type = "",
+ .mhandler.cmd_new = qmp_marshal_input_query_memory
+ },
+SQMP
+query-memory
+----------
+
+Return a json-object with the following information:
+
+- "total": total memory in bytes, including hotplugged dimms
+
+Example:
+
+-> { "execute": "query-memory" }
+<- {
+ "return": { "total": 1073741824 }
+ }
+
+EQMP
@@ -671,6 +671,15 @@ StatusInfo *qmp_query_status(Error **errp)
return info;
}
+MemoryInfo *qmp_query_memory(Error **errp)
+{
+ MemoryInfo *info = g_malloc0(sizeof(*info));
+
+ info->total = ram_size + get_hp_memory_total();
+
+ return info;
+}
+
/***********************************************************/
/* real time host monotonic timer */