From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
-Date: Tue, 10 Mar 2020 12:55:11 +0100
-Subject: [PATCH 14/32] PVE: virtio-balloon: improve query-balloon
+Date: Mon, 6 Apr 2020 12:16:43 +0200
+Subject: [PATCH] PVE: virtio-balloon: improve query-balloon
Actually provide memory information via the query-balloon
command.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
+[FE: add BalloonInfo to member name exceptions list
+ rebase for 8.0 - moved to hw/core/machine-hmp-cmds.c]
+Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
+ hw/core/machine-hmp-cmds.c | 30 +++++++++++++++++++++++++++++-
hw/virtio/virtio-balloon.c | 33 +++++++++++++++++++++++++++++++--
- monitor/hmp-cmds.c | 30 +++++++++++++++++++++++++++++-
- qapi/misc.json | 22 +++++++++++++++++++++-
- 3 files changed, 81 insertions(+), 4 deletions(-)
+ qapi/machine.json | 22 +++++++++++++++++++++-
+ qapi/pragma.json | 1 +
+ 4 files changed, 82 insertions(+), 4 deletions(-)
+diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
+index c3e55ef9e9..0e32e6201f 100644
+--- a/hw/core/machine-hmp-cmds.c
++++ b/hw/core/machine-hmp-cmds.c
+@@ -169,7 +169,35 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
+ 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);
+ }
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
-index 40b04f5180..76e907e628 100644
+index 746f07c4d2..a41854b902 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
-@@ -713,8 +713,37 @@ static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f,
+@@ -804,8 +804,37 @@ static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f,
static void virtio_balloon_stat(void *opaque, BalloonInfo *info)
{
VirtIOBalloon *dev = opaque;
}
static void virtio_balloon_to_target(void *opaque, ram_addr_t target)
-diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
-index b2551c16d1..2e725ed818 100644
---- a/monitor/hmp-cmds.c
-+++ b/monitor/hmp-cmds.c
-@@ -854,7 +854,35 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
- 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);
- }
-diff --git a/qapi/misc.json b/qapi/misc.json
-index 33b94e3589..ed65ed27e3 100644
---- a/qapi/misc.json
-+++ b/qapi/misc.json
-@@ -408,10 +408,30 @@
- #
- # @actual: the number of bytes the balloon currently contains
+diff --git a/qapi/machine.json b/qapi/machine.json
+index 604b686e59..15f5f86683 100644
+--- a/qapi/machine.json
++++ b/qapi/machine.json
+@@ -1056,9 +1056,29 @@
+ # @actual: the logical size of the VM in bytes
+ # Formula used: logical_vm_size = vm_ram_size - balloon_size
#
+# @last_update: time when stats got updated from guest
+#
+#
+# @max_mem: amount of memory (in bytes) assigned to the guest
+#
- # Since: 0.14.0
- #
+ # Since: 0.14
##
-{ 'struct': 'BalloonInfo', 'data': {'actual': 'int' } }
+{ 'struct': 'BalloonInfo',
##
# @query-balloon:
+diff --git a/qapi/pragma.json b/qapi/pragma.json
+index 29233db825..f2097b9020 100644
+--- a/qapi/pragma.json
++++ b/qapi/pragma.json
+@@ -37,6 +37,7 @@
+ 'member-name-exceptions': [ # visible in:
+ 'ACPISlotType', # query-acpi-ospm-status
+ 'AcpiTableOptions', # -acpitable
++ 'BalloonInfo', # query-balloon
+ 'BlkdebugEvent', # blockdev-add, -blockdev
+ 'BlkdebugSetStateOptions', # blockdev-add, -blockdev
+ 'BlockDeviceInfo', # query-block