[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH v4 19/30] Implement "info memory-total" and "que
From: |
Vasilis Liaskovitis |
Subject: |
[Qemu-devel] [RFC PATCH v4 19/30] Implement "info memory-total" and "query-memory-total" |
Date: |
Tue, 18 Dec 2012 13:41:47 +0100 |
Returns total physical memory available to guest in bytes, including hotplugged
memory. Note that the number reported here may be different from what the guest
sees e.g. if the guest has not logically onlined hotplugged memory.
This functionality is provided independently of a balloon device, since a
guest can be using ACPI memory hotplug without using a balloon device.
v3->v4: Moved qmp command implementation to vl.c. This prevents a circular
header dependency problem.
Signed-off-by: Vasilis Liaskovitis <address@hidden>
---
hmp-commands.hx | 2 ++
hmp.c | 7 +++++++
hmp.h | 1 +
hw/dimm.c | 14 ++++++++++++++
hw/dimm.h | 1 +
monitor.c | 7 +++++++
qapi-schema.json | 11 +++++++++++
qmp-commands.hx | 20 ++++++++++++++++++++
vl.c | 9 +++++++++
9 files changed, 72 insertions(+), 0 deletions(-)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 010b8c9..3fbd975 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1570,6 +1570,8 @@ show device tree
show qdev device model list
@item info roms
show roms
address@hidden info memory-total
+show memory-total
@end table
ETEXI
diff --git a/hmp.c b/hmp.c
index 180ba2b..fb39b0d 100644
--- a/hmp.c
+++ b/hmp.c
@@ -628,6 +628,13 @@ void hmp_info_block_jobs(Monitor *mon)
}
}
+void hmp_info_memory_total(Monitor *mon)
+{
+ uint64_t ram_total;
+ ram_total = (uint64_t)qmp_query_memory_total(NULL);
+ monitor_printf(mon, "MemTotal: %lu\n", ram_total);
+}
+
void hmp_quit(Monitor *mon, const QDict *qdict)
{
monitor_suspend(mon);
diff --git a/hmp.h b/hmp.h
index 0ab03be..25a3a70 100644
--- a/hmp.h
+++ b/hmp.h
@@ -36,6 +36,7 @@ void hmp_info_spice(Monitor *mon);
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_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 e384952..f181e54 100644
--- a/hw/dimm.c
+++ b/hw/dimm.c
@@ -189,6 +189,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 int dimm_init(DeviceState *s)
{
DimmBus *bus = DIMM_BUS(qdev_get_parent_bus(s));
diff --git a/hw/dimm.h b/hw/dimm.h
index 75a6911..5130b2c 100644
--- a/hw/dimm.h
+++ b/hw/dimm.h
@@ -85,5 +85,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, uint32_t populated);
+uint64_t get_hp_memory_total(void);
#endif
diff --git a/monitor.c b/monitor.c
index c0e32d6..6e87d0d 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2708,6 +2708,13 @@ static mon_cmd_t info_cmds[] = {
.mhandler.info = hmp_info_balloon,
},
{
+ .name = "memory-total",
+ .args_type = "",
+ .params = "",
+ .help = "show total memory size",
+ .mhandler.info = hmp_info_memory_total,
+ },
+ {
.name = "qtree",
.args_type = "",
.params = "",
diff --git a/qapi-schema.json b/qapi-schema.json
index 5dfa052..33f88d6 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2903,6 +2903,17 @@
{ 'command': 'query-target', 'returns': 'TargetInfo' }
##
+# @query-memory-total:
+#
+# Returns total memory in bytes, including hotplugged dimms
+#
+# Returns: int
+#
+# Since: 1.4
+##
+{ 'command': 'query-memory-total', 'returns': 'int' }
+
+##
# @QKeyCode:
#
# An enumeration of key name.
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 5c692d0..a99117a 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -2654,3 +2654,23 @@ EQMP
.args_type = "",
.mhandler.cmd_new = qmp_marshal_input_query_target,
},
+
+ {
+ .name = "query-memory-total",
+ .args_type = "",
+ .mhandler.cmd_new = qmp_marshal_input_query_memory_total
+ },
+SQMP
+query-memory-total
+----------
+
+Return total memory in bytes, including hotplugged dimms
+
+Example:
+
+-> { "execute": "query-memory-total" }
+<- {
+ "return": 1073741824
+ }
+
+EQMP
diff --git a/vl.c b/vl.c
index 8406933..80803c5 100644
--- a/vl.c
+++ b/vl.c
@@ -126,6 +126,7 @@ int main(int argc, char **argv)
#include "hw/xen.h"
#include "hw/qdev.h"
#include "hw/loader.h"
+#include "hw/dimm.h"
#include "bt-host.h"
#include "net.h"
#include "net/slirp.h"
@@ -442,6 +443,14 @@ StatusInfo *qmp_query_status(Error **errp)
return info;
}
+int64_t qmp_query_memory_total(Error **errp)
+{
+ uint64_t info;
+ info = ram_size + get_hp_memory_total();
+
+ return (int64_t)info;
+}
+
/***********************************************************/
/* real time host monotonic timer */
--
1.7.9
- [Qemu-devel] [RFC PATCH v4 20/30] balloon: update with hotplugged memory, (continued)
- [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, 2012/12/18
- [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 <=
- [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