diff options
author | Christoph Hellwig <hch@lst.de> | 2011-01-24 13:32:41 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2011-01-31 10:03:00 +0100 |
commit | db97ee6a976bacbb0d18818e951cfc41b39269a7 (patch) | |
tree | 14c8b30a7b745f84da878aab6f35220dd701b79f /block.c | |
parent | 6d4a2b3a47959f02e7f307f50396e70e8464f95e (diff) |
block: tell drivers about an image resize
Extend the change_cb callback with a reason argument, and use it
to tell drivers about size changes.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -645,7 +645,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int flags, /* call the change callback */ bs->media_changed = 1; if (bs->change_cb) - bs->change_cb(bs->change_opaque); + bs->change_cb(bs->change_opaque, CHANGE_MEDIA); } return 0; @@ -684,7 +684,7 @@ void bdrv_close(BlockDriverState *bs) /* call the change callback */ bs->media_changed = 1; if (bs->change_cb) - bs->change_cb(bs->change_opaque); + bs->change_cb(bs->change_opaque, CHANGE_MEDIA); } } @@ -1135,6 +1135,9 @@ int bdrv_truncate(BlockDriverState *bs, int64_t offset) ret = drv->bdrv_truncate(bs, offset); if (ret == 0) { ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS); + if (bs->change_cb) { + bs->change_cb(bs->change_opaque, CHANGE_SIZE); + } } return ret; } @@ -1366,7 +1369,8 @@ int bdrv_enable_write_cache(BlockDriverState *bs) /* XXX: no longer used */ void bdrv_set_change_cb(BlockDriverState *bs, - void (*change_cb)(void *opaque), void *opaque) + void (*change_cb)(void *opaque, int reason), + void *opaque) { bs->change_cb = change_cb; bs->change_opaque = opaque; @@ -1411,7 +1415,7 @@ int bdrv_set_key(BlockDriverState *bs, const char *key) /* call the change callback now, we skipped it on open */ bs->media_changed = 1; if (bs->change_cb) - bs->change_cb(bs->change_opaque); + bs->change_cb(bs->change_opaque, CHANGE_MEDIA); } return ret; } |