提交 e1a8a091 编写于 作者: M Max Reitz 提交者: Michael Roth

block: Add blk_dev_has_tray()

Pull out the check whether a block device has a tray from
blk_dev_is_tray_open() into its own function so both attributes (whether
there is a tray vs. whether that tray is open) can be queried
independently.

Cc: qemu-stable <qemu-stable@nongnu.org>
Signed-off-by: NMax Reitz <mreitz@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Reviewed-by: NAlberto Garcia <berto@igalia.com>
Message-id: 1454096953-31773-2-git-send-email-mreitz@redhat.com
(cherry picked from commit 8f3a73bc)
Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
上级 7a2c1c8e
...@@ -457,6 +457,14 @@ bool blk_dev_has_removable_media(BlockBackend *blk) ...@@ -457,6 +457,14 @@ bool blk_dev_has_removable_media(BlockBackend *blk)
return !blk->dev || (blk->dev_ops && blk->dev_ops->change_media_cb); return !blk->dev || (blk->dev_ops && blk->dev_ops->change_media_cb);
} }
/*
* Does @blk's attached device model have a tray?
*/
bool blk_dev_has_tray(BlockBackend *blk)
{
return blk->dev_ops && blk->dev_ops->is_tray_open;
}
/* /*
* Notify @blk's attached device model of a media eject request. * Notify @blk's attached device model of a media eject request.
* If @force is true, the medium is about to be yanked out forcefully. * If @force is true, the medium is about to be yanked out forcefully.
...@@ -473,7 +481,7 @@ void blk_dev_eject_request(BlockBackend *blk, bool force) ...@@ -473,7 +481,7 @@ void blk_dev_eject_request(BlockBackend *blk, bool force)
*/ */
bool blk_dev_is_tray_open(BlockBackend *blk) bool blk_dev_is_tray_open(BlockBackend *blk)
{ {
if (blk->dev_ops && blk->dev_ops->is_tray_open) { if (blk_dev_has_tray(blk)) {
return blk->dev_ops->is_tray_open(blk->dev_opaque); return blk->dev_ops->is_tray_open(blk->dev_opaque);
} }
return false; return false;
......
...@@ -686,6 +686,7 @@ void blk_set_bs(BlockBackend *blk, BlockDriverState *bs); ...@@ -686,6 +686,7 @@ void blk_set_bs(BlockBackend *blk, BlockDriverState *bs);
void blk_dev_change_media_cb(BlockBackend *blk, bool load); void blk_dev_change_media_cb(BlockBackend *blk, bool load);
bool blk_dev_has_removable_media(BlockBackend *blk); bool blk_dev_has_removable_media(BlockBackend *blk);
bool blk_dev_has_tray(BlockBackend *blk);
void blk_dev_eject_request(BlockBackend *blk, bool force); void blk_dev_eject_request(BlockBackend *blk, bool force);
bool blk_dev_is_tray_open(BlockBackend *blk); bool blk_dev_is_tray_open(BlockBackend *blk);
bool blk_dev_is_medium_locked(BlockBackend *blk); bool blk_dev_is_medium_locked(BlockBackend *blk);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册