diff mbox series

[RFC,v2,4/5] virtio-balloon: Add HMP functions for Working Set

Message ID 20230525222016.35333-5-talumbau@google.com
State New
Headers show
Series virtio-balloon: Working Set Reporting | expand

Commit Message

T.J. Alumbaugh May 25, 2023, 10:20 p.m. UTC
- Adds 'working_set_request', 'working_set_config' HMP functions

Start qemu with '-monitor telnet:127.0.0.1:4444,server=on,wait=off'

>> telnet localhost 4444

(qemu) working_set_config 200 800 3000 750 1000
(qemu) working_set_request
(qemu) qom-get /machine/peripheral/balloon0 guest-working-set
{
    "working_set": {
        "ws3": {
            "memory-size-bytes": {
                "anon": 298287104,
                "file": 647041024
            },
            "idle-age": 4294967292
        },
        "ws2": {
            "memory-size-bytes": {
                "anon": 4505600,
                "file": 2252800
            },
            "idle-age": 3000
        },
        "ws1": {
            "memory-size-bytes": {
                "anon": 1228800,
                "file": 614400
            },
            "idle-age": 800
        },
        "ws0": {
            "memory-size-bytes": {
                "anon": 409600,
                "file": 204800
            },
            "idle-age": 200
        }
    }
}

Signed-off-by: T.J. Alumbaugh <talumbau@google.com>
---
 hmp-commands.hx            | 26 ++++++++++++++++++++++++++
 hw/core/machine-hmp-cmds.c | 21 +++++++++++++++++++++
 include/monitor/hmp.h      |  2 ++
 3 files changed, 49 insertions(+)
diff mbox series

Patch

diff --git a/hmp-commands.hx b/hmp-commands.hx
index 2cbd0f77a0..8ed044b23f 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1398,6 +1398,32 @@  SRST
   Request VM to change its memory allocation to *value* (in MB).
 ERST
 
+    {
+        .name       = "working_set_config",
+        .args_type  = "i0:i,i1:i,i2:i,refresh:i,report:i",
+        .params     = "bin intervals 0-2, refresh and report thresholds",
+        .help       = "Working Set intervals, refresh/report thresholds (ms)",
+        .cmd        = hmp_working_set_config,
+    },
+
+SRST
+``working_set_config``
+  Set the intervals (in ms), refresh, report thresholds for Working Set reporting
+ERST
+
+    {
+        .name       = "working_set_request",
+        .args_type  = "",
+        .params     = "",
+        .help       = "Request the Working Set of the guest.",
+        .cmd        = hmp_working_set_request,
+    },
+
+SRST
+``working_set_request``
+  Request the Working Set from the guest.
+ERST
+
     {
         .name       = "set_link",
         .args_type  = "name:s,up:b",
diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
index c3e55ef9e9..3c0a7694a2 100644
--- a/hw/core/machine-hmp-cmds.c
+++ b/hw/core/machine-hmp-cmds.c
@@ -237,6 +237,27 @@  void hmp_balloon(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, err);
 }
 
+void hmp_working_set_request(Monitor *mon, const QDict *qdict)
+{
+    Error *err = NULL;
+
+    qmp_working_set_request(&err);
+    hmp_handle_error(mon, err);
+}
+
+void hmp_working_set_config(Monitor *mon, const QDict *qdict)
+{
+    uint64_t i0 = qdict_get_int(qdict, "i0");
+    uint64_t i1 = qdict_get_int(qdict, "i1");
+    uint64_t i2 = qdict_get_int(qdict, "i2");
+    uint64_t refresh = qdict_get_int(qdict, "refresh");
+    uint64_t report = qdict_get_int(qdict, "report");
+    Error *err = NULL;
+
+    qmp_working_set_config(i0, i1, i2, refresh, report, &err);
+    hmp_handle_error(mon, err);
+}
+
 void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
 {
     Error *err = NULL;
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index 13f9a2dedb..a1e6c5e92a 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -59,6 +59,8 @@  void hmp_nmi(Monitor *mon, const QDict *qdict);
 void hmp_info_network(Monitor *mon, const QDict *qdict);
 void hmp_set_link(Monitor *mon, const QDict *qdict);
 void hmp_balloon(Monitor *mon, const QDict *qdict);
+void hmp_working_set_config(Monitor *mon, const QDict *qdict);
+void hmp_working_set_request(Monitor *mon, const QDict *qdict);
 void hmp_loadvm(Monitor *mon, const QDict *qdict);
 void hmp_savevm(Monitor *mon, const QDict *qdict);
 void hmp_delvm(Monitor *mon, const QDict *qdict);