All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Roman Bolshakov <r.bolshakov@yadro.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH for-6.0 5/6] hmp: Add 'info accel' command
Date: Fri, 27 Nov 2020 10:39:16 +0000	[thread overview]
Message-ID: <20201127103916.GC2969@work-vm> (raw)
In-Reply-To: <20201116131011.26607-6-r.bolshakov@yadro.com>

* 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



  reply	other threads:[~2020-11-27 10:43 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-16 13:10 [PATCH for-6.0 0/6] Add HMP/QMP commands to query accelerator Roman Bolshakov
2020-11-16 13:10 ` [PATCH for-6.0 1/6] qapi: Add query-accel command Roman Bolshakov
2020-11-16 16:20   ` Eric Blake
2020-11-16 18:56     ` Roman Bolshakov
2020-11-16 21:13     ` Eduardo Habkost
2020-11-17  8:51       ` Markus Armbruster
2020-11-18  1:19         ` Roman Bolshakov
2020-11-18  8:36           ` Markus Armbruster
2020-11-18  9:21             ` Paolo Bonzini
2020-11-18 13:08               ` Markus Armbruster
2020-11-18 13:46                 ` Paolo Bonzini
2020-11-18 14:45                   ` Markus Armbruster
2020-11-18 14:54                     ` Paolo Bonzini
2020-11-18 14:00                 ` Roman Bolshakov
2020-11-18 11:28             ` Kevin Wolf
2020-11-18 11:56               ` Daniel P. Berrangé
2020-11-18 13:53                 ` Markus Armbruster
2020-11-18 15:45                   ` Eduardo Habkost
2020-11-18 15:56                     ` Eric Blake
2020-11-18 16:23                       ` Eduardo Habkost
2020-11-19 13:17                         ` Markus Armbruster
2020-11-30 17:05   ` Philippe Mathieu-Daudé
2020-11-16 13:10 ` [PATCH for-6.0 2/6] qapi: Rename KvmInfo to AccelInfo Roman Bolshakov
2020-11-27 10:40   ` Dr. David Alan Gilbert
2020-11-27 12:08     ` Markus Armbruster
2020-11-16 13:10 ` [PATCH for-6.0 3/6] qapi: Use qmp_query_accel() in qmp_query_kvm() Roman Bolshakov
2020-11-16 13:10 ` [PATCH for-6.0 4/6] softmmu: Remove kvm_available() Roman Bolshakov
2020-11-16 13:10 ` [PATCH for-6.0 5/6] hmp: Add 'info accel' command Roman Bolshakov
2020-11-27 10:39   ` Dr. David Alan Gilbert [this message]
2020-11-16 13:10 ` [PATCH for-6.0 6/6] qapi: Deprecate 'query-kvm' Roman Bolshakov
2020-11-27 10:50   ` Daniel P. Berrangé
2020-11-27 11:21     ` Peter Krempa
2020-11-27 11:45       ` Roman Bolshakov
2020-11-27 12:18         ` Peter Krempa
2020-11-27 15:44           ` Markus Armbruster
2020-11-27 16:30             ` Peter Krempa
2020-11-30  9:21               ` Markus Armbruster
2020-11-30 10:09                 ` Peter Krempa
2020-11-30 16:03                   ` Markus Armbruster
2020-11-30 15:30               ` Eric Blake
2020-11-27 15:53           ` Daniel P. Berrangé
2020-11-27 16:35             ` Peter Krempa
2020-11-19 14:41 ` [PATCH for-6.0 0/6] Add HMP/QMP commands to query accelerator Claudio Fontana
2020-11-19 15:46   ` Roman Bolshakov
2020-11-19 15:54     ` Claudio Fontana

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201127103916.GC2969@work-vm \
    --to=dgilbert@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=r.bolshakov@yadro.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.