diff options
| author | Philippe Mathieu-Daudé <philmd@linaro.org> | 2025-07-02 15:03:12 +0200 |
|---|---|---|
| committer | Philippe Mathieu-Daudé <philmd@linaro.org> | 2025-07-15 19:34:33 +0200 |
| commit | 1861993f1fc13e42afed6a618c45a5a95a1457ea (patch) | |
| tree | 2a7e391e7fbe61988ce5e03138dfc0b8a5c20b48 /accel/accel-qmp.c | |
| parent | 8cc04fd9df3b9775eaf0fb1b17d82a1a075aa3ec (diff) | |
| download | focaccia-qemu-1861993f1fc13e42afed6a618c45a5a95a1457ea.tar.gz focaccia-qemu-1861993f1fc13e42afed6a618c45a5a95a1457ea.zip | |
accel/system: Introduce @x-accel-stats QMP command
Unstable QMP 'x-accel-stats' dispatches to the AccelOpsClass::get_stats() and get_vcpu_stats() handlers. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Reviewed-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Message-Id: <20250715140048.84942-4-philmd@linaro.org>
Diffstat (limited to 'accel/accel-qmp.c')
| -rw-r--r-- | accel/accel-qmp.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/accel/accel-qmp.c b/accel/accel-qmp.c new file mode 100644 index 0000000000..5fb70c6631 --- /dev/null +++ b/accel/accel-qmp.c @@ -0,0 +1,35 @@ +/* + * QMP commands related to accelerators + * + * Copyright (c) Linaro + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/accel.h" +#include "qapi/type-helpers.h" +#include "qapi/qapi-commands-accelerator.h" +#include "accel/accel-ops.h" +#include "accel/accel-cpu-ops.h" +#include "hw/core/cpu.h" + +HumanReadableText *qmp_x_accel_stats(Error **errp) +{ + AccelState *accel = current_accel(); + AccelClass *acc = ACCEL_GET_CLASS(accel); + g_autoptr(GString) buf = g_string_new(""); + + if (acc->get_stats) { + acc->get_stats(accel, buf); + } + if (acc->ops->get_vcpu_stats) { + CPUState *cpu; + + CPU_FOREACH(cpu) { + acc->ops->get_vcpu_stats(cpu, buf); + } + } + + return human_readable_text_from_str(buf); +} |