| 1 | /* |
| 2 | * QMP commands related to accelerators |
| 3 | * |
| 4 | * Copyright (c) Linaro |
| 5 | * |
| 6 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 7 | */ |
| 8 | |
| 9 | #include "qemu/osdep.h" |
| 10 | #include "qemu/accel.h" |
| 11 | #include "qapi/type-helpers.h" |
| 12 | #include "qapi/qapi-commands-accelerator.h" |
| 13 | #include "accel/accel-ops.h" |
| 14 | #include "accel/accel-cpu-ops.h" |
| 15 | #include "hw/core/cpu.h" |
| 16 | |
| 17 | HumanReadableText *qmp_x_accel_stats(Error **errp) |
| 18 | { |
| 19 | AccelState *accel = current_accel(); |
| 20 | AccelClass *acc = ACCEL_GET_CLASS(accel); |
| 21 | g_autoptr(GString) buf = g_string_new(""); |
| 22 | |
| 23 | if (acc->get_stats) { |
| 24 | acc->get_stats(accel, buf); |
| 25 | } |
| 26 | if (acc->ops->get_vcpu_stats) { |
| 27 | CPUState *cpu; |
| 28 | |
| 29 | CPU_FOREACH(cpu) { |
| 30 | acc->ops->get_vcpu_stats(cpu, buf); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | return human_readable_text_from_str(buf); |
| 35 | } |