From: Andrzej Zaborowski <balr...@gmail.com> Signed-off-by: Andrzej Zaborowski <andrew.zaborow...@intel.com> --- v2: pass only char *prop_name as qdev_driver_prop_foreach_func parameter, Anthony noted Property was soon going away. v3: use QOM. --- monitor.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/monitor.c b/monitor.c index aadbdcb..28f5b9a 100644 --- a/monitor.c +++ b/monitor.c @@ -3917,6 +3917,27 @@ static void block_completion_it(void *opaque, BlockDriverState *bs) } } +static void class_completion_it(ObjectClass *klass, void *opaque) +{ + const char *input = opaque; + const char *name = object_class_get_name(klass); + + if (input[0] == '\0' || !strncmp(name, input, strlen(input))) { + readline_add_completion(cur_mon->rs, name); + } +} + +static int driver_prop_completion_it(Property *info, void *opaque) +{ + const char *input = opaque; + + if (input[0] == '\0' || !strncmp(info->name, input, strlen(input))) { + readline_add_completion(cur_mon->rs, info->name); + } + + return 0; +} + /* NOTE: this parser is an approximate form of the real command parser */ static void parse_cmdline(const char *cmdline, int *pnb_args, char **args) @@ -3957,6 +3978,7 @@ static void monitor_find_completion(const char *cmdline) const char *ptype, *str; const mon_cmd_t *cmd; const KeyDef *key; + char *pkey; parse_cmdline(cmdline, &nb_args, args); #ifdef DEBUG_COMPLETION @@ -3995,6 +4017,7 @@ static void monitor_find_completion(const char *cmdline) goto cleanup; } + key_get_info(cmd->args_type, &pkey); ptype = next_arg_type(cmd->args_type); for(i = 0; i < nb_args - 2; i++) { if (*ptype != '\0') { @@ -4040,9 +4063,44 @@ static void monitor_find_completion(const char *cmdline) } } break; + case 'O': + if (!strcmp(pkey, "device")) { + char *sep = strrchr(str, ','); + + readline_set_completion_index(cur_mon->rs, + strlen(sep ? sep + 1 : str)); + if (sep) { + char *driver = g_strndup(str, strchr(str, ',') - str); + ObjectClass *klass = object_class_by_name(driver); + DeviceClass *info; + Property *prop; + + g_free(driver); + if (!klass) { + break; + } + + info = DEVICE_CLASS(klass); + for (prop = info->props; prop && prop->name; prop++) { + driver_prop_completion_it(prop, sep + 1); + } + if (info->bus_info) { + for (prop = info->bus_info->props; + prop && prop->name; prop++) { + driver_prop_completion_it(prop, sep + 1); + } + } + break; + } + + object_class_foreach(class_completion_it, TYPE_DEVICE, 0, + (void *) str); + } + break; default: break; } + g_free(pkey); } cleanup: -- 1.7.4.4 --------------------------------------------------------------------- Intel Technology Poland sp. z o.o. z siedziba w Gdansku ul. Slowackiego 173 80-298 Gdansk Sad Rejonowy Gdansk Polnoc w Gdansku, VII Wydzial Gospodarczy Krajowego Rejestru Sadowego, numer KRS 101882 NIP 957-07-52-316 Kapital zakladowy 200.000 zl This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.