qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Hani Benhabiles <kroosec@gmail.com>
To: Luiz Capitulino <lcapitulino@redhat.com>
Cc: imammedo@redhat.com, qemu-devel@nongnu.org, pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH 4/4] monitor: Add object_add class argument completion.
Date: Tue, 11 Feb 2014 23:14:01 +0100	[thread overview]
Message-ID: <20140211221401.GD13922@Inspiron-3521> (raw)
In-Reply-To: <20140211133832.73e246ca@redhat.com>

On Tue, Feb 11, 2014 at 01:38:32PM -0500, Luiz Capitulino wrote:
> On Thu,  6 Feb 2014 23:30:13 +0100
> Hani Benhabiles <kroosec@gmail.com> wrote:
> 
> > ---
> >  monitor.c | 23 +++++++++++++++++++++++
> >  1 file changed, 23 insertions(+)
> > 
> > diff --git a/monitor.c b/monitor.c
> > index 4a2c1ae..397e1fe 100644
> > --- a/monitor.c
> > +++ b/monitor.c
> > @@ -56,6 +56,7 @@
> >  #include "qapi/qmp/qjson.h"
> >  #include "qapi/qmp/json-streamer.h"
> >  #include "qapi/qmp/json-parser.h"
> > +#include <qom/object_interfaces.h>
> >  #include "qemu/osdep.h"
> >  #include "cpu.h"
> >  #include "trace.h"
> > @@ -4275,6 +4276,26 @@ static void device_add_completion(ReadLineState *rs, const char *str)
> >      g_slist_free(list);
> >  }
> >  
> > +static void object_add_completion(ReadLineState *rs, const char *str)
> > +{
> > +    GSList *list, *elt;
> > +    size_t len;
> > +
> > +    len = strlen(str);
> > +    readline_set_completion_index(rs, len);
> > +    list = elt = object_class_get_list(TYPE_USER_CREATABLE, false);
> > +    while (elt) {
> > +        const char *name;
> > +
> > +        name = object_class_get_name(OBJECT_CLASS(elt->data));
> > +        if (!strncmp(name, str, len) && strcmp(name, TYPE_USER_CREATABLE)) {
> > +            readline_add_completion(rs, name);
> > +        }
> > +        elt = elt->next;
> > +    }
> > +    g_slist_free(list);
> > +}
> > +
> >  static void device_del_completion(ReadLineState *rs, BusState *bus,
> >                                    const char *str, size_t len)
> >  {
> > @@ -4381,6 +4402,8 @@ static void monitor_find_completion_by_table(Monitor *mon,
> >          case 'O':
> >              if (!strcmp(cmd->name, "device_add") && nb_args == 2) {
> >                  device_add_completion(mon->rs, str);
> > +            } else if (!strcmp(cmd->name, "object_add") && nb_args == 2) {
> > +                object_add_completion(mon->rs, str);
> >              }
> >              break;
> >          case 's':
> 
> Those many ifs need to be generalized. Maybe we could add a
> command_completion callback to mon_cmd_t? Anyway, I won't refuse the series
> because of that but it would be very welcome to improve this.

I agree that it could be made better. I will be looking at it next for possible
improvements.


Cheers,

Hani.

  reply	other threads:[~2014-02-11 22:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-06 22:30 [Qemu-devel] [PATCH 0/4] monitor: Add argument completion for multiple commands Hani Benhabiles
2014-02-06 22:30 ` [Qemu-devel] [PATCH 1/4] monitor: Add device_del id argument completion Hani Benhabiles
2014-02-11 18:35   ` Luiz Capitulino
2014-02-06 22:30 ` [Qemu-devel] [PATCH 2/4] monitor: Add device_add device " Hani Benhabiles
2014-02-06 22:30 ` [Qemu-devel] [PATCH 3/4] monitor: Add object_del id " Hani Benhabiles
2014-02-06 22:30 ` [Qemu-devel] [PATCH 4/4] monitor: Add object_add class " Hani Benhabiles
2014-02-11 18:38   ` Luiz Capitulino
2014-02-11 22:14     ` Hani Benhabiles [this message]
2014-02-11 18:39 ` [Qemu-devel] [PATCH 0/4] monitor: Add argument completion for multiple commands Luiz Capitulino
2014-02-11 22:10   ` Hani Benhabiles

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=20140211221401.GD13922@Inspiron-3521 \
    --to=kroosec@gmail.com \
    --cc=imammedo@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).