[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH v4 21/30] Implement dimm-info
From: |
Vasilis Liaskovitis |
Subject: |
[Qemu-devel] [RFC PATCH v4 21/30] Implement dimm-info |
Date: |
Tue, 18 Dec 2012 13:41:49 +0100 |
"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>
---
hmp-commands.hx | 2 ++
hmp.c | 17 +++++++++++++++++
hmp.h | 1 +
hw/dimm.c | 43 +++++++++++++++++++++++++++++++++++++++++++
monitor.c | 7 +++++++
qapi-schema.json | 26 ++++++++++++++++++++++++++
6 files changed, 96 insertions(+), 0 deletions(-)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 3fbd975..65d799e 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1572,6 +1572,8 @@ show qdev device model list
show roms
@item info memory-total
show memory-total
address@hidden info dimm
+show dimm
@end table
ETEXI
diff --git a/hmp.c b/hmp.c
index fb39b0d..f8456fd 100644
--- a/hmp.c
+++ b/hmp.c
@@ -635,6 +635,23 @@ void hmp_info_memory_total(Monitor *mon)
monitor_printf(mon, "MemTotal: %lu\n", ram_total);
}
+void hmp_info_dimm(Monitor *mon)
+{
+ 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 25a3a70..74ac061 100644
--- a/hmp.h
+++ b/hmp.h
@@ -37,6 +37,7 @@ void hmp_info_balloon(Monitor *mon);
void hmp_info_pci(Monitor *mon);
void hmp_info_block_jobs(Monitor *mon);
void hmp_info_memory_total(Monitor *mon);
+void hmp_info_dimm(Monitor *mon);
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/dimm.c b/hw/dimm.c
index f181e54..e79f23d 100644
--- a/hw/dimm.c
+++ b/hw/dimm.c
@@ -174,6 +174,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;
@@ -203,6 +215,37 @@ uint64_t get_hp_memory_total(void)
return info;
}
+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;
+}
+
static int dimm_init(DeviceState *s)
{
DimmBus *bus = DIMM_BUS(qdev_get_parent_bus(s));
diff --git a/monitor.c b/monitor.c
index 6e87d0d..de1dcf1 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2743,6 +2743,13 @@ static mon_cmd_t info_cmds[] = {
.mhandler.info = do_trace_print_events,
},
{
+ .name = "dimm",
+ .args_type = "",
+ .params = "",
+ .help = "show active and non active dimms",
+ .mhandler.info = hmp_info_dimm,
+ },
+ {
.name = NULL,
},
};
diff --git a/qapi-schema.json b/qapi-schema.json
index 33f88d6..5a20577 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2914,6 +2914,32 @@
{ 'command': 'query-memory-total', 'returns': 'int' }
##
+# @DimmInfo:
+#
+# Information about status of a memory hotplug command
+#
+# @dimm: the Dimm associated with the result
+#
+# @result: the result of the hotplug command
+#
+# Since: 1.4
+#
+##
+{ 'type': 'DimmInfo',
+ 'data': {'dimm': 'str', 'state': 'bool'} }
+
+##
+# @query-dimm-info:
+#
+# Returns total memory in bytes, including hotplugged dimms
+#
+# Returns: int
+#
+# Since: 1.4
+##
+{ 'command': 'query-dimm-info', 'returns': ['DimmInfo'] }
+
+##
# @QKeyCode:
#
# An enumeration of key name.
--
1.7.9
- [Qemu-devel] [RFC PATCH v4 16/30] pc: Add dimm paravirt SRAT info, (continued)
- [Qemu-devel] [RFC PATCH v4 16/30] pc: Add dimm paravirt SRAT info, Vasilis Liaskovitis, 2012/12/18
- [Qemu-devel] [RFC PATCH v4 11/30] acpi_piix4 : Implement memory device hotplug registers, Vasilis Liaskovitis, 2012/12/18
- [Qemu-devel] [RFC PATCH v4 14/30] piix_pci: Add i440fx dram controller initialization, Vasilis Liaskovitis, 2012/12/18
- [Qemu-devel] [RFC PATCH v4 18/30] Introduce paravirt interface QEMU_CFG_PCI_WINDOW, Vasilis Liaskovitis, 2012/12/18
- [Qemu-devel] [RFC PATCH v4 20/30] balloon: update with hotplugged memory, Vasilis Liaskovitis, 2012/12/18
- [Qemu-devel] [RFC PATCH v4 26/30] Implement qmp and hmp commands for notification lists, Vasilis Liaskovitis, 2012/12/18
- [Qemu-devel] [RFC PATCH v4 29/30] [SeaBIOS] Implement _PS3 method for memory device, Vasilis Liaskovitis, 2012/12/18
- [Qemu-devel] [RFC PATCH v4 30/30] Implement _PS3 for dimm, Vasilis Liaskovitis, 2012/12/18
- [Qemu-devel] [RFC PATCH v4 28/30] Add _OST dimm support, Vasilis Liaskovitis, 2012/12/18
- [Qemu-devel] [RFC PATCH v4 27/30] [SeaBIOS] Add _OST dimm method, Vasilis Liaskovitis, 2012/12/18
- [Qemu-devel] [RFC PATCH v4 21/30] Implement dimm-info,
Vasilis Liaskovitis <=
- [Qemu-devel] [RFC PATCH v4 23/30] dimm: add hot-remove capability, Vasilis Liaskovitis, 2012/12/18
- [Qemu-devel] [RFC PATCH v4 25/30] acpi_ich9: add hot-remove capability, Vasilis Liaskovitis, 2012/12/18
- [Qemu-devel] [RFC PATCH v4 19/30] Implement "info memory-total" and "query-memory-total", Vasilis Liaskovitis, 2012/12/18
- [Qemu-devel] [RFC PATCH v4 22/30] [SeaBIOS] acpi: add _EJ0 operation and eject port for memory devices, Vasilis Liaskovitis, 2012/12/18
- [Qemu-devel] [RFC PATCH v4 24/30] acpi_piix4: add hot-remove capability, Vasilis Liaskovitis, 2012/12/18
- Re: [Qemu-devel] [RFC PATCH v4 00/30] ACPI memory hotplug, Zhi Yong Wu, 2012/12/18
- Re: [Qemu-devel] [RFC PATCH v4 00/30] ACPI memory hotplug, Gerd Hoffmann, 2012/12/19