sim-card
/
qemu
Archived
10
0
Fork 0

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>
This commit is contained in:
Markus Armbruster 2011-09-06 18:58:59 +02:00 committed by Kevin Wolf
parent ab359cd17e
commit 7d4b4ba5c2
6 changed files with 12 additions and 11 deletions

12
block.c
View File

@ -44,7 +44,7 @@
#include <windows.h> #include <windows.h>
#endif #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, static BlockDriverAIOCB *bdrv_aio_readv_em(BlockDriverState *bs,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque); BlockDriverCompletionFunc *cb, void *opaque);
@ -688,7 +688,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int flags,
} }
if (!bdrv_key_required(bs)) { if (!bdrv_key_required(bs)) {
bdrv_dev_change_media_cb(bs); bdrv_dev_change_media_cb(bs, true);
} }
return 0; return 0;
@ -724,7 +724,7 @@ void bdrv_close(BlockDriverState *bs)
bdrv_close(bs->file); bdrv_close(bs->file);
} }
bdrv_dev_change_media_cb(bs); bdrv_dev_change_media_cb(bs, false);
} }
} }
@ -807,10 +807,10 @@ void bdrv_set_dev_ops(BlockDriverState *bs, const BlockDevOps *ops,
} }
} }
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) { 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 @@ int bdrv_set_key(BlockDriverState *bs, const char *key)
} else if (!bs->valid_key) { } else if (!bs->valid_key) {
bs->valid_key = 1; bs->valid_key = 1;
/* call the change callback now, we skipped it on open */ /* 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; return ret;
} }

View File

@ -32,11 +32,12 @@ typedef struct QEMUSnapshotInfo {
typedef struct BlockDevOps { typedef struct BlockDevOps {
/* /*
* Runs when virtual media changed (monitor commands eject, change) * Runs when virtual media changed (monitor commands eject, change)
* Argument load is true on load and false on eject.
* Beware: doesn't run when a host device's physical media * Beware: doesn't run when a host device's physical media
* changes. Sure would be useful if it did. * changes. Sure would be useful if it did.
* Device models with removable media must implement this callback. * Device models with removable media must implement this callback.
*/ */
void (*change_media_cb)(void *opaque); void (*change_media_cb)(void *opaque, bool load);
/* /*
* Is the virtual tray open? * Is the virtual tray open?
* Device models implement this only when the device has a tray. * Device models implement this only when the device has a tray.

View File

@ -1777,7 +1777,7 @@ static void fdctrl_result_timer(void *opaque)
fdctrl_stop_transfer(fdctrl, 0x00, 0x00, 0x00); fdctrl_stop_transfer(fdctrl, 0x00, 0x00, 0x00);
} }
static void fdctrl_change_cb(void *opaque) static void fdctrl_change_cb(void *opaque, bool load)
{ {
FDrive *drive = opaque; FDrive *drive = opaque;

View File

@ -784,7 +784,7 @@ static void ide_cfata_metadata_write(IDEState *s)
} }
/* called when the inserted state of the media has changed */ /* called when the inserted state of the media has changed */
static void ide_cd_change_cb(void *opaque) static void ide_cd_change_cb(void *opaque, bool load)
{ {
IDEState *s = opaque; IDEState *s = opaque;
uint64_t nb_sectors; uint64_t nb_sectors;

View File

@ -1173,7 +1173,7 @@ static void scsi_destroy(SCSIDevice *dev)
blockdev_mark_auto_del(s->qdev.conf.bs); blockdev_mark_auto_del(s->qdev.conf.bs);
} }
static void scsi_cd_change_media_cb(void *opaque) static void scsi_cd_change_media_cb(void *opaque, bool load)
{ {
} }

View File

@ -419,7 +419,7 @@ static void sd_reset(SDState *sd, BlockDriverState *bdrv)
sd->pwd_len = 0; sd->pwd_len = 0;
} }
static void sd_cardchange(void *opaque) static void sd_cardchange(void *opaque, bool load)
{ {
SDState *sd = opaque; SDState *sd = opaque;