@@ -1657,6 +1657,8 @@ show roms
show memory-total
@item info tpm
show the TPM device
+@item info dimm
+show dimm
@end table
ETEXI
@@ -683,6 +683,23 @@ void hmp_info_memory(Monitor *mon, const QDict *qdict)
qapi_free_MemoryInfo(mem);
}
+void hmp_info_dimm(Monitor *mon, const QDict *qdict)
+{
+ DimmInfoList *info;
+ DimmInfoList *item;
+ DimmInfo *dimm;
+
+ info = qmp_query_dimm_info(NULL);
+ for (item = info; item; item = item->next) {
+ dimm = item->value;
+ monitor_printf(mon, "dimm %s : %s\n", dimm->dimm,
+ dimm->state ? "on" : "off");
+ dimm->dimm = NULL;
+ }
+
+ qapi_free_DimmInfoList(info);
+}
+
void hmp_quit(Monitor *mon, const QDict *qdict)
{
monitor_suspend(mon);
@@ -38,6 +38,7 @@ 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_info_dimm(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);
@@ -170,6 +170,18 @@ static DimmConfig *dimmcfg_find_from_name(DimmBus *bus, const char *name)
return NULL;
}
+static DimmDevice *dimm_find_from_name(DimmBus *bus, const char *name)
+{
+ DimmDevice *slot;
+
+ QTAILQ_FOREACH(slot, &bus->dimmlist, nextdimm) {
+ if (!strcmp(slot->qdev.id, name)) {
+ return slot;
+ }
+ }
+ return NULL;
+}
+
void dimm_setup_fwcfg_layout(uint64_t *fw_cfg_slots)
{
DimmConfig *slot;
@@ -185,6 +197,37 @@ void dimm_setup_fwcfg_layout(uint64_t *fw_cfg_slots)
}
}
+DimmInfoList *qmp_query_dimm_info(Error **errp)
+{
+ DimmBus *bus;
+ DimmConfig *slot;
+ DimmInfoList *head = NULL, *info, *cur_item = NULL;
+
+ QLIST_FOREACH(bus, &memory_buses, next) {
+ QTAILQ_FOREACH(slot, &bus->dimmconfig_list, nextdimmcfg) {
+
+ info = g_malloc0(sizeof(*info));
+ info->value = g_malloc0(sizeof(*info->value));
+ info->value->dimm = g_malloc0(sizeof(char) * 32);
+ strcpy(info->value->dimm, slot->name);
+ if (dimm_find_from_name(bus, slot->name)) {
+ info->value->state = 1;
+ } else {
+ info->value->state = 0;
+ }
+ /* XXX: waiting for the qapi to support GSList */
+ if (!cur_item) {
+ head = cur_item = info;
+ } else {
+ cur_item->next = info;
+ cur_item = info;
+ }
+ }
+ }
+
+ return head;
+}
+
uint64_t get_hp_memory_total(void)
{
DimmBus *bus;
@@ -2753,6 +2753,13 @@ static mon_cmd_t info_cmds[] = {
.mhandler.cmd = do_trace_print_events,
},
{
+ .name = "dimm",
+ .args_type = "",
+ .params = "",
+ .help = "show active and non active dimms",
+ .mhandler.cmd = hmp_info_dimm,
+ },
+ {
.name = "tpm",
.args_type = "",
.params = "",
@@ -3621,3 +3621,30 @@
{ 'type': 'MemoryInfo',
'data': { 'total': 'int' } }
{ 'command': 'query-memory', 'returns': 'MemoryInfo' }
+
+##
+# @DimmInfo:
+#
+# Information about status of dimm device
+#
+# @dimm: the name of the dimm
+#
+# @state: 'true' means the dimm device is plugged in, 'false' means
+# means the dimm device is plugged out.
+#
+# Since: 1.6
+#
+##
+{ 'type': 'DimmInfo',
+ 'data': {'dimm': 'str', 'state': 'bool'} }
+
+##
+# @query-dimm-info:
+#
+# Returns the state of dimm devices
+#
+# Returns: list of @DimmInfo
+#
+# Since: 1.6
+##
+{ 'command': 'query-dimm-info', 'returns': ['DimmInfo'] }