@@ -824,4 +824,6 @@ void riscv_cpu_register_gdb_regs_for_features(CPUState *cs);
uint8_t satp_mode_max_from_map(uint32_t map);
const char *satp_mode_str(uint8_t satp_mode, bool is_32_bit);
+void riscv_cpu_add_definition(gpointer data, gpointer user_data);
+
#endif /* RISCV_CPU_H */
@@ -2341,6 +2341,7 @@ static int64_t riscv_get_arch_id(CPUState *cs)
#include "hw/core/sysemu-cpu-ops.h"
static const struct SysemuCPUOps riscv_sysemu_ops = {
+ .add_definition = riscv_cpu_add_definition,
.get_phys_page_debug = riscv_cpu_get_phys_page_debug,
.write_elf64_note = riscv_cpu_write_elf64_note,
.write_elf32_note = riscv_cpu_write_elf32_note,
@@ -26,6 +26,7 @@
#include "qapi/error.h"
#include "qapi/qapi-commands-machine-target.h"
+#include "qapi/commands-target-compat.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qobject-input-visitor.h"
@@ -36,7 +37,7 @@
#include "cpu-qom.h"
#include "cpu.h"
-static void riscv_cpu_add_definition(gpointer data, gpointer user_data)
+void riscv_cpu_add_definition(gpointer data, gpointer user_data)
{
ObjectClass *oc = data;
CpuDefinitionInfoList **cpu_list = user_data;
@@ -55,13 +56,7 @@ static void riscv_cpu_add_definition(gpointer data, gpointer user_data)
CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
{
- CpuDefinitionInfoList *cpu_list = NULL;
- GSList *list = object_class_get_list(TYPE_RISCV_CPU, false);
-
- g_slist_foreach(list, riscv_cpu_add_definition, &cpu_list);
- g_slist_free(list);
-
- return cpu_list;
+ return generic_query_cpu_definitions(errp);
}
static void riscv_check_if_cpu_available(RISCVCPU *cpu, Error **errp)
Expose riscv_cpu_add_definition() and use it as add_definition() handler, then use the QMP generic_query_cpu_definitions() method. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- target/riscv/cpu.h | 2 ++ target/riscv/cpu.c | 1 + target/riscv/riscv-qmp-cmds.c | 11 +++-------- 3 files changed, 6 insertions(+), 8 deletions(-)