Browse Source
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>pull/294/head
6 changed files with 59 additions and 1 deletions
@ -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); |
|||
} |
|||
Loading…
Reference in new issue