aboutsummaryrefslogtreecommitdiff
path: root/accel/accel-qmp.c
blob: 5fb70c6631f4c82dbe1e48aa5a3b85e241a46297 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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);
}