From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34370) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDLaw-0007ex-Ch for qemu-devel@nongnu.org; Tue, 11 Feb 2014 17:14:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDLak-0007Gw-C6 for qemu-devel@nongnu.org; Tue, 11 Feb 2014 17:14:22 -0500 Received: from mail-wi0-x236.google.com ([2a00:1450:400c:c05::236]:38292) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDLak-0007Ga-4q for qemu-devel@nongnu.org; Tue, 11 Feb 2014 17:14:10 -0500 Received: by mail-wi0-f182.google.com with SMTP id f8so5510347wiw.3 for ; Tue, 11 Feb 2014 14:14:09 -0800 (PST) Date: Tue, 11 Feb 2014 23:14:01 +0100 From: Hani Benhabiles Message-ID: <20140211221401.GD13922@Inspiron-3521> References: <1391725813-29514-1-git-send-email-kroosec@gmail.com> <1391725813-29514-5-git-send-email-kroosec@gmail.com> <20140211133832.73e246ca@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140211133832.73e246ca@redhat.com> Subject: Re: [Qemu-devel] [PATCH 4/4] monitor: Add object_add class argument completion. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: imammedo@redhat.com, qemu-devel@nongnu.org, pbonzini@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 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 > > #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.