Skip to content

Commit

Permalink
kvm: fix segfault with query-stats-schemas and -M none
Browse files Browse the repository at this point in the history
-M none creates a guest without a vCPU, causing the following error:

$ ./qemu-system-x86_64 -qmp stdio -M none -accel kvm
{execute:qmp_capabilities}
{"return": {}}
{execute: query-stats-schemas}
Segmentation fault (core dumped)

Fix it by not querying the vCPU stats if first_cpu is NULL.

Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
bonzini committed Aug 18, 2022
1 parent c7208a6 commit a9197ad
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions accel/kvm/kvm-all.c
Original file line number Diff line number Diff line change
Expand Up @@ -4131,7 +4131,9 @@ void query_stats_schemas_cb(StatsSchemaList **result, Error **errp)
query_stats_schema(result, STATS_TARGET_VM, stats_fd, errp);
close(stats_fd);

stats_args.result.schema = result;
stats_args.errp = errp;
run_on_cpu(first_cpu, query_stats_schema_vcpu, RUN_ON_CPU_HOST_PTR(&stats_args));
if (first_cpu) {
stats_args.result.schema = result;
stats_args.errp = errp;
run_on_cpu(first_cpu, query_stats_schema_vcpu, RUN_ON_CPU_HOST_PTR(&stats_args));
}
}

0 comments on commit a9197ad

Please sign in to comment.