summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2016-01-29 20:49:10 +0100
committerTimothy Pearson <tpearson@raptorengineering.com>2019-11-29 19:30:22 -0600
commit4d84cc18547327d0e3f4fe46ea6f909ff2d12337 (patch)
treedb3499a05a4d673734a06bedcf5c013f4c3a2b6f /block
parent83e47683cf9bc565474d8b1d554c5aff8812c62a (diff)
downloadhqemu-4d84cc18547327d0e3f4fe46ea6f909ff2d12337.zip
hqemu-4d84cc18547327d0e3f4fe46ea6f909ff2d12337.tar.gz
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: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Message-id: 1454096953-31773-2-git-send-email-mreitz@redhat.com
Diffstat (limited to 'block')
-rw-r--r--block/block-backend.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/block/block-backend.c b/block/block-backend.c
index efd6146..a4208f1 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -459,6 +459,14 @@ bool blk_dev_has_removable_media(BlockBackend *blk)
}
/*
+ * 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.
* If @force is true, the medium is about to be yanked out forcefully.
*/
@@ -474,7 +482,7 @@ void blk_dev_eject_request(BlockBackend *blk, bool force)
*/
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 false;
OpenPOWER on IntegriCloud