Skip to content

Commit

Permalink
block: Improve bdrv_iterate (Jan Kiszka)
Browse files Browse the repository at this point in the history
Make bdrv_iterate more useful by passing the BlockDriverState to the
iterator instead of the device name.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6703 c046a42c-6fe2-441c-8c8c-71466251a162
  • Loading branch information
aliguori committed Mar 5, 2009
1 parent 51d7c00 commit 51de976
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions block.c
Expand Up @@ -1011,12 +1011,12 @@ BlockDriverState *bdrv_find(const char *name)
return NULL;
}

void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque)
void bdrv_iterate(void (*it)(void *opaque, BlockDriverState *bs), void *opaque)
{
BlockDriverState *bs;

for (bs = bdrv_first; bs != NULL; bs = bs->next) {
it(opaque, bs->device_name);
it(opaque, bs);
}
}

Expand Down
3 changes: 2 additions & 1 deletion block.h
Expand Up @@ -141,7 +141,8 @@ void bdrv_set_change_cb(BlockDriverState *bs,
void (*change_cb)(void *opaque), void *opaque);
void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size);
BlockDriverState *bdrv_find(const char *name);
void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque);
void bdrv_iterate(void (*it)(void *opaque, BlockDriverState *bs),
void *opaque);
int bdrv_is_encrypted(BlockDriverState *bs);
int bdrv_set_key(BlockDriverState *bs, const char *key);
void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
Expand Down
3 changes: 2 additions & 1 deletion monitor.c
Expand Up @@ -2679,8 +2679,9 @@ static void file_completion(const char *input)
closedir(ffs);
}

static void block_completion_it(void *opaque, const char *name)
static void block_completion_it(void *opaque, BlockDriverState *bs)
{
const char *name = bdrv_get_device_name(bs);
const char *input = opaque;

if (input[0] == '\0' ||
Expand Down

0 comments on commit 51de976

Please sign in to comment.