@@ -41,6 +41,7 @@ typedef struct AccelClass {
AccelOpsClass *ops;
int (*init_machine)(MachineState *ms, AccelState *as);
+ void (*get_stats)(AccelState *as, GString *buf);
/* system related hooks */
void (*setup_post)(MachineState *ms, AccelState *accel);
@@ -51,6 +51,8 @@ struct AccelOpsClass {
void (*handle_interrupt)(CPUState *cpu, int mask);
+ void (*get_vcpu_stats)(CPUState *cpu, GString *buf);
+
/**
* @get_virtual_clock: fetch virtual clock
* @set_virtual_clock: set virtual clock
@@ -25,6 +25,8 @@
#include "qemu/osdep.h"
#include "qemu/accel.h"
+#include "qapi/type-helpers.h"
+#include "monitor/monitor.h"
#include "hw/boards.h"
#include "system/accel-ops.h"
#include "system/cpus.h"
@@ -72,6 +74,26 @@ bool cpus_are_resettable(void)
return true;
}
+static HumanReadableText *hmp_info_accel(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);
+}
+
/* initialize the arch-independent accel operation interfaces */
void accel_init_ops_interfaces(AccelClass *ac)
{
@@ -102,11 +124,17 @@ void accel_init_ops_interfaces(AccelClass *ac)
cpus_register_accel(ops);
}
+static void accel_ops_class_init(ObjectClass *oc, const void *data)
+{
+ monitor_register_hmp_info_hrt("accel", hmp_info_accel);
+}
+
static const TypeInfo accel_ops_type_info = {
.name = TYPE_ACCEL_OPS,
.parent = TYPE_OBJECT,
.abstract = true,
.class_size = sizeof(AccelOpsClass),
+ .class_init = accel_ops_class_init,
};
static void accel_system_register_types(void)
@@ -281,6 +281,18 @@ ERST
.cmd = hmp_info_sync_profile,
},
+ {
+ .name = "accel",
+ .args_type = "",
+ .params = "",
+ .help = "show accelerator info",
+ },
+
+SRST
+ ``info accel``
+ Show accelerator info.
+ERST
+
SRST
``info sync-profile [-m|-n]`` [*max*]
Show synchronization profiling info, up to *max* entries (default: 10),
'info accel' dispatches to the AccelOpsClass::get_stats() and get_vcpu_stats() handlers. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- include/qemu/accel.h | 1 + include/system/accel-ops.h | 2 ++ accel/accel-system.c | 28 ++++++++++++++++++++++++++++ hmp-commands-info.hx | 12 ++++++++++++ 4 files changed, 43 insertions(+)