[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 30/35] block: New change_media_cb() parameter load
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 30/35] block: New change_media_cb() parameter load |
Date: |
Mon, 12 Sep 2011 16:19:29 +0200 |
From: Markus Armbruster <address@hidden>
To let device models distinguish between eject and load.
Signed-off-by: Markus Armbruster <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 12 ++++++------
block.h | 3 ++-
hw/fdc.c | 2 +-
hw/ide/core.c | 2 +-
hw/scsi-disk.c | 2 +-
hw/sd.c | 2 +-
6 files changed, 12 insertions(+), 11 deletions(-)
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 @@ int bdrv_open(BlockDriverState *bs, const char *filename,
int flags,
}
if (!bdrv_key_required(bs)) {
- bdrv_dev_change_media_cb(bs);
+ bdrv_dev_change_media_cb(bs, true);
}
return 0;
@@ -724,7 +724,7 @@ void bdrv_close(BlockDriverState *bs)
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) {
- 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) {
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;
}
diff --git a/block.h b/block.h
index 4b7fa35..16bfa0a 100644
--- a/block.h
+++ b/block.h
@@ -32,11 +32,12 @@ typedef struct QEMUSnapshotInfo {
typedef struct BlockDevOps {
/*
* 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
* changes. Sure would be useful if it did.
* 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?
* Device models implement this only when the device has a tray.
diff --git a/hw/fdc.c b/hw/fdc.c
index 57eda0c..433af73 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -1777,7 +1777,7 @@ static void fdctrl_result_timer(void *opaque)
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;
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 3771acb..5def25c 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -784,7 +784,7 @@ static void ide_cfata_metadata_write(IDEState *s)
}
/* 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;
uint64_t nb_sectors;
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index b115760..f5f1d82 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1173,7 +1173,7 @@ static void scsi_destroy(SCSIDevice *dev)
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)
{
}
diff --git a/hw/sd.c b/hw/sd.c
index 1af62b2..10e26ad 100644
--- a/hw/sd.c
+++ b/hw/sd.c
@@ -419,7 +419,7 @@ static void sd_reset(SDState *sd, BlockDriverState *bdrv)
sd->pwd_len = 0;
}
-static void sd_cardchange(void *opaque)
+static void sd_cardchange(void *opaque, bool load)
{
SDState *sd = opaque;
--
1.7.6
- [Qemu-devel] [PATCH 22/35] block: Clean up remaining users of "removable", (continued)
- [Qemu-devel] [PATCH 22/35] block: Clean up remaining users of "removable", Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 20/35] scsi-disk: Fix START_STOP to fail when it can't eject, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 28/35] block: Reset buffer alignment on detach, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 24/35] block: Show whether the virtual tray is open in info block, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 31/35] ide/atapi scsi-disk: Make monitor eject -f, then change work, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 35/35] qcow2: fix range check, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 34/35] qcow2: align cluster_data to block to improve performance using O_DIRECT, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 19/35] ide/atapi: Don't fail eject when tray is already open, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 25/35] block: Move BlockConf & friends from block_int.h to block.h, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 26/35] hw: Trim superfluous #include "block_int.h", Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 30/35] block: New change_media_cb() parameter load,
Kevin Wolf <=
- [Qemu-devel] [PATCH 32/35] qcow2: initialize metadata before inserting in cluster_allocs, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 23/35] block: Drop BlockDriverState member removable, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 33/35] ahci: Remove unused struct member, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 17/35] rbd: clean up, fix style, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 18/35] rbd: fix leak in qemu_rbd_open failure paths, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 29/35] nbd: Clean up use of block_int.h, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 27/35] block: New bdrv_set_buffer_alignment(), Kevin Wolf, 2011/09/12
- Re: [Qemu-devel] [PULL 00/35] Block patches, Anthony Liguori, 2011/09/15