diff options
author | Markus Armbruster <armbru@redhat.com> | 2011-08-03 15:07:42 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2011-09-06 11:23:51 +0200 |
commit | 145feb176ffe6de1db6d05af064c841d7c16633c (patch) | |
tree | f69598e83c5a2b36fcecd043e7a234dcbeb77a2e /block.c | |
parent | 0e49de5232f47c9e58adb82c28d4f42be933d891 (diff) |
block: Split change_cb() into change_media_cb(), resize_cb()
Multiplexing callbacks complicates matters needlessly.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 23 |
1 files changed, 15 insertions, 8 deletions
@@ -44,7 +44,7 @@ #include <windows.h> #endif -static void bdrv_dev_change_cb(BlockDriverState *bs, int reason); +static void bdrv_dev_change_media_cb(BlockDriverState *bs); static BlockDriverAIOCB *bdrv_aio_readv_em(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque); @@ -690,7 +690,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int flags, if (!bdrv_key_required(bs)) { bs->media_changed = 1; - bdrv_dev_change_cb(bs, CHANGE_MEDIA); + bdrv_dev_change_media_cb(bs); } return 0; @@ -727,7 +727,7 @@ void bdrv_close(BlockDriverState *bs) } bs->media_changed = 1; - bdrv_dev_change_cb(bs, CHANGE_MEDIA); + bdrv_dev_change_media_cb(bs); } } @@ -806,10 +806,17 @@ void bdrv_set_dev_ops(BlockDriverState *bs, const BlockDevOps *ops, bs->dev_opaque = opaque; } -static void bdrv_dev_change_cb(BlockDriverState *bs, int reason) +static void bdrv_dev_change_media_cb(BlockDriverState *bs) { - if (bs->dev_ops && bs->dev_ops->change_cb) { - bs->dev_ops->change_cb(bs->dev_opaque, reason); + if (bs->dev_ops && bs->dev_ops->change_media_cb) { + bs->dev_ops->change_media_cb(bs->dev_opaque); + } +} + +static void bdrv_dev_resize_cb(BlockDriverState *bs) +{ + if (bs->dev_ops && bs->dev_ops->resize_cb) { + bs->dev_ops->resize_cb(bs->dev_opaque); } } @@ -1283,7 +1290,7 @@ 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); - bdrv_dev_change_cb(bs, CHANGE_SIZE); + bdrv_dev_resize_cb(bs); } return ret; } @@ -1659,7 +1666,7 @@ int bdrv_set_key(BlockDriverState *bs, const char *key) bs->valid_key = 1; /* call the change callback now, we skipped it on open */ bs->media_changed = 1; - bdrv_dev_change_cb(bs, CHANGE_MEDIA); + bdrv_dev_change_media_cb(bs); } return ret; } |