aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2011-09-06 18:58:41 +0200
committerKevin Wolf <kwolf@redhat.com>2011-09-12 15:17:20 +0200
commita1aff5bf6786e6e8478373e4ada869a4ef2a7fc4 (patch)
tree8a959a57d9cb3e12229423d1d8f35906a6456dbb /block.c
parentece0d5e9a736df174509751980ca0613a778f8b4 (diff)
block: Revert entanglement of bdrv_is_inserted() with tray status
Commit 4be9762a changed bdrv_is_inserted() to fail when the tray is open. Unfortunately, there are two different kinds of users, with conflicting needs. 1. Device models using bdrv_eject(), currently ide-cd and scsi-cd. They expect bdrv_is_inserted() to reflect the tray status. Commit 4be9762a makes them happy. 2. Code that wants to know whether a BlockDriverState has media, such as find_image_format(), bdrv_flush_all(). Commit 4be9762a makes them unhappy. In particular, it breaks flush on VM stop for media ejected by the guest. Revert the change to bdrv_is_inserted(). Check the tray status in the device models instead. Note on IDE: Since only ATAPI devices have a tray, and they don't accept ATA commands since the recent commit "ide: Reject ATA commands specific to drive kinds", checking in atapi.c suffices. 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.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/block.c b/block.c
index a8c789a079..6fe8addcb7 100644
--- a/block.c
+++ b/block.c
@@ -3026,13 +3026,12 @@ static int coroutine_fn bdrv_co_flush_em(BlockDriverState *bs)
int bdrv_is_inserted(BlockDriverState *bs)
{
BlockDriver *drv = bs->drv;
- int ret;
+
if (!drv)
return 0;
if (!drv->bdrv_is_inserted)
- return !bs->tray_open;
- ret = drv->bdrv_is_inserted(bs);
- return ret;
+ return 1;
+ return drv->bdrv_is_inserted(bs);
}
/**