mirror of
https://github.com/qemu/qemu.git
synced 2026-02-04 05:35:39 +00:00
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>
This commit is contained in:
35
accel/accel-qmp.c
Normal file
35
accel/accel-qmp.c
Normal file
@@ -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);
|
||||
}
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/accel.h"
|
||||
#include "hw/boards.h"
|
||||
#include "hw/core/cpu.h"
|
||||
#include "accel/accel-ops.h"
|
||||
#include "accel/accel-cpu-ops.h"
|
||||
#include "system/cpus.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
common_ss.add(files('accel-common.c'))
|
||||
specific_ss.add(files('accel-target.c'))
|
||||
system_ss.add(files('accel-system.c', 'accel-blocker.c'))
|
||||
system_ss.add(files('accel-system.c', 'accel-blocker.c', 'accel-qmp.c'))
|
||||
user_ss.add(files('accel-user.c'))
|
||||
|
||||
subdir('tcg')
|
||||
|
||||
@@ -65,6 +65,9 @@ struct AccelOpsClass {
|
||||
/* handle_interrupt is mandatory. */
|
||||
void (*handle_interrupt)(CPUState *cpu, int mask);
|
||||
|
||||
/* get_vcpu_stats: Append statistics of this @cpu to @buf */
|
||||
void (*get_vcpu_stats)(CPUState *cpu, GString *buf);
|
||||
|
||||
/**
|
||||
* @get_virtual_clock: fetch virtual clock
|
||||
* @set_virtual_clock: set virtual clock
|
||||
|
||||
@@ -25,6 +25,8 @@ struct AccelClass {
|
||||
int (*init_machine)(AccelState *as, MachineState *ms);
|
||||
bool (*cpu_common_realize)(CPUState *cpu, Error **errp);
|
||||
void (*cpu_common_unrealize)(CPUState *cpu);
|
||||
/* get_stats: Append statistics to @buf */
|
||||
void (*get_stats)(AccelState *as, GString *buf);
|
||||
|
||||
/* system related hooks */
|
||||
void (*setup_post)(AccelState *as);
|
||||
|
||||
@@ -37,3 +37,20 @@
|
||||
# <- { "return": { "enabled": true, "present": true } }
|
||||
##
|
||||
{ 'command': 'query-kvm', 'returns': 'KvmInfo' }
|
||||
|
||||
##
|
||||
# @x-accel-stats:
|
||||
#
|
||||
# Query accelerator statistics
|
||||
#
|
||||
# Features:
|
||||
#
|
||||
# @unstable: This command is meant for debugging.
|
||||
#
|
||||
# Returns: accelerator statistics
|
||||
#
|
||||
# Since: 10.1
|
||||
##
|
||||
{ 'command': 'x-accel-stats',
|
||||
'returns': 'HumanReadableText',
|
||||
'features': [ 'unstable' ] }
|
||||
|
||||
Reference in New Issue
Block a user