* [Qemu-devel] [PATCH 1/7] monitor: Add command_completion callback to mon_cmd_t.
2014-03-09 11:16 [Qemu-devel] [PATCH 0/7] monitor: Completion support for various commands Hani Benhabiles
@ 2014-03-09 11:16 ` Hani Benhabiles
2014-03-27 20:21 ` Luiz Capitulino
2014-03-09 11:16 ` [Qemu-devel] [PATCH 2/7] monitor: Add chardev-remove id argument completion Hani Benhabiles
` (7 subsequent siblings)
8 siblings, 1 reply; 17+ messages in thread
From: Hani Benhabiles @ 2014-03-09 11:16 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, imammedo, stefanha, lcapitulino
Convert device_add, device_del, object_add and object_del commands to use
the new callback.
Also fix drive_del id argument type to activate completion.
Signed-off-by: Hani Benhabiles <hani@linux.com>
Suggested-by: Luiz Capitulino <lcapitulino@redhat.com>
---
hmp-commands.hx | 6 +++++-
hmp.h | 4 ++++
monitor.c | 65 +++++++++++++++++++++++++++++++++++----------------------
3 files changed, 49 insertions(+), 26 deletions(-)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index f3fc514..4c4d261 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -176,7 +176,7 @@ ETEXI
{
.name = "drive_del",
- .args_type = "id:s",
+ .args_type = "id:B",
.params = "device",
.help = "remove host block device",
.user_print = monitor_user_noop,
@@ -658,6 +658,7 @@ ETEXI
.help = "add device, like -device on the command line",
.user_print = monitor_user_noop,
.mhandler.cmd_new = do_device_add,
+ .command_completion = device_add_completion,
},
STEXI
@@ -673,6 +674,7 @@ ETEXI
.params = "device",
.help = "remove device",
.mhandler.cmd = hmp_device_del,
+ .command_completion = device_del_completion,
},
STEXI
@@ -1254,6 +1256,7 @@ ETEXI
.params = "[qom-type=]type,id=str[,prop=value][,...]",
.help = "create QOM object",
.mhandler.cmd = hmp_object_add,
+ .command_completion = object_add_completion,
},
STEXI
@@ -1268,6 +1271,7 @@ ETEXI
.params = "id",
.help = "destroy QOM object",
.mhandler.cmd = hmp_object_del,
+ .command_completion = object_del_completion,
},
STEXI
diff --git a/hmp.h b/hmp.h
index ed58f0e..558658f 100644
--- a/hmp.h
+++ b/hmp.h
@@ -92,5 +92,9 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict);
void hmp_cpu_add(Monitor *mon, const QDict *qdict);
void hmp_object_add(Monitor *mon, const QDict *qdict);
void hmp_object_del(Monitor *mon, const QDict *qdict);
+void device_add_completion(Monitor *mon, int nb_args, const char *str);
+void device_del_completion(Monitor *mon, int nb_args, const char *str);
+void object_add_completion(Monitor *mon, int nb_args, const char *str);
+void object_del_completion(Monitor *mon, int nb_args, const char *str);
#endif
diff --git a/monitor.c b/monitor.c
index 342e83b..2c8528c 100644
--- a/monitor.c
+++ b/monitor.c
@@ -137,6 +137,7 @@ typedef struct mon_cmd_t {
* used, and mhandler of 1st level plays the role of help function.
*/
struct mon_cmd_t *sub_table;
+ void (*command_completion)(Monitor *mon, int nb_args, const char *str);
} mon_cmd_t;
/* file descriptors passed via SCM_RIGHTS */
@@ -4277,13 +4278,17 @@ static const char *next_arg_type(const char *typestr)
return (p != NULL ? ++p : typestr);
}
-static void device_add_completion(ReadLineState *rs, const char *str)
+void device_add_completion(Monitor *mon, int nb_args, const char *str)
{
GSList *list, *elt;
size_t len;
+ if (nb_args != 2) {
+ return;
+ }
+
len = strlen(str);
- readline_set_completion_index(rs, len);
+ readline_set_completion_index(mon->rs, len);
list = elt = object_class_get_list(TYPE_DEVICE, false);
while (elt) {
const char *name;
@@ -4291,35 +4296,39 @@ static void device_add_completion(ReadLineState *rs, const char *str)
TYPE_DEVICE);
name = object_class_get_name(OBJECT_CLASS(dc));
if (!strncmp(name, str, len)) {
- readline_add_completion(rs, name);
+ readline_add_completion(mon->rs, name);
}
elt = elt->next;
}
g_slist_free(list);
}
-static void object_add_completion(ReadLineState *rs, const char *str)
+void object_add_completion(Monitor *mon, int nb_args, const char *str)
{
GSList *list, *elt;
size_t len;
+ if (nb_args != 2) {
+ return;
+ }
+
len = strlen(str);
- readline_set_completion_index(rs, len);
+ readline_set_completion_index(mon->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);
+ readline_add_completion(mon->rs, name);
}
elt = elt->next;
}
g_slist_free(list);
}
-static void device_del_completion(ReadLineState *rs, BusState *bus,
- const char *str, size_t len)
+static void device_del_bus_completion(ReadLineState *rs, BusState *bus,
+ const char *str, size_t len)
{
BusChild *kid;
@@ -4332,18 +4341,34 @@ static void device_del_completion(ReadLineState *rs, BusState *bus,
}
QLIST_FOREACH(dev_child, &dev->child_bus, sibling) {
- device_del_completion(rs, dev_child, str, len);
+ device_del_bus_completion(rs, dev_child, str, len);
}
}
}
-static void object_del_completion(ReadLineState *rs, const char *str)
+void device_del_completion(Monitor *mon, int nb_args, const char *str)
+{
+ size_t len;
+
+ if (nb_args != 2) {
+ return;
+ }
+
+ len = strlen(str);
+ readline_set_completion_index(mon->rs, len);
+ device_del_bus_completion(mon->rs, sysbus_get_default(), str, len);
+}
+
+void object_del_completion(Monitor *mon, int nb_args, const char *str)
{
ObjectPropertyInfoList *list, *start;
size_t len;
+ if (nb_args != 2) {
+ return;
+ }
len = strlen(str);
- readline_set_completion_index(rs, len);
+ readline_set_completion_index(mon->rs, len);
start = list = qmp_qom_list("/objects", NULL);
while (list) {
@@ -4351,7 +4376,7 @@ static void object_del_completion(ReadLineState *rs, const char *str)
if (!strncmp(info->type, "child<", 5)
&& !strncmp(info->name, str, len)) {
- readline_add_completion(rs, info->name);
+ readline_add_completion(mon->rs, info->name);
}
list = list->next;
}
@@ -4395,6 +4420,9 @@ static void monitor_find_completion_by_table(Monitor *mon,
return monitor_find_completion_by_table(mon, cmd->sub_table,
&args[1], nb_args - 1);
}
+ if (cmd->command_completion) {
+ return cmd->command_completion(mon, nb_args, args[nb_args - 1]);
+ }
ptype = next_arg_type(cmd->args_type);
for(i = 0; i < nb_args - 2; i++) {
@@ -4421,13 +4449,6 @@ static void monitor_find_completion_by_table(Monitor *mon,
readline_set_completion_index(mon->rs, strlen(str));
bdrv_iterate(block_completion_it, &mbs);
break;
- 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':
case 'S':
if (!strcmp(cmd->name, "sendkey")) {
@@ -4441,12 +4462,6 @@ static void monitor_find_completion_by_table(Monitor *mon,
} else if (!strcmp(cmd->name, "help|?")) {
monitor_find_completion_by_table(mon, cmd_table,
&args[1], nb_args - 1);
- } else if (!strcmp(cmd->name, "device_del") && nb_args == 2) {
- size_t len = strlen(str);
- readline_set_completion_index(mon->rs, len);
- device_del_completion(mon->rs, sysbus_get_default(), str, len);
- } else if (!strcmp(cmd->name, "object_del") && nb_args == 2) {
- object_del_completion(mon->rs, str);
}
break;
default:
--
1.8.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [Qemu-devel] [PATCH 1/7] monitor: Add command_completion callback to mon_cmd_t.
2014-03-09 11:16 ` [Qemu-devel] [PATCH 1/7] monitor: Add command_completion callback to mon_cmd_t Hani Benhabiles
@ 2014-03-27 20:21 ` Luiz Capitulino
2014-03-27 21:55 ` Hani Benhabiles
0 siblings, 1 reply; 17+ messages in thread
From: Luiz Capitulino @ 2014-03-27 20:21 UTC (permalink / raw)
To: Hani Benhabiles; +Cc: kwolf, imammedo, qemu-devel, stefanha
On Sun, 9 Mar 2014 12:16:11 +0100
Hani Benhabiles <kroosec@gmail.com> wrote:
> Convert device_add, device_del, object_add and object_del commands to use
> the new callback.
>
> Also fix drive_del id argument type to activate completion.
I think this patch has to be split into at least three patches. One for
the drive_del change (which is unrelated with the other stuff), one
converting device_add & device_del and the third one converting
object_add and object_del.
Also, please, take the simplest conversion for the first patch, which
introduces the callback.
One more comment below.
>
> Signed-off-by: Hani Benhabiles <hani@linux.com>
> Suggested-by: Luiz Capitulino <lcapitulino@redhat.com>
> ---
> hmp-commands.hx | 6 +++++-
> hmp.h | 4 ++++
> monitor.c | 65 +++++++++++++++++++++++++++++++++++----------------------
> 3 files changed, 49 insertions(+), 26 deletions(-)
>
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index f3fc514..4c4d261 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -176,7 +176,7 @@ ETEXI
>
> {
> .name = "drive_del",
> - .args_type = "id:s",
> + .args_type = "id:B",
> .params = "device",
> .help = "remove host block device",
> .user_print = monitor_user_noop,
> @@ -658,6 +658,7 @@ ETEXI
> .help = "add device, like -device on the command line",
> .user_print = monitor_user_noop,
> .mhandler.cmd_new = do_device_add,
> + .command_completion = device_add_completion,
> },
>
> STEXI
> @@ -673,6 +674,7 @@ ETEXI
> .params = "device",
> .help = "remove device",
> .mhandler.cmd = hmp_device_del,
> + .command_completion = device_del_completion,
> },
>
> STEXI
> @@ -1254,6 +1256,7 @@ ETEXI
> .params = "[qom-type=]type,id=str[,prop=value][,...]",
> .help = "create QOM object",
> .mhandler.cmd = hmp_object_add,
> + .command_completion = object_add_completion,
> },
>
> STEXI
> @@ -1268,6 +1271,7 @@ ETEXI
> .params = "id",
> .help = "destroy QOM object",
> .mhandler.cmd = hmp_object_del,
> + .command_completion = object_del_completion,
> },
>
> STEXI
> diff --git a/hmp.h b/hmp.h
> index ed58f0e..558658f 100644
> --- a/hmp.h
> +++ b/hmp.h
> @@ -92,5 +92,9 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict);
> void hmp_cpu_add(Monitor *mon, const QDict *qdict);
> void hmp_object_add(Monitor *mon, const QDict *qdict);
> void hmp_object_del(Monitor *mon, const QDict *qdict);
> +void device_add_completion(Monitor *mon, int nb_args, const char *str);
> +void device_del_completion(Monitor *mon, int nb_args, const char *str);
> +void object_add_completion(Monitor *mon, int nb_args, const char *str);
> +void object_del_completion(Monitor *mon, int nb_args, const char *str);
>
> #endif
> diff --git a/monitor.c b/monitor.c
> index 342e83b..2c8528c 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -137,6 +137,7 @@ typedef struct mon_cmd_t {
> * used, and mhandler of 1st level plays the role of help function.
> */
> struct mon_cmd_t *sub_table;
> + void (*command_completion)(Monitor *mon, int nb_args, const char *str);
Why does command_completion need 'mon'? It seems to me that a ReadLineState
suffices.
> } mon_cmd_t;
>
> /* file descriptors passed via SCM_RIGHTS */
> @@ -4277,13 +4278,17 @@ static const char *next_arg_type(const char *typestr)
> return (p != NULL ? ++p : typestr);
> }
>
> -static void device_add_completion(ReadLineState *rs, const char *str)
> +void device_add_completion(Monitor *mon, int nb_args, const char *str)
> {
> GSList *list, *elt;
> size_t len;
>
> + if (nb_args != 2) {
> + return;
> + }
> +
> len = strlen(str);
> - readline_set_completion_index(rs, len);
> + readline_set_completion_index(mon->rs, len);
> list = elt = object_class_get_list(TYPE_DEVICE, false);
> while (elt) {
> const char *name;
> @@ -4291,35 +4296,39 @@ static void device_add_completion(ReadLineState *rs, const char *str)
> TYPE_DEVICE);
> name = object_class_get_name(OBJECT_CLASS(dc));
> if (!strncmp(name, str, len)) {
> - readline_add_completion(rs, name);
> + readline_add_completion(mon->rs, name);
> }
> elt = elt->next;
> }
> g_slist_free(list);
> }
>
> -static void object_add_completion(ReadLineState *rs, const char *str)
> +void object_add_completion(Monitor *mon, int nb_args, const char *str)
> {
> GSList *list, *elt;
> size_t len;
>
> + if (nb_args != 2) {
> + return;
> + }
> +
> len = strlen(str);
> - readline_set_completion_index(rs, len);
> + readline_set_completion_index(mon->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);
> + readline_add_completion(mon->rs, name);
> }
> elt = elt->next;
> }
> g_slist_free(list);
> }
>
> -static void device_del_completion(ReadLineState *rs, BusState *bus,
> - const char *str, size_t len)
> +static void device_del_bus_completion(ReadLineState *rs, BusState *bus,
> + const char *str, size_t len)
> {
> BusChild *kid;
>
> @@ -4332,18 +4341,34 @@ static void device_del_completion(ReadLineState *rs, BusState *bus,
> }
>
> QLIST_FOREACH(dev_child, &dev->child_bus, sibling) {
> - device_del_completion(rs, dev_child, str, len);
> + device_del_bus_completion(rs, dev_child, str, len);
> }
> }
> }
>
> -static void object_del_completion(ReadLineState *rs, const char *str)
> +void device_del_completion(Monitor *mon, int nb_args, const char *str)
> +{
> + size_t len;
> +
> + if (nb_args != 2) {
> + return;
> + }
> +
> + len = strlen(str);
> + readline_set_completion_index(mon->rs, len);
> + device_del_bus_completion(mon->rs, sysbus_get_default(), str, len);
> +}
> +
> +void object_del_completion(Monitor *mon, int nb_args, const char *str)
> {
> ObjectPropertyInfoList *list, *start;
> size_t len;
>
> + if (nb_args != 2) {
> + return;
> + }
> len = strlen(str);
> - readline_set_completion_index(rs, len);
> + readline_set_completion_index(mon->rs, len);
>
> start = list = qmp_qom_list("/objects", NULL);
> while (list) {
> @@ -4351,7 +4376,7 @@ static void object_del_completion(ReadLineState *rs, const char *str)
>
> if (!strncmp(info->type, "child<", 5)
> && !strncmp(info->name, str, len)) {
> - readline_add_completion(rs, info->name);
> + readline_add_completion(mon->rs, info->name);
> }
> list = list->next;
> }
> @@ -4395,6 +4420,9 @@ static void monitor_find_completion_by_table(Monitor *mon,
> return monitor_find_completion_by_table(mon, cmd->sub_table,
> &args[1], nb_args - 1);
> }
> + if (cmd->command_completion) {
> + return cmd->command_completion(mon, nb_args, args[nb_args - 1]);
> + }
>
> ptype = next_arg_type(cmd->args_type);
> for(i = 0; i < nb_args - 2; i++) {
> @@ -4421,13 +4449,6 @@ static void monitor_find_completion_by_table(Monitor *mon,
> readline_set_completion_index(mon->rs, strlen(str));
> bdrv_iterate(block_completion_it, &mbs);
> break;
> - 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':
> case 'S':
> if (!strcmp(cmd->name, "sendkey")) {
> @@ -4441,12 +4462,6 @@ static void monitor_find_completion_by_table(Monitor *mon,
> } else if (!strcmp(cmd->name, "help|?")) {
> monitor_find_completion_by_table(mon, cmd_table,
> &args[1], nb_args - 1);
> - } else if (!strcmp(cmd->name, "device_del") && nb_args == 2) {
> - size_t len = strlen(str);
> - readline_set_completion_index(mon->rs, len);
> - device_del_completion(mon->rs, sysbus_get_default(), str, len);
> - } else if (!strcmp(cmd->name, "object_del") && nb_args == 2) {
> - object_del_completion(mon->rs, str);
> }
> break;
> default:
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Qemu-devel] [PATCH 1/7] monitor: Add command_completion callback to mon_cmd_t.
2014-03-27 20:21 ` Luiz Capitulino
@ 2014-03-27 21:55 ` Hani Benhabiles
2014-03-28 13:10 ` Luiz Capitulino
0 siblings, 1 reply; 17+ messages in thread
From: Hani Benhabiles @ 2014-03-27 21:55 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: kwolf, imammedo, qemu-devel, stefanha
On Thu, Mar 27, 2014 at 04:21:51PM -0400, Luiz Capitulino wrote:
>
> I think this patch has to be split into at least three patches. One for
> the drive_del change (which is unrelated with the other stuff), one
> converting device_add & device_del and the third one converting
> object_add and object_del.
>
> Also, please, take the simplest conversion for the first patch, which
> introduces the callback.
>
Ok, I will split them. Just felt that the number of patches was growing-up too
fast.
> One more comment below.
>
> >
> > Signed-off-by: Hani Benhabiles <hani@linux.com>
> > Suggested-by: Luiz Capitulino <lcapitulino@redhat.com>
> > ---
> > hmp-commands.hx | 6 +++++-
> > hmp.h | 4 ++++
> > monitor.c | 65 +++++++++++++++++++++++++++++++++++----------------------
> > 3 files changed, 49 insertions(+), 26 deletions(-)
> >
> > diff --git a/hmp-commands.hx b/hmp-commands.hx
> > index f3fc514..4c4d261 100644
> > --- a/hmp-commands.hx
> > +++ b/hmp-commands.hx
> > @@ -176,7 +176,7 @@ ETEXI
> >
> > {
> > .name = "drive_del",
> > - .args_type = "id:s",
> > + .args_type = "id:B",
> > .params = "device",
> > .help = "remove host block device",
> > .user_print = monitor_user_noop,
> > @@ -658,6 +658,7 @@ ETEXI
> > .help = "add device, like -device on the command line",
> > .user_print = monitor_user_noop,
> > .mhandler.cmd_new = do_device_add,
> > + .command_completion = device_add_completion,
> > },
> >
> > STEXI
> > @@ -673,6 +674,7 @@ ETEXI
> > .params = "device",
> > .help = "remove device",
> > .mhandler.cmd = hmp_device_del,
> > + .command_completion = device_del_completion,
> > },
> >
> > STEXI
> > @@ -1254,6 +1256,7 @@ ETEXI
> > .params = "[qom-type=]type,id=str[,prop=value][,...]",
> > .help = "create QOM object",
> > .mhandler.cmd = hmp_object_add,
> > + .command_completion = object_add_completion,
> > },
> >
> > STEXI
> > @@ -1268,6 +1271,7 @@ ETEXI
> > .params = "id",
> > .help = "destroy QOM object",
> > .mhandler.cmd = hmp_object_del,
> > + .command_completion = object_del_completion,
> > },
> >
> > STEXI
> > diff --git a/hmp.h b/hmp.h
> > index ed58f0e..558658f 100644
> > --- a/hmp.h
> > +++ b/hmp.h
> > @@ -92,5 +92,9 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict);
> > void hmp_cpu_add(Monitor *mon, const QDict *qdict);
> > void hmp_object_add(Monitor *mon, const QDict *qdict);
> > void hmp_object_del(Monitor *mon, const QDict *qdict);
> > +void device_add_completion(Monitor *mon, int nb_args, const char *str);
> > +void device_del_completion(Monitor *mon, int nb_args, const char *str);
> > +void object_add_completion(Monitor *mon, int nb_args, const char *str);
> > +void object_del_completion(Monitor *mon, int nb_args, const char *str);
> >
> > #endif
> > diff --git a/monitor.c b/monitor.c
> > index 342e83b..2c8528c 100644
> > --- a/monitor.c
> > +++ b/monitor.c
> > @@ -137,6 +137,7 @@ typedef struct mon_cmd_t {
> > * used, and mhandler of 1st level plays the role of help function.
> > */
> > struct mon_cmd_t *sub_table;
> > + void (*command_completion)(Monitor *mon, int nb_args, const char *str);
>
> Why does command_completion need 'mon'? It seems to me that a ReadLineState
> suffices.
No particular reason right now. I just tried to keep the prototype general
enough in order to not have to make a mass conversion in case some need shows up
in the future. Should I just use ReadLineState in the next series version ?
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Qemu-devel] [PATCH 1/7] monitor: Add command_completion callback to mon_cmd_t.
2014-03-27 21:55 ` Hani Benhabiles
@ 2014-03-28 13:10 ` Luiz Capitulino
0 siblings, 0 replies; 17+ messages in thread
From: Luiz Capitulino @ 2014-03-28 13:10 UTC (permalink / raw)
To: Hani Benhabiles; +Cc: kwolf, imammedo, qemu-devel, stefanha
On Thu, 27 Mar 2014 22:55:46 +0100
Hani Benhabiles <kroosec@gmail.com> wrote:
> On Thu, Mar 27, 2014 at 04:21:51PM -0400, Luiz Capitulino wrote:
> >
> > I think this patch has to be split into at least three patches. One for
> > the drive_del change (which is unrelated with the other stuff), one
> > converting device_add & device_del and the third one converting
> > object_add and object_del.
> >
> > Also, please, take the simplest conversion for the first patch, which
> > introduces the callback.
> >
>
> Ok, I will split them. Just felt that the number of patches was growing-up too
> fast.
That's not a problem.
> > One more comment below.
> >
> > >
> > > Signed-off-by: Hani Benhabiles <hani@linux.com>
> > > Suggested-by: Luiz Capitulino <lcapitulino@redhat.com>
> > > ---
> > > hmp-commands.hx | 6 +++++-
> > > hmp.h | 4 ++++
> > > monitor.c | 65 +++++++++++++++++++++++++++++++++++----------------------
> > > 3 files changed, 49 insertions(+), 26 deletions(-)
> > >
> > > diff --git a/hmp-commands.hx b/hmp-commands.hx
> > > index f3fc514..4c4d261 100644
> > > --- a/hmp-commands.hx
> > > +++ b/hmp-commands.hx
> > > @@ -176,7 +176,7 @@ ETEXI
> > >
> > > {
> > > .name = "drive_del",
> > > - .args_type = "id:s",
> > > + .args_type = "id:B",
> > > .params = "device",
> > > .help = "remove host block device",
> > > .user_print = monitor_user_noop,
> > > @@ -658,6 +658,7 @@ ETEXI
> > > .help = "add device, like -device on the command line",
> > > .user_print = monitor_user_noop,
> > > .mhandler.cmd_new = do_device_add,
> > > + .command_completion = device_add_completion,
> > > },
> > >
> > > STEXI
> > > @@ -673,6 +674,7 @@ ETEXI
> > > .params = "device",
> > > .help = "remove device",
> > > .mhandler.cmd = hmp_device_del,
> > > + .command_completion = device_del_completion,
> > > },
> > >
> > > STEXI
> > > @@ -1254,6 +1256,7 @@ ETEXI
> > > .params = "[qom-type=]type,id=str[,prop=value][,...]",
> > > .help = "create QOM object",
> > > .mhandler.cmd = hmp_object_add,
> > > + .command_completion = object_add_completion,
> > > },
> > >
> > > STEXI
> > > @@ -1268,6 +1271,7 @@ ETEXI
> > > .params = "id",
> > > .help = "destroy QOM object",
> > > .mhandler.cmd = hmp_object_del,
> > > + .command_completion = object_del_completion,
> > > },
> > >
> > > STEXI
> > > diff --git a/hmp.h b/hmp.h
> > > index ed58f0e..558658f 100644
> > > --- a/hmp.h
> > > +++ b/hmp.h
> > > @@ -92,5 +92,9 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict);
> > > void hmp_cpu_add(Monitor *mon, const QDict *qdict);
> > > void hmp_object_add(Monitor *mon, const QDict *qdict);
> > > void hmp_object_del(Monitor *mon, const QDict *qdict);
> > > +void device_add_completion(Monitor *mon, int nb_args, const char *str);
> > > +void device_del_completion(Monitor *mon, int nb_args, const char *str);
> > > +void object_add_completion(Monitor *mon, int nb_args, const char *str);
> > > +void object_del_completion(Monitor *mon, int nb_args, const char *str);
> > >
> > > #endif
> > > diff --git a/monitor.c b/monitor.c
> > > index 342e83b..2c8528c 100644
> > > --- a/monitor.c
> > > +++ b/monitor.c
> > > @@ -137,6 +137,7 @@ typedef struct mon_cmd_t {
> > > * used, and mhandler of 1st level plays the role of help function.
> > > */
> > > struct mon_cmd_t *sub_table;
> > > + void (*command_completion)(Monitor *mon, int nb_args, const char *str);
> >
> > Why does command_completion need 'mon'? It seems to me that a ReadLineState
> > suffices.
>
> No particular reason right now. I just tried to keep the prototype general
> enough in order to not have to make a mass conversion in case some need shows up
> in the future. Should I just use ReadLineState in the next series version ?
IMO, yes. If, in the future, it turns out we need a Monitor object we can
just update the callback signature.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 2/7] monitor: Add chardev-remove id argument completion.
2014-03-09 11:16 [Qemu-devel] [PATCH 0/7] monitor: Completion support for various commands Hani Benhabiles
2014-03-09 11:16 ` [Qemu-devel] [PATCH 1/7] monitor: Add command_completion callback to mon_cmd_t Hani Benhabiles
@ 2014-03-09 11:16 ` Hani Benhabiles
2014-03-09 11:16 ` [Qemu-devel] [PATCH 3/7] monitor: Add chardev-add backend " Hani Benhabiles
` (6 subsequent siblings)
8 siblings, 0 replies; 17+ messages in thread
From: Hani Benhabiles @ 2014-03-09 11:16 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, imammedo, stefanha, lcapitulino
Signed-off-by: Hani Benhabiles <hani@linux.com>
---
hmp-commands.hx | 1 +
hmp.h | 2 ++
monitor.c | 23 +++++++++++++++++++++++
3 files changed, 26 insertions(+)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 4c4d261..4f0f053 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1630,6 +1630,7 @@ ETEXI
.params = "id",
.help = "remove chardev",
.mhandler.cmd = hmp_chardev_remove,
+ .command_completion = chardev_remove_completion,
},
STEXI
diff --git a/hmp.h b/hmp.h
index 558658f..162ccfa 100644
--- a/hmp.h
+++ b/hmp.h
@@ -96,5 +96,7 @@ void device_add_completion(Monitor *mon, int nb_args, const char *str);
void device_del_completion(Monitor *mon, int nb_args, const char *str);
void object_add_completion(Monitor *mon, int nb_args, const char *str);
void object_del_completion(Monitor *mon, int nb_args, const char *str);
+void chardev_remove_completion(Monitor *mon, int nb_args, const char *str);
+
#endif
diff --git a/monitor.c b/monitor.c
index 2c8528c..b79c0bd 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4346,6 +4346,29 @@ static void device_del_bus_completion(ReadLineState *rs, BusState *bus,
}
}
+void chardev_remove_completion(Monitor *mon, int nb_args, const char *str)
+{
+ size_t len;
+ ChardevInfoList *list, *start;
+
+ if (nb_args != 2) {
+ return;
+ }
+ len = strlen(str);
+ readline_set_completion_index(mon->rs, len);
+
+ start = list = qmp_query_chardev(NULL);
+ while (list) {
+ ChardevInfo *chr = list->value;
+
+ if (!strncmp(chr->label, str, len)) {
+ readline_add_completion(mon->rs, chr->label);
+ }
+ list = list->next;
+ }
+ qapi_free_ChardevInfoList(start);
+}
+
void device_del_completion(Monitor *mon, int nb_args, const char *str)
{
size_t len;
--
1.8.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 3/7] monitor: Add chardev-add backend argument completion.
2014-03-09 11:16 [Qemu-devel] [PATCH 0/7] monitor: Completion support for various commands Hani Benhabiles
2014-03-09 11:16 ` [Qemu-devel] [PATCH 1/7] monitor: Add command_completion callback to mon_cmd_t Hani Benhabiles
2014-03-09 11:16 ` [Qemu-devel] [PATCH 2/7] monitor: Add chardev-remove id argument completion Hani Benhabiles
@ 2014-03-09 11:16 ` Hani Benhabiles
2014-03-09 11:16 ` [Qemu-devel] [PATCH 4/7] monitor: Add cpu index " Hani Benhabiles
` (5 subsequent siblings)
8 siblings, 0 replies; 17+ messages in thread
From: Hani Benhabiles @ 2014-03-09 11:16 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, imammedo, stefanha, lcapitulino
Signed-off-by: Hani Benhabiles <hani@linux.com>
---
hmp-commands.hx | 1 +
hmp.h | 1 +
monitor.c | 23 +++++++++++++++++++++++
3 files changed, 25 insertions(+)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 4f0f053..a411d4f 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1614,6 +1614,7 @@ ETEXI
.params = "args",
.help = "add chardev",
.mhandler.cmd = hmp_chardev_add,
+ .command_completion = chardev_add_completion,
},
STEXI
diff --git a/hmp.h b/hmp.h
index 162ccfa..dc03984 100644
--- a/hmp.h
+++ b/hmp.h
@@ -96,6 +96,7 @@ void device_add_completion(Monitor *mon, int nb_args, const char *str);
void device_del_completion(Monitor *mon, int nb_args, const char *str);
void object_add_completion(Monitor *mon, int nb_args, const char *str);
void object_del_completion(Monitor *mon, int nb_args, const char *str);
+void chardev_add_completion(Monitor *mon, int nb_args, const char *str);
void chardev_remove_completion(Monitor *mon, int nb_args, const char *str);
diff --git a/monitor.c b/monitor.c
index b79c0bd..73442c6 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4278,6 +4278,29 @@ static const char *next_arg_type(const char *typestr)
return (p != NULL ? ++p : typestr);
}
+void chardev_add_completion(Monitor *mon, int nb_args, const char *str)
+{
+ size_t len;
+ ChardevBackendInfoList *list, *start;
+
+ if (nb_args != 2) {
+ return;
+ }
+ len = strlen(str);
+ readline_set_completion_index(mon->rs, len);
+
+ start = list = qmp_query_chardev_backends(NULL);
+ while (list) {
+ const char *chr_name = list->value->name;
+
+ if (!strncmp(chr_name, str, len)) {
+ readline_add_completion(mon->rs, chr_name);
+ }
+ list = list->next;
+ }
+ qapi_free_ChardevBackendInfoList(start);
+}
+
void device_add_completion(Monitor *mon, int nb_args, const char *str)
{
GSList *list, *elt;
--
1.8.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 4/7] monitor: Add cpu index argument completion.
2014-03-09 11:16 [Qemu-devel] [PATCH 0/7] monitor: Completion support for various commands Hani Benhabiles
` (2 preceding siblings ...)
2014-03-09 11:16 ` [Qemu-devel] [PATCH 3/7] monitor: Add chardev-add backend " Hani Benhabiles
@ 2014-03-09 11:16 ` Hani Benhabiles
2014-03-27 20:24 ` Luiz Capitulino
2014-03-09 11:16 ` [Qemu-devel] [PATCH 5/7] monitor: Add set_link arguments completion Hani Benhabiles
` (4 subsequent siblings)
8 siblings, 1 reply; 17+ messages in thread
From: Hani Benhabiles @ 2014-03-09 11:16 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, imammedo, stefanha, lcapitulino
Signed-off-by: Hani Benhabiles <hani@linux.com>
---
hmp-commands.hx | 1 +
hmp.h | 1 +
monitor.c | 24 ++++++++++++++++++++++++
3 files changed, 26 insertions(+)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index a411d4f..813c0fb 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -690,6 +690,7 @@ ETEXI
.params = "index",
.help = "set the default CPU",
.mhandler.cmd = hmp_cpu,
+ .command_completion = cpu_completion,
},
STEXI
diff --git a/hmp.h b/hmp.h
index dc03984..59a60ed 100644
--- a/hmp.h
+++ b/hmp.h
@@ -98,6 +98,7 @@ void object_add_completion(Monitor *mon, int nb_args, const char *str);
void object_del_completion(Monitor *mon, int nb_args, const char *str);
void chardev_add_completion(Monitor *mon, int nb_args, const char *str);
void chardev_remove_completion(Monitor *mon, int nb_args, const char *str);
+void cpu_completion(Monitor *mon, int nb_args, const char *str);
#endif
diff --git a/monitor.c b/monitor.c
index 73442c6..43aab76 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4429,6 +4429,30 @@ void object_del_completion(Monitor *mon, int nb_args, const char *str)
qapi_free_ObjectPropertyInfoList(start);
}
+void cpu_completion(Monitor *mon, int nb_args, const char *str)
+{
+ CpuInfoList *cpu_list, *start;
+ size_t len;
+
+ if (nb_args != 2) {
+ return;
+ }
+ len = strlen(str);
+ readline_set_completion_index(mon->rs, len);
+
+ start = cpu_list = qmp_query_cpus(NULL);
+ while (cpu_list) {
+ char name[16];
+ snprintf(name, sizeof(name), "%" PRId64, cpu_list->value->CPU);
+
+ if (!strncmp(str, name, len)) {
+ readline_add_completion(mon->rs, name);
+ }
+ cpu_list = cpu_list->next;
+ }
+ qapi_free_CpuInfoList(start);
+}
+
static void monitor_find_completion_by_table(Monitor *mon,
const mon_cmd_t *cmd_table,
char **args,
--
1.8.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [Qemu-devel] [PATCH 4/7] monitor: Add cpu index argument completion.
2014-03-09 11:16 ` [Qemu-devel] [PATCH 4/7] monitor: Add cpu index " Hani Benhabiles
@ 2014-03-27 20:24 ` Luiz Capitulino
2014-03-27 21:51 ` Hani Benhabiles
0 siblings, 1 reply; 17+ messages in thread
From: Luiz Capitulino @ 2014-03-27 20:24 UTC (permalink / raw)
To: Hani Benhabiles; +Cc: kwolf, imammedo, qemu-devel, stefanha
On Sun, 9 Mar 2014 12:16:14 +0100
Hani Benhabiles <kroosec@gmail.com> wrote:
> Signed-off-by: Hani Benhabiles <hani@linux.com>
Honest question: is this one really worth it? Aren't we just
auto-completing a single integer?
> ---
> hmp-commands.hx | 1 +
> hmp.h | 1 +
> monitor.c | 24 ++++++++++++++++++++++++
> 3 files changed, 26 insertions(+)
>
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index a411d4f..813c0fb 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -690,6 +690,7 @@ ETEXI
> .params = "index",
> .help = "set the default CPU",
> .mhandler.cmd = hmp_cpu,
> + .command_completion = cpu_completion,
> },
>
> STEXI
> diff --git a/hmp.h b/hmp.h
> index dc03984..59a60ed 100644
> --- a/hmp.h
> +++ b/hmp.h
> @@ -98,6 +98,7 @@ void object_add_completion(Monitor *mon, int nb_args, const char *str);
> void object_del_completion(Monitor *mon, int nb_args, const char *str);
> void chardev_add_completion(Monitor *mon, int nb_args, const char *str);
> void chardev_remove_completion(Monitor *mon, int nb_args, const char *str);
> +void cpu_completion(Monitor *mon, int nb_args, const char *str);
>
>
> #endif
> diff --git a/monitor.c b/monitor.c
> index 73442c6..43aab76 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -4429,6 +4429,30 @@ void object_del_completion(Monitor *mon, int nb_args, const char *str)
> qapi_free_ObjectPropertyInfoList(start);
> }
>
> +void cpu_completion(Monitor *mon, int nb_args, const char *str)
> +{
> + CpuInfoList *cpu_list, *start;
> + size_t len;
> +
> + if (nb_args != 2) {
> + return;
> + }
> + len = strlen(str);
> + readline_set_completion_index(mon->rs, len);
> +
> + start = cpu_list = qmp_query_cpus(NULL);
> + while (cpu_list) {
> + char name[16];
> + snprintf(name, sizeof(name), "%" PRId64, cpu_list->value->CPU);
> +
> + if (!strncmp(str, name, len)) {
> + readline_add_completion(mon->rs, name);
> + }
> + cpu_list = cpu_list->next;
> + }
> + qapi_free_CpuInfoList(start);
> +}
> +
> static void monitor_find_completion_by_table(Monitor *mon,
> const mon_cmd_t *cmd_table,
> char **args,
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Qemu-devel] [PATCH 4/7] monitor: Add cpu index argument completion.
2014-03-27 20:24 ` Luiz Capitulino
@ 2014-03-27 21:51 ` Hani Benhabiles
0 siblings, 0 replies; 17+ messages in thread
From: Hani Benhabiles @ 2014-03-27 21:51 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: kwolf, imammedo, qemu-devel, stefanha
On Thu, Mar 27, 2014 at 04:24:50PM -0400, Luiz Capitulino wrote:
> On Sun, 9 Mar 2014 12:16:14 +0100
> Hani Benhabiles <kroosec@gmail.com> wrote:
>
> > Signed-off-by: Hani Benhabiles <hani@linux.com>
>
> Honest question: is this one really worth it? Aren't we just
> auto-completing a single integer?
It could for example serve for fast discovery, without having to check
"info cpus" before hand.
No strong opinion about it, so feel free to take it or not. I did it because
well, it was trivial enough and took too few efforts to leave behind.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 5/7] monitor: Add set_link arguments completion.
2014-03-09 11:16 [Qemu-devel] [PATCH 0/7] monitor: Completion support for various commands Hani Benhabiles
` (3 preceding siblings ...)
2014-03-09 11:16 ` [Qemu-devel] [PATCH 4/7] monitor: Add cpu index " Hani Benhabiles
@ 2014-03-09 11:16 ` Hani Benhabiles
2014-03-09 11:16 ` [Qemu-devel] [PATCH 6/7] monitor: Add netdev_add type argument completion Hani Benhabiles
` (3 subsequent siblings)
8 siblings, 0 replies; 17+ messages in thread
From: Hani Benhabiles @ 2014-03-09 11:16 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, imammedo, stefanha, lcapitulino
This also adds the add_completion_option() function which is to be used for
other commands completions as well.
Signed-off-by: Hani Benhabiles <hani@linux.com>
---
hmp-commands.hx | 1 +
hmp.h | 1 +
monitor.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 47 insertions(+)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 813c0fb..fbd303a 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1332,6 +1332,7 @@ ETEXI
.params = "name on|off",
.help = "change the link status of a network adapter",
.mhandler.cmd = hmp_set_link,
+ .command_completion = set_link_completion,
},
STEXI
diff --git a/hmp.h b/hmp.h
index 59a60ed..df19f1c 100644
--- a/hmp.h
+++ b/hmp.h
@@ -99,6 +99,7 @@ void object_del_completion(Monitor *mon, int nb_args, const char *str);
void chardev_add_completion(Monitor *mon, int nb_args, const char *str);
void chardev_remove_completion(Monitor *mon, int nb_args, const char *str);
void cpu_completion(Monitor *mon, int nb_args, const char *str);
+void set_link_completion(Monitor *mon, int nb_args, const char *str);
#endif
diff --git a/monitor.c b/monitor.c
index 43aab76..9905113 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4278,6 +4278,17 @@ static const char *next_arg_type(const char *typestr)
return (p != NULL ? ++p : typestr);
}
+static void add_completion_option(Monitor *mon, const char *str,
+ const char *option)
+{
+ if (!str || !option) {
+ return;
+ }
+ if (!strncmp(option, str, strlen(str))) {
+ readline_add_completion(mon->rs, option);
+ }
+}
+
void chardev_add_completion(Monitor *mon, int nb_args, const char *str)
{
size_t len;
@@ -4453,6 +4464,40 @@ void cpu_completion(Monitor *mon, int nb_args, const char *str)
qapi_free_CpuInfoList(start);
}
+struct NicCompletionData {
+ Monitor *mon;
+ const char *str;
+};
+
+static void check_nic_completion(NICState *nic, void *data)
+{
+ Monitor *mon;
+ const char *str, *name;
+
+ mon = ((struct NicCompletionData *) data)->mon;
+ str = ((struct NicCompletionData *) data)->str;
+ name = nic->ncs->name;
+
+ if (!strncmp(name, str, strlen(str))) {
+ readline_add_completion(mon->rs, nic->ncs->name);
+ }
+}
+
+void set_link_completion(Monitor *mon, int nb_args, const char *str)
+{
+ readline_set_completion_index(mon->rs, strlen(str));
+ if (nb_args == 2) {
+ struct NicCompletionData data = {
+ .mon = mon,
+ .str = str,
+ };
+ qemu_foreach_nic(check_nic_completion, &data);
+ } else if (nb_args == 3) {
+ add_completion_option(mon, str, "on");
+ add_completion_option(mon, str, "off");
+ }
+}
+
static void monitor_find_completion_by_table(Monitor *mon,
const mon_cmd_t *cmd_table,
char **args,
--
1.8.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 6/7] monitor: Add netdev_add type argument completion.
2014-03-09 11:16 [Qemu-devel] [PATCH 0/7] monitor: Completion support for various commands Hani Benhabiles
` (4 preceding siblings ...)
2014-03-09 11:16 ` [Qemu-devel] [PATCH 5/7] monitor: Add set_link arguments completion Hani Benhabiles
@ 2014-03-09 11:16 ` Hani Benhabiles
2014-03-09 11:16 ` [Qemu-devel] [PATCH 7/7] monitor: Add netdev_del id " Hani Benhabiles
` (2 subsequent siblings)
8 siblings, 0 replies; 17+ messages in thread
From: Hani Benhabiles @ 2014-03-09 11:16 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, imammedo, stefanha, lcapitulino
Also update the command's documentation.
Signed-off-by: Hani Benhabiles <hani@linux.com>
---
hmp-commands.hx | 3 ++-
hmp.h | 1 +
monitor.c | 18 ++++++++++++++++++
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index fbd303a..b009561 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1226,9 +1226,10 @@ ETEXI
{
.name = "netdev_add",
.args_type = "netdev:O",
- .params = "[user|tap|socket|hubport|netmap],id=str[,prop=value][,...]",
+ .params = "[user|tap|socket|vde|bridge|hubport|netmap],id=str[,prop=value][,...]",
.help = "add host network device",
.mhandler.cmd = hmp_netdev_add,
+ .command_completion = netdev_add_completion,
},
STEXI
diff --git a/hmp.h b/hmp.h
index df19f1c..cda0943 100644
--- a/hmp.h
+++ b/hmp.h
@@ -100,6 +100,7 @@ void chardev_add_completion(Monitor *mon, int nb_args, const char *str);
void chardev_remove_completion(Monitor *mon, int nb_args, const char *str);
void cpu_completion(Monitor *mon, int nb_args, const char *str);
void set_link_completion(Monitor *mon, int nb_args, const char *str);
+void netdev_add_completion(Monitor *mon, int nb_args, const char *str);
#endif
diff --git a/monitor.c b/monitor.c
index 9905113..b1378c6 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4312,6 +4312,24 @@ void chardev_add_completion(Monitor *mon, int nb_args, const char *str)
qapi_free_ChardevBackendInfoList(start);
}
+void netdev_add_completion(Monitor *mon, int nb_args, const char *str)
+{
+ size_t len;
+
+ if (nb_args != 2) {
+ return;
+ }
+ len = strlen(str);
+ readline_set_completion_index(mon->rs, len);
+ add_completion_option(mon, str, "user");
+ add_completion_option(mon, str, "tap");
+ add_completion_option(mon, str, "socket");
+ add_completion_option(mon, str, "vde");
+ add_completion_option(mon, str, "bridge");
+ add_completion_option(mon, str, "hubport");
+ add_completion_option(mon, str, "netmap");
+}
+
void device_add_completion(Monitor *mon, int nb_args, const char *str)
{
GSList *list, *elt;
--
1.8.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 7/7] monitor: Add netdev_del id argument completion.
2014-03-09 11:16 [Qemu-devel] [PATCH 0/7] monitor: Completion support for various commands Hani Benhabiles
` (5 preceding siblings ...)
2014-03-09 11:16 ` [Qemu-devel] [PATCH 6/7] monitor: Add netdev_add type argument completion Hani Benhabiles
@ 2014-03-09 11:16 ` Hani Benhabiles
2014-03-10 14:44 ` [Qemu-devel] [PATCH 0/7] monitor: Completion support for various commands Luiz Capitulino
2014-03-27 20:26 ` Luiz Capitulino
8 siblings, 0 replies; 17+ messages in thread
From: Hani Benhabiles @ 2014-03-09 11:16 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, imammedo, stefanha, lcapitulino
Signed-off-by: Hani Benhabiles <hani@linux.com>
---
hmp-commands.hx | 1 +
hmp.h | 1 +
monitor.c | 15 +++++++++++++++
3 files changed, 17 insertions(+)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index b009561..d252ffc 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1244,6 +1244,7 @@ ETEXI
.params = "id",
.help = "remove host network device",
.mhandler.cmd = hmp_netdev_del,
+ .command_completion = netdev_del_completion,
},
STEXI
diff --git a/hmp.h b/hmp.h
index cda0943..ef0fcd3 100644
--- a/hmp.h
+++ b/hmp.h
@@ -101,6 +101,7 @@ void chardev_remove_completion(Monitor *mon, int nb_args, const char *str);
void cpu_completion(Monitor *mon, int nb_args, const char *str);
void set_link_completion(Monitor *mon, int nb_args, const char *str);
void netdev_add_completion(Monitor *mon, int nb_args, const char *str);
+void netdev_del_completion(Monitor *mon, int nb_args, const char *str);
#endif
diff --git a/monitor.c b/monitor.c
index b1378c6..3d194fa 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4516,6 +4516,21 @@ void set_link_completion(Monitor *mon, int nb_args, const char *str)
}
}
+void netdev_del_completion(Monitor *mon, int nb_args, const char *str)
+{
+ struct NicCompletionData data = {
+ .mon = mon,
+ .str = str,
+ };
+
+ if (nb_args != 2) {
+ return;
+ }
+
+ readline_set_completion_index(mon->rs, strlen(str));
+ qemu_foreach_nic(check_nic_completion, &data);
+}
+
static void monitor_find_completion_by_table(Monitor *mon,
const mon_cmd_t *cmd_table,
char **args,
--
1.8.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [Qemu-devel] [PATCH 0/7] monitor: Completion support for various commands.
2014-03-09 11:16 [Qemu-devel] [PATCH 0/7] monitor: Completion support for various commands Hani Benhabiles
` (6 preceding siblings ...)
2014-03-09 11:16 ` [Qemu-devel] [PATCH 7/7] monitor: Add netdev_del id " Hani Benhabiles
@ 2014-03-10 14:44 ` Luiz Capitulino
2014-03-11 7:18 ` Hani Benhabiles
2014-03-27 20:26 ` Luiz Capitulino
8 siblings, 1 reply; 17+ messages in thread
From: Luiz Capitulino @ 2014-03-10 14:44 UTC (permalink / raw)
To: Hani Benhabiles; +Cc: kwolf, imammedo, qemu-devel, stefanha
On Sun, 9 Mar 2014 12:16:10 +0100
Hani Benhabiles <kroosec@gmail.com> wrote:
> This patch series adds a new callback to mon_cmd_t which will make adding
> completion support for more commands cleaner.
>
> It then adds full or partial arguments completion for 7 different hmp commands.
Not high priority for 2.0, right?
I won't have review bandwidth to review this before hard-freeze (which happens
in two days), so this is going to be postponed to 2.1.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Qemu-devel] [PATCH 0/7] monitor: Completion support for various commands.
2014-03-10 14:44 ` [Qemu-devel] [PATCH 0/7] monitor: Completion support for various commands Luiz Capitulino
@ 2014-03-11 7:18 ` Hani Benhabiles
0 siblings, 0 replies; 17+ messages in thread
From: Hani Benhabiles @ 2014-03-11 7:18 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: kwolf, imammedo, qemu-devel, stefanha
On Mon, Mar 10, 2014 at 10:44:45AM -0400, Luiz Capitulino wrote:
> On Sun, 9 Mar 2014 12:16:10 +0100
> Hani Benhabiles <kroosec@gmail.com> wrote:
>
> > This patch series adds a new callback to mon_cmd_t which will make adding
> > completion support for more commands cleaner.
> >
> > It then adds full or partial arguments completion for 7 different hmp commands.
>
> Not high priority for 2.0, right?
>
> I won't have review bandwidth to review this before hard-freeze (which happens
> in two days), so this is going to be postponed to 2.1.
Not high priority. Just that I will send another series that will build on top
of this.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Qemu-devel] [PATCH 0/7] monitor: Completion support for various commands.
2014-03-09 11:16 [Qemu-devel] [PATCH 0/7] monitor: Completion support for various commands Hani Benhabiles
` (7 preceding siblings ...)
2014-03-10 14:44 ` [Qemu-devel] [PATCH 0/7] monitor: Completion support for various commands Luiz Capitulino
@ 2014-03-27 20:26 ` Luiz Capitulino
2014-03-27 21:47 ` Hani Benhabiles
8 siblings, 1 reply; 17+ messages in thread
From: Luiz Capitulino @ 2014-03-27 20:26 UTC (permalink / raw)
To: Hani Benhabiles; +Cc: kwolf, qemu-devel, Markus Armbruster, stefanha, imammedo
On Sun, 9 Mar 2014 12:16:10 +0100
Hani Benhabiles <kroosec@gmail.com> wrote:
> This patch series adds a new callback to mon_cmd_t which will make adding
> completion support for more commands cleaner.
>
> It then adds full or partial arguments completion for 7 different hmp commands.
The general approach seems OK to me, but I could use some help to review
the entire series.
Stefan, could you please review the set_link(), netdev_add/del() changes?
>
> Hani Benhabiles (7):
> monitor: Add command_completion callback to mon_cmd_t.
> monitor: Add chardev-remove id argument completion.
> monitor: Add chardev-add backend argument completion.
> monitor: Add cpu index argument completion.
> monitor: Add set_link arguments completion.
> monitor: Add netdev_add type argument completion.
> monitor: Add netdev_del id argument completion.
>
> hmp-commands.hx | 14 +++-
> hmp.h | 11 +++
> monitor.c | 213 +++++++++++++++++++++++++++++++++++++++++++++++++-------
> 3 files changed, 211 insertions(+), 27 deletions(-)
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Qemu-devel] [PATCH 0/7] monitor: Completion support for various commands.
2014-03-27 20:26 ` Luiz Capitulino
@ 2014-03-27 21:47 ` Hani Benhabiles
0 siblings, 0 replies; 17+ messages in thread
From: Hani Benhabiles @ 2014-03-27 21:47 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: kwolf, qemu-devel, Markus Armbruster, stefanha, imammedo
On Thu, Mar 27, 2014 at 04:26:15PM -0400, Luiz Capitulino wrote:
> On Sun, 9 Mar 2014 12:16:10 +0100
> Hani Benhabiles <kroosec@gmail.com> wrote:
>
> > This patch series adds a new callback to mon_cmd_t which will make adding
> > completion support for more commands cleaner.
> >
> > It then adds full or partial arguments completion for 7 different hmp commands.
>
> The general approach seems OK to me, but I could use some help to review
> the entire series.
>
> Stefan, could you please review the set_link(), netdev_add/del() changes?
>
Better review the new series I will send soon.
^ permalink raw reply [flat|nested] 17+ messages in thread