aboutsummaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2014-10-07 13:59:10 +0200
committerKevin Wolf <kwolf@redhat.com>2014-10-20 13:41:26 +0200
commitfea68bb6e9fa65c7cc6caa6adda810d1d0fdbde4 (patch)
treea7e6e95a740ae028023b921b7048b9fd3bfa4297 /monitor.c
parentb9fe8a7a12f18adebba5616a3e9f44143a78c07e (diff)
block: Eliminate bdrv_iterate(), use bdrv_next()
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: BenoƮt Canet <benoit.canet@nodalink.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c32
1 files changed, 9 insertions, 23 deletions
diff --git a/monitor.c b/monitor.c
index 2d14f394d6..412e63fdd9 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4216,24 +4216,6 @@ static void file_completion(Monitor *mon, const char *input)
closedir(ffs);
}
-typedef struct MonitorBlockComplete {
- Monitor *mon;
- const char *input;
-} MonitorBlockComplete;
-
-static void block_completion_it(void *opaque, BlockDriverState *bs)
-{
- const char *name = bdrv_get_device_name(bs);
- MonitorBlockComplete *mbc = opaque;
- Monitor *mon = mbc->mon;
- const char *input = mbc->input;
-
- if (input[0] == '\0' ||
- !strncmp(name, (char *)input, strlen(input))) {
- readline_add_completion(mon->rs, name);
- }
-}
-
static const char *next_arg_type(const char *typestr)
{
const char *p = strchr(typestr, ':');
@@ -4671,9 +4653,9 @@ static void monitor_find_completion_by_table(Monitor *mon,
{
const char *cmdname;
int i;
- const char *ptype, *str;
+ const char *ptype, *str, *name;
const mon_cmd_t *cmd;
- MonitorBlockComplete mbs;
+ BlockDriverState *bs;
if (nb_args <= 1) {
/* command completion */
@@ -4725,10 +4707,14 @@ static void monitor_find_completion_by_table(Monitor *mon,
break;
case 'B':
/* block device name completion */
- mbs.mon = mon;
- mbs.input = str;
readline_set_completion_index(mon->rs, strlen(str));
- bdrv_iterate(block_completion_it, &mbs);
+ for (bs = bdrv_next(NULL); bs; bs = bdrv_next(bs)) {
+ name = bdrv_get_device_name(bs);
+ if (str[0] == '\0' ||
+ !strncmp(name, str, strlen(str))) {
+ readline_add_completion(mon->rs, name);
+ }
+ }
break;
case 's':
case 'S':