From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHEwD-0002lB-BL for qemu-devel@nongnu.org; Wed, 04 Sep 2013 11:24:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VHEw7-000192-8w for qemu-devel@nongnu.org; Wed, 04 Sep 2013 11:24:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43037) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHEw7-00018v-10 for qemu-devel@nongnu.org; Wed, 04 Sep 2013 11:24:03 -0400 From: Cole Robinson Date: Wed, 4 Sep 2013 11:23:26 -0400 Message-Id: Subject: [Qemu-devel] [PATCH] target-arm: Implement qmp query-cpu-definitions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Cole Robinson Libvirt uses this to introspect available CPU models. Signed-off-by: Cole Robinson --- Maybe this will be centrally handled after the QOM CPU work is done? target-arm/helper.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/target-arm/helper.c b/target-arm/helper.c index e51ef20..1874377 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -2,6 +2,7 @@ #include "exec/gdbstub.h" #include "helper.h" #include "qemu/host-utils.h" +#include "sysemu/arch_init.h" #include "sysemu/sysemu.h" #include "qemu/bitops.h" @@ -1829,6 +1830,37 @@ void arm_cpu_list(FILE *f, fprintf_function cpu_fprintf) g_slist_free(list); } +static void arm_cpu_add_definition(gpointer data, gpointer user_data) +{ + ObjectClass *oc = data; + CpuDefinitionInfoList **cpu_list = user_data; + CpuDefinitionInfoList *entry; + CpuDefinitionInfo *info; + const char *typename; + + typename = object_class_get_name(oc); + info = g_malloc0(sizeof(*info)); + info->name = g_strndup(typename, + strlen(typename) - strlen("-" TYPE_ARM_CPU)); + + entry = g_malloc0(sizeof(*entry)); + entry->value = info; + entry->next = *cpu_list; + *cpu_list = entry; +} + +CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp) +{ + CpuDefinitionInfoList *cpu_list = NULL; + GSList *list; + + list = object_class_get_list(TYPE_ARM_CPU, false); + g_slist_foreach(list, arm_cpu_add_definition, &cpu_list); + g_slist_free(list); + + return cpu_list; +} + void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, const ARMCPRegInfo *r, void *opaque) { -- 1.8.3.1