[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH for-6.0 5/6] hmp: Add 'info accel' command
From: |
Dr. David Alan Gilbert |
Subject: |
Re: [PATCH for-6.0 5/6] hmp: Add 'info accel' command |
Date: |
Fri, 27 Nov 2020 10:39:16 +0000 |
User-agent: |
Mutt/1.14.6 (2020-07-11) |
* Roman Bolshakov (r.bolshakov@yadro.com) wrote:
> The command is made after 'info kvm' and aims to replace it as more
> generic one.
>
> If used without parameters, the command can used to get current
> accelerator. Otherwise, it may be used to determine if an accelerator is
> available. Here's an example if a VM with hvf accel is started:
>
> (qemu) info accel
> hvf support: enabled
> (qemu) info accel kvm
> kvm support: not compiled
> (qemu) info accel tcg
> tcg support: disabled
>
> Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
> ---
> hmp-commands-info.hx | 13 +++++++++++++
> include/monitor/hmp.h | 1 +
> monitor/hmp-cmds.c | 32 ++++++++++++++++++++++++++++++++
> 3 files changed, 46 insertions(+)
>
> diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
> index 117ba25f91..e9da6b52e4 100644
> --- a/hmp-commands-info.hx
> +++ b/hmp-commands-info.hx
> @@ -337,6 +337,19 @@ SRST
> Show KVM information.
> ERST
>
> + {
> + .name = "accel",
> + .args_type = "name:s?",
> + .params = "[name]",
> + .help = "show accelerator information",
> + .cmd = hmp_info_accel,
> + },
> +
> +SRST
> + ``info accel``` [*name*]
> + Show accelerator information.
> +ERST
> +
> {
> .name = "numa",
> .args_type = "",
> diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
> index ed2913fd18..03f22957d9 100644
> --- a/include/monitor/hmp.h
> +++ b/include/monitor/hmp.h
> @@ -21,6 +21,7 @@ void hmp_handle_error(Monitor *mon, Error *err);
> void hmp_info_name(Monitor *mon, const QDict *qdict);
> void hmp_info_version(Monitor *mon, const QDict *qdict);
> void hmp_info_kvm(Monitor *mon, const QDict *qdict);
> +void hmp_info_accel(Monitor *mon, const QDict *qdict);
> void hmp_info_status(Monitor *mon, const QDict *qdict);
> void hmp_info_uuid(Monitor *mon, const QDict *qdict);
> void hmp_info_chardev(Monitor *mon, const QDict *qdict);
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index ea86289fe8..00db791aa3 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -20,6 +20,7 @@
> #include "chardev/char.h"
> #include "sysemu/block-backend.h"
> #include "sysemu/runstate.h"
> +#include "sysemu/accel.h"
> #include "qemu/config-file.h"
> #include "qemu/option.h"
> #include "qemu/timer.h"
> @@ -133,6 +134,37 @@ void hmp_info_kvm(Monitor *mon, const QDict *qdict)
> qapi_free_AccelInfo(info);
> }
>
> +void hmp_info_accel(Monitor *mon, const QDict *qdict)
> +{
> + AccelInfo *info;
> + AccelClass *acc;
> + const char *name, *typename;
> + char *current_name;
> + int len;
> +
> + /* Figure out current accelerator */
> + acc = ACCEL_GET_CLASS(current_accel());
Is that always guaranteed non-null?
> + typename = object_class_get_name(OBJECT_CLASS(acc));
> + len = strlen(typename) - strlen(ACCEL_CLASS_SUFFIX);
> + current_name = g_strndup(typename, len);
> +
> + name = qdict_get_try_str(qdict, "name");
> + if (!name) {
> + name = current_name;
> + }
> +
> + info = qmp_query_accel(name, NULL);
> + monitor_printf(mon, "%s support: ", name);
> + if (info->present) {
> + monitor_printf(mon, "%s\n", info->enabled ? "enabled" : "disabled");
> + } else {
> + monitor_printf(mon, "not compiled\n");
> + }
> +
> + qapi_free_AccelInfo(info);
> + g_free(current_name);
> +}
I think that's fine, since HMP is not guaranteed stable, I'd say it's
fine to kill off 'info kvm' and replace it with this.
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Dave
> +
> void hmp_info_status(Monitor *mon, const QDict *qdict)
> {
> StatusInfo *info;
> --
> 2.29.2
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
- Re: [PATCH for-6.0 1/6] qapi: Add query-accel command, (continued)
[PATCH for-6.0 2/6] qapi: Rename KvmInfo to AccelInfo, Roman Bolshakov, 2020/11/16
[PATCH for-6.0 4/6] softmmu: Remove kvm_available(), Roman Bolshakov, 2020/11/16
[PATCH for-6.0 3/6] qapi: Use qmp_query_accel() in qmp_query_kvm(), Roman Bolshakov, 2020/11/16
[PATCH for-6.0 6/6] qapi: Deprecate 'query-kvm', Roman Bolshakov, 2020/11/16
[PATCH for-6.0 5/6] hmp: Add 'info accel' command, Roman Bolshakov, 2020/11/16
- Re: [PATCH for-6.0 5/6] hmp: Add 'info accel' command,
Dr. David Alan Gilbert <=
Re: [PATCH for-6.0 0/6] Add HMP/QMP commands to query accelerator, Claudio Fontana, 2020/11/19