aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHani Benhabiles <kroosec@gmail.com>2014-02-06 23:30:11 +0100
committerLuiz Capitulino <lcapitulino@redhat.com>2014-02-17 11:57:23 -0500
commit992d3e64c89bd2af1ae005080636e8da43c1b500 (patch)
tree93e163f69239eb329cd97c8710c98618441547c4
parentfca72d9b4994343dd1e48d9bb9f45914f4429cfb (diff)
monitor: Add device_add device argument completion.
Signed-off-by: Hani Benhabiles <hani@linux.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
-rw-r--r--monitor.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/monitor.c b/monitor.c
index c90fc1dff2..4ffe44d0d3 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4254,6 +4254,27 @@ static const char *next_arg_type(const char *typestr)
return (p != NULL ? ++p : typestr);
}
+static void device_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_DEVICE, false);
+ while (elt) {
+ const char *name;
+ DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, elt->data,
+ TYPE_DEVICE);
+ name = object_class_get_name(OBJECT_CLASS(dc));
+ if (!strncmp(name, str, len)) {
+ 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)
{
@@ -4336,6 +4357,11 @@ 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);
+ }
+ break;
case 's':
case 'S':
if (!strcmp(cmd->name, "sendkey")) {