block: Avoid bs->blk in bdrv_next()

We need to introduce a separate BdrvNextIterator struct that can keep
more state than just the current BDS in order to avoid using the bs->blk
pointer.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
Kevin Wolf 2016-03-22 18:58:50 +01:00
parent dde33812a8
commit 7c8eece45b
10 changed files with 103 additions and 76 deletions

View file

@ -3427,11 +3427,13 @@ void host_net_remove_completion(ReadLineState *rs, int nb_args, const char *str)
static void vm_completion(ReadLineState *rs, const char *str)
{
size_t len;
BlockDriverState *bs = NULL;
BlockDriverState *bs;
BdrvNextIterator *it = NULL;
len = strlen(str);
readline_set_completion_index(rs, len);
while ((bs = bdrv_next(bs))) {
while ((it = bdrv_next(it, &bs))) {
SnapshotInfoList *snapshots, *snapshot;
AioContext *ctx = bdrv_get_aio_context(bs);
bool ok = false;