block: New change_media_cb() parameter load
To let device models distinguish between eject and load.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
diff --git a/block.c b/block.c
index b006e58..e3fe97f 100644
--- a/block.c
+++ b/block.c
@@ -44,7 +44,7 @@
#include <windows.h>
#endif
-static void bdrv_dev_change_media_cb(BlockDriverState *bs);
+static void bdrv_dev_change_media_cb(BlockDriverState *bs, bool load);
static BlockDriverAIOCB *bdrv_aio_readv_em(BlockDriverState *bs,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque);
@@ -688,7 +688,7 @@
}
if (!bdrv_key_required(bs)) {
- bdrv_dev_change_media_cb(bs);
+ bdrv_dev_change_media_cb(bs, true);
}
return 0;
@@ -724,7 +724,7 @@
bdrv_close(bs->file);
}
- bdrv_dev_change_media_cb(bs);
+ bdrv_dev_change_media_cb(bs, false);
}
}
@@ -807,10 +807,10 @@
}
}
-static void bdrv_dev_change_media_cb(BlockDriverState *bs)
+static void bdrv_dev_change_media_cb(BlockDriverState *bs, bool load)
{
if (bs->dev_ops && bs->dev_ops->change_media_cb) {
- bs->dev_ops->change_media_cb(bs->dev_opaque);
+ bs->dev_ops->change_media_cb(bs->dev_opaque, load);
}
}
@@ -1674,7 +1674,7 @@
} else if (!bs->valid_key) {
bs->valid_key = 1;
/* call the change callback now, we skipped it on open */
- bdrv_dev_change_media_cb(bs);
+ bdrv_dev_change_media_cb(bs, true);
}
return ret;
}