+++ /dev/null
-Index: new/hmp.c
-===================================================================
---- new.orig/hmp.c 2014-11-20 06:45:05.000000000 +0100
-+++ new/hmp.c 2014-11-20 07:26:23.000000000 +0100
-@@ -635,7 +635,35 @@
- return;
- }
-
-- monitor_printf(mon, "balloon: actual=%" PRId64 "\n", info->actual >> 20);
-+ monitor_printf(mon, "balloon: actual=%" PRId64, info->actual >> 20);
-+ monitor_printf(mon, " max_mem=%" PRId64, info->max_mem >> 20);
-+ if (info->has_total_mem) {
-+ monitor_printf(mon, " total_mem=%" PRId64, info->total_mem >> 20);
-+ }
-+ if (info->has_free_mem) {
-+ monitor_printf(mon, " free_mem=%" PRId64, info->free_mem >> 20);
-+ }
-+
-+ if (info->has_mem_swapped_in) {
-+ monitor_printf(mon, " mem_swapped_in=%" PRId64, info->mem_swapped_in);
-+ }
-+ if (info->has_mem_swapped_out) {
-+ monitor_printf(mon, " mem_swapped_out=%" PRId64, info->mem_swapped_out);
-+ }
-+ if (info->has_major_page_faults) {
-+ monitor_printf(mon, " major_page_faults=%" PRId64,
-+ info->major_page_faults);
-+ }
-+ if (info->has_minor_page_faults) {
-+ monitor_printf(mon, " minor_page_faults=%" PRId64,
-+ info->minor_page_faults);
-+ }
-+ if (info->has_last_update) {
-+ monitor_printf(mon, " last_update=%" PRId64,
-+ info->last_update);
-+ }
-+
-+ monitor_printf(mon, "\n");
-
- qapi_free_BalloonInfo(info);
- }
-Index: new/hw/virtio/virtio-balloon.c
-===================================================================
---- new.orig/hw/virtio/virtio-balloon.c 2014-11-20 06:45:06.000000000 +0100
-+++ new/hw/virtio/virtio-balloon.c 2014-11-20 07:26:23.000000000 +0100
-@@ -319,8 +319,37 @@
- static void virtio_balloon_stat(void *opaque, BalloonInfo *info)
- {
- VirtIOBalloon *dev = opaque;
-- info->actual = get_current_ram_size() - ((uint64_t) dev->actual <<
-- VIRTIO_BALLOON_PFN_SHIFT);
-+ ram_addr_t ram_size = get_current_ram_size();
-+ info->actual = ram_size - ((uint64_t) dev->actual <<
-+ VIRTIO_BALLOON_PFN_SHIFT);
-+
-+ info->max_mem = ram_size;
-+
-+ if (!(balloon_stats_enabled(dev) && balloon_stats_supported(dev) &&
-+ dev->stats_last_update)) {
-+ return;
-+ }
-+
-+ info->last_update = dev->stats_last_update;
-+ info->has_last_update = true;
-+
-+ info->mem_swapped_in = dev->stats[VIRTIO_BALLOON_S_SWAP_IN];
-+ info->has_mem_swapped_in = info->mem_swapped_in >= 0 ? true : false;
-+
-+ info->mem_swapped_out = dev->stats[VIRTIO_BALLOON_S_SWAP_OUT];
-+ info->has_mem_swapped_out = info->mem_swapped_out >= 0 ? true : false;
-+
-+ info->major_page_faults = dev->stats[VIRTIO_BALLOON_S_MAJFLT];
-+ info->has_major_page_faults = info->major_page_faults >= 0 ? true : false;
-+
-+ info->minor_page_faults = dev->stats[VIRTIO_BALLOON_S_MINFLT];
-+ info->has_minor_page_faults = info->minor_page_faults >= 0 ? true : false;
-+
-+ info->free_mem = dev->stats[VIRTIO_BALLOON_S_MEMFREE];
-+ info->has_free_mem = info->free_mem >= 0 ? true : false;
-+
-+ info->total_mem = dev->stats[VIRTIO_BALLOON_S_MEMTOT];
-+ info->has_total_mem = info->total_mem >= 0 ? true : false;
- }
-
- static void virtio_balloon_to_target(void *opaque, ram_addr_t target)
-Index: new/qapi-schema.json
-===================================================================
---- new.orig/qapi-schema.json 2014-11-20 06:45:06.000000000 +0100
-+++ new/qapi-schema.json 2014-11-20 07:26:23.000000000 +0100
-@@ -983,10 +983,29 @@
- #
- # @actual: the number of bytes the balloon currently contains
- #
--# Since: 0.14.0
-+# @last_update: #optional time when stats got updated from guest
-+#
-+# @mem_swapped_in: #optional number of pages swapped in within the guest
-+#
-+# @mem_swapped_out: #optional number of pages swapped out within the guest
-+#
-+# @major_page_faults: #optional number of major page faults within the guest
- #
-+# @minor_page_faults: #optional number of minor page faults within the guest
-+#
-+# @free_mem: #optional amount of memory (in bytes) free in the guest
-+#
-+# @total_mem: #optional amount of memory (in bytes) visible to the guest
-+#
-+# @max_mem: amount of memory (in bytes) assigned to the guest
-+#
-+# Since: 0.14.0
- ##
--{ 'struct': 'BalloonInfo', 'data': {'actual': 'int' } }
-+{ 'struct': 'BalloonInfo',
-+ 'data': {'actual': 'int', '*last_update': 'int', '*mem_swapped_in': 'int',
-+ '*mem_swapped_out': 'int', '*major_page_faults': 'int',
-+ '*minor_page_faults': 'int', '*free_mem': 'int',
-+ '*total_mem': 'int', 'max_mem': 'int' } }
-
- ##
- # @query-balloon:
-Index: new/qmp-commands.hx
-===================================================================
---- new.orig/qmp-commands.hx 2014-11-20 06:45:06.000000000 +0100
-+++ new/qmp-commands.hx 2014-11-20 07:26:23.000000000 +0100
-@@ -3329,6 +3329,13 @@
- json-object will be returned containing the following data:
-
- - "actual": current balloon value in bytes (json-int)
-+- "mem_swapped_in": Amount of memory swapped in bytes (json-int, optional)
-+- "mem_swapped_out": Amount of memory swapped out in bytes (json-int, optional)
-+- "major_page_faults": Number of major faults (json-int, optional)
-+- "minor_page_faults": Number of minor faults (json-int, optional)
-+- "free_mem": Total amount of free and unused memory in
-+ bytes (json-int, optional)
-+- "total_mem": Total amount of available memory in bytes (json-int, optional)
-
- Example:
-
-@@ -3336,6 +3344,12 @@
- <- {
- "return":{
- "actual":1073741824,
-+ "mem_swapped_in":0,
-+ "mem_swapped_out":0,
-+ "major_page_faults":142,
-+ "minor_page_faults":239245,
-+ "free_mem":1014185984,
-+ "total_mem":1044668416
- }
- }
-