qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] target/mips: implement QMP query-cpu-definit


From: Philippe Mathieu-Daudé
Subject: Re: [Qemu-devel] [PATCH v2] target/mips: implement QMP query-cpu-definitions command
Date: Tue, 19 Feb 2019 20:28:16 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0

On 2/19/19 8:15 PM, Aleksandar Markovic wrote:
> From: Pavel Dovgalyuk <address@hidden>
> 
> This patch enables QMP-based querying of the available CPU types for
> MIPS and MIPS64 platforms.
> 
> Signed-off-by: Pavel Dovgalyuk <address@hidden>
> Signed-off-by: Aleksandar Markovic <address@hidden>
> Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
> Tested-by: Philippe Mathieu-Daudé <address@hidden>

Aleksandar, FYI I tested v1 and your v2 that way:

$ mips64el-softmmu/qemu-system-mips64el -S \
    -qmp tcp:localhost:4444,server,nowait

$ telnet localhost 4444
{"QMP": {"version": {"qemu": {"micro": 50, "minor": 1, "major": 3},
"package": "v3.1.0-1924-gc7b700fafb"}, "capabilities": ["oob"]}}

{ "execute": "qmp_capabilities" }
{"return": {}}

{ "execute": "query-cpu-definitions" }
{"return": [{"name": "24KEc", "typename": "24KEc-mips64-cpu", "static":
false}, {"name": "MIPS64R2-generic", "typename":
"MIPS64R2-generic-mips64-cpu", "static": false}, {"name": "VR5432",
"typename": "VR5432-mips64-cpu", "static": false}, {"name": "M14Kc",
"typename": "M14Kc-mips64-cpu", "static": false}, {"name": "20Kc",
"typename": "20Kc-mips64-cpu", "static": false}, {"name": "4Km",
"typename": "4Km-mips64-cpu", "static": false}, {"name": "mips64dspr2",
"typename": "mips64dspr2-mips64-cpu", "static": false}, {"name":
"I6400", "typename": "I6400-mips64-cpu", "static": false}, {"name":
"Loongson-2E", "typename": "Loongson-2E-mips64-cpu", "static": false},
{"name": "I6500", "typename": "I6500-mips64-cpu", "static": false},
{"name": "4KEcR1", "typename": "4KEcR1-mips64-cpu", "static": false},
{"name": "74Kf", "typename": "74Kf-mips64-cpu", "static": false},
{"name": "24Kf", "typename": "24Kf-mips64-cpu", "static": false},
{"name": "5KEc", "typename": "5KEc-mips64-cpu", "static": false},
{"name": "P5600", "typename": "P5600-mips64-cpu", "static": false},
{"name": "I7200", "typename": "I7200-mips64-cpu", "static": false},
{"name": "M14K", "typename": "M14K-mips64-cpu", "static": false},
{"name": "5KEf", "typename": "5KEf-mips64-cpu", "static": false},
{"name": "24Kc", "typename": "24Kc-mips64-cpu", "static": false},
{"name": "4KEm", "typename": "4KEm-mips64-cpu", "static": false},
{"name": "4Kc", "typename": "4Kc-mips64-cpu", "static": false}, {"name":
"5Kc", "typename": "5Kc-mips64-cpu", "static": false}, {"name":
"4KEmR1", "typename": "4KEmR1-mips64-cpu", "static": false}, {"name":
"R4000", "typename": "R4000-mips64-cpu", "static": false}, {"name":
"5Kf", "typename": "5Kf-mips64-cpu", "static": false}, {"name":
"mips32r6-generic", "typename": "mips32r6-generic-mips64-cpu", "static":
false}, {"name": "4KEc", "typename": "4KEc-mips64-cpu", "static":
false}, {"name": "34Kf", "typename": "34Kf-mips64-cpu", "static":
false}, {"name": "Loongson-2F", "typename": "Loongson-2F-mips64-cpu",
"static": false}]}

See: https://wiki.qemu.org/Documentation/QMP

Regards,

Phil.

> ---
> 
> v1->v2:
> 
>   - rebased to the latest QAPI code
> 
>  qapi/target.json     |  4 ++--
>  target/mips/helper.c | 33 +++++++++++++++++++++++++++++++++
>  2 files changed, 35 insertions(+), 2 deletions(-)
> 
> diff --git a/qapi/target.json b/qapi/target.json
> index da7b4be..1d4d54b 100644
> --- a/qapi/target.json
> +++ b/qapi/target.json
> @@ -499,7 +499,7 @@
>              'static': 'bool',
>              '*unavailable-features': [ 'str' ],
>              'typename': 'str' },
> -  'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386) 
> || defined(TARGET_S390X)' }
> +  'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386) 
> || defined(TARGET_S390X) || defined(TARGET_MIPS)' }
>  
>  ##
>  # @query-cpu-definitions:
> @@ -511,4 +511,4 @@
>  # Since: 1.2.0
>  ##
>  { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'],
> -  'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386) 
> || defined(TARGET_S390X)' }
> +  'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386) 
> || defined(TARGET_S390X) || defined(TARGET_MIPS)' }
> diff --git a/target/mips/helper.c b/target/mips/helper.c
> index 944f094..c44cdca 100644
> --- a/target/mips/helper.c
> +++ b/target/mips/helper.c
> @@ -24,6 +24,7 @@
>  #include "exec/cpu_ldst.h"
>  #include "exec/log.h"
>  #include "hw/mips/cpudevs.h"
> +#include "qapi/qapi-commands-target.h"
>  
>  enum {
>      TLBRET_XI = -6,
> @@ -1470,3 +1471,35 @@ void QEMU_NORETURN do_raise_exception_err(CPUMIPSState 
> *env,
>  
>      cpu_loop_exit_restore(cs, pc);
>  }
> +
> +static void mips_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_MIPS_CPU));
> +    info->q_typename = g_strdup(typename);
> +
> +    entry = g_malloc0(sizeof(*entry));
> +    entry->value = info;
> +    entry->next = *cpu_list;
> +    *cpu_list = entry;
> +}
> +
> +CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
> +{
> +    CpuDefinitionInfoList *cpu_list = NULL;
> +    GSList *list;
> +
> +    list = object_class_get_list(TYPE_MIPS_CPU, false);
> +    g_slist_foreach(list, mips_cpu_add_definition, &cpu_list);
> +    g_slist_free(list);
> +
> +    return cpu_list;
> +}
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]