mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
qmp: add filtering of statistics by target vCPU
Introduce a simple filtering of statistics, that allows to retrieve statistics for a subset of the guest vCPUs. This will be used for example by the HMP monitor, in order to retrieve the statistics for the currently selected CPU. Example: { "execute": "query-stats", "arguments": { "target": "vcpu", "vcpus": [ "/machine/unattached/device[2]", "/machine/unattached/device[4]" ] } } Extracted from a patch by Mark Kanda. Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
cc01a3f4ca
commit
467ef823d8
4 changed files with 69 additions and 9 deletions
|
@ -2311,7 +2311,8 @@ bool kvm_dirty_ring_enabled(void)
|
|||
return kvm_state->kvm_dirty_ring_size ? true : false;
|
||||
}
|
||||
|
||||
static void query_stats_cb(StatsResultList **result, StatsTarget target, Error **errp);
|
||||
static void query_stats_cb(StatsResultList **result, StatsTarget target,
|
||||
strList *targets, Error **errp);
|
||||
static void query_stats_schemas_cb(StatsSchemaList **result, Error **errp);
|
||||
|
||||
static int kvm_init(MachineState *ms)
|
||||
|
@ -4038,7 +4039,8 @@ static void query_stats_schema_vcpu(CPUState *cpu, run_on_cpu_data data)
|
|||
close(stats_fd);
|
||||
}
|
||||
|
||||
static void query_stats_cb(StatsResultList **result, StatsTarget target, Error **errp)
|
||||
static void query_stats_cb(StatsResultList **result, StatsTarget target,
|
||||
strList *targets, Error **errp)
|
||||
{
|
||||
KVMState *s = kvm_state;
|
||||
CPUState *cpu;
|
||||
|
@ -4062,6 +4064,9 @@ static void query_stats_cb(StatsResultList **result, StatsTarget target, Error *
|
|||
stats_args.result.stats = result;
|
||||
stats_args.errp = errp;
|
||||
CPU_FOREACH(cpu) {
|
||||
if (!apply_str_list_filter(cpu->parent_obj.canonical_path, targets)) {
|
||||
continue;
|
||||
}
|
||||
run_on_cpu(cpu, query_stats_vcpu, RUN_ON_CPU_HOST_PTR(&stats_args));
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue