[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 14/14] Implement dimm-info
From: |
Hu Tao |
Subject: |
[Qemu-devel] [PATCH v5 14/14] Implement dimm-info |
Date: |
Wed, 26 Jun 2013 17:13:37 +0800 |
From: Vasilis Liaskovitis <address@hidden>
"query-dimm-info" and "info dimm" will give current state of all dimms in the
system e.g.
dimm0: on
dimm1: off
dimm2: off
dimm3: on
etc.
Signed-off-by: Vasilis Liaskovitis <address@hidden>
Signed-off-by: Hu Tao <address@hidden>
---
hmp-commands.hx | 2 ++
hmp.c | 17 +++++++++++++++++
hmp.h | 1 +
hw/mem-hotplug/dimm.c | 43 +++++++++++++++++++++++++++++++++++++++++++
monitor.c | 7 +++++++
qapi-schema.json | 27 +++++++++++++++++++++++++++
6 files changed, 97 insertions(+)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index b2937c2..6cb1285 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1657,6 +1657,8 @@ show roms
show memory-total
@item info tpm
show the TPM device
address@hidden info dimm
+show dimm
@end table
ETEXI
diff --git a/hmp.c b/hmp.c
index 0371da9..04586b3 100644
--- a/hmp.c
+++ b/hmp.c
@@ -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);
diff --git a/hmp.h b/hmp.h
index b5a5afb..06cea4e 100644
--- a/hmp.h
+++ b/hmp.h
@@ -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);
diff --git a/hw/mem-hotplug/dimm.c b/hw/mem-hotplug/dimm.c
index da31a18..4b08706 100644
--- a/hw/mem-hotplug/dimm.c
+++ b/hw/mem-hotplug/dimm.c
@@ -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;
diff --git a/monitor.c b/monitor.c
index 14a955e..c2b046c 100644
--- a/monitor.c
+++ b/monitor.c
@@ -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 = "",
diff --git a/qapi-schema.json b/qapi-schema.json
index d2940dc..88bbfac 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -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'] }
--
1.8.3.1
- [Qemu-devel] [PATCH v5 06/14] acpi_piix4 : Implement memory device hotplug registers, (continued)
- [Qemu-devel] [PATCH v5 06/14] acpi_piix4 : Implement memory device hotplug registers, Hu Tao, 2013/06/26
- [Qemu-devel] [PATCH v5 11/14] Introduce paravirt interface QEMU_CFG_PCI_WINDOW, Hu Tao, 2013/06/26
- [Qemu-devel] [PATCH v5 09/14] memory controller: initialize dram controller., Hu Tao, 2013/06/26
- [Qemu-devel] [PATCH v5 04/14] Implement dimm device abstraction, Hu Tao, 2013/06/26
- [Qemu-devel] [PATCH v5 13/14] balloon: update with hotplugged memory, Hu Tao, 2013/06/26
- [Qemu-devel] [PATCH v5 07/14] acpi_ich9 : Implement memory device hotplug registers, Hu Tao, 2013/06/26
- [Qemu-devel] [PATCH v5 10/14] pc: Add dimm paravirt SRAT info, Hu Tao, 2013/06/26
- [Qemu-devel] [PATCH v5 12/14] Implement "info memory" and "query-memory", Hu Tao, 2013/06/26
- [Qemu-devel] [PATCH v5 08/14] memory: record below_4g_mem_size, above_4g_mem_size, Hu Tao, 2013/06/26
- [Qemu-devel] [PATCH v5 14/14] Implement dimm-info,
Hu Tao <=
- [Qemu-devel] [PATCH v5 0/7] support for ACPI memory hotplug, Hu Tao, 2013/06/26
- [Qemu-devel] [PATCH v5 1/7] Add ACPI_EXTRACT_DEVICE* macros, Hu Tao, 2013/06/26
- [Qemu-devel] [PATCH v5 2/7] Add SSDT memory device support, Hu Tao, 2013/06/26
- [Qemu-devel] [PATCH v5 4/7] set psize to 0 when romfile_loadfile failed, Hu Tao, 2013/06/26
- [Qemu-devel] [PATCH v5 3/7] acpi-dsdt: Implement functions for memory hotplug, Hu Tao, 2013/06/26
- [Qemu-devel] [PATCH v5 6/7] q35: Add memory hotplug handler, Hu Tao, 2013/06/26
- [Qemu-devel] [PATCH v5 7/7] pci: Use paravirt interface for pcimem_start and pcimem64_start, Hu Tao, 2013/06/26
- [Qemu-devel] [PATCH v5 5/7] acpi: generate hotplug memory devices, Hu Tao, 2013/06/26