Commit 51de97605b183fe5a84f96f411cfc99ba6bbb6b1

Authored by aliguori
1 parent 51d7c00c

block: Improve bdrv_iterate (Jan Kiszka)

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
@@ -1011,12 +1011,12 @@ BlockDriverState *bdrv_find(const char *name) @@ -1011,12 +1011,12 @@ BlockDriverState *bdrv_find(const char *name)
1011 return NULL; 1011 return NULL;
1012 } 1012 }
1013 1013
1014 -void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque) 1014 +void bdrv_iterate(void (*it)(void *opaque, BlockDriverState *bs), void *opaque)
1015 { 1015 {
1016 BlockDriverState *bs; 1016 BlockDriverState *bs;
1017 1017
1018 for (bs = bdrv_first; bs != NULL; bs = bs->next) { 1018 for (bs = bdrv_first; bs != NULL; bs = bs->next) {
1019 - it(opaque, bs->device_name); 1019 + it(opaque, bs);
1020 } 1020 }
1021 } 1021 }
1022 1022
@@ -141,7 +141,8 @@ void bdrv_set_change_cb(BlockDriverState *bs, @@ -141,7 +141,8 @@ void bdrv_set_change_cb(BlockDriverState *bs,
141 void (*change_cb)(void *opaque), void *opaque); 141 void (*change_cb)(void *opaque), void *opaque);
142 void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size); 142 void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size);
143 BlockDriverState *bdrv_find(const char *name); 143 BlockDriverState *bdrv_find(const char *name);
144 -void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque); 144 +void bdrv_iterate(void (*it)(void *opaque, BlockDriverState *bs),
  145 + void *opaque);
145 int bdrv_is_encrypted(BlockDriverState *bs); 146 int bdrv_is_encrypted(BlockDriverState *bs);
146 int bdrv_set_key(BlockDriverState *bs, const char *key); 147 int bdrv_set_key(BlockDriverState *bs, const char *key);
147 void bdrv_iterate_format(void (*it)(void *opaque, const char *name), 148 void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
monitor.c
@@ -2679,8 +2679,9 @@ static void file_completion(const char *input) @@ -2679,8 +2679,9 @@ static void file_completion(const char *input)
2679 closedir(ffs); 2679 closedir(ffs);
2680 } 2680 }
2681 2681
2682 -static void block_completion_it(void *opaque, const char *name) 2682 +static void block_completion_it(void *opaque, BlockDriverState *bs)
2683 { 2683 {
  2684 + const char *name = bdrv_get_device_name(bs);
2684 const char *input = opaque; 2685 const char *input = opaque;
2685 2686
2686 if (input[0] == '\0' || 2687 if (input[0] == '\0' ||