[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 01/50] block: Add blk_dev_has_tray()
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PULL v2 01/50] block: Add blk_dev_has_tray() |
Date: |
Tue, 2 Feb 2016 18:34:54 +0100 |
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 <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Alberto Garcia <address@hidden>
Message-id: address@hidden
---
block/block-backend.c | 10 +++++++++-
include/block/block_int.h | 1 +
2 files changed, 10 insertions(+), 1 deletion(-)
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;
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 428fa33..ec31df1 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -695,6 +695,7 @@ void blk_set_bs(BlockBackend *blk, BlockDriverState *bs);
void blk_dev_change_media_cb(BlockBackend *blk, bool load);
bool blk_dev_has_removable_media(BlockBackend *blk);
+bool blk_dev_has_tray(BlockBackend *blk);
void blk_dev_eject_request(BlockBackend *blk, bool force);
bool blk_dev_is_tray_open(BlockBackend *blk);
bool blk_dev_is_medium_locked(BlockBackend *blk);
--
2.7.0
- [Qemu-devel] [PULL v2 00/50] Block patches, Max Reitz, 2016/02/02
- [Qemu-devel] [PULL v2 02/50] blockdev: Fix 'change' for slot devices, Max Reitz, 2016/02/02
- [Qemu-devel] [PULL v2 01/50] block: Add blk_dev_has_tray(),
Max Reitz <=
- [Qemu-devel] [PULL v2 04/50] block/qapi: Emit tray_open only if there is a tray, Max Reitz, 2016/02/02
- [Qemu-devel] [PULL v2 07/50] nbd: client_close on error in nbd_co_client_start, Max Reitz, 2016/02/02
- [Qemu-devel] [PULL v2 06/50] iotests: Limit supported formats for 118, Max Reitz, 2016/02/02
- [Qemu-devel] [PULL v2 03/50] Revert "hw/block/fdc: Implement tray status", Max Reitz, 2016/02/02
- [Qemu-devel] [PULL v2 05/50] vmdk: Fix converting to streamOptimized, Max Reitz, 2016/02/02
- [Qemu-devel] [PULL v2 09/50] iotests: Change coding style of _filter_nbd in 083, Max Reitz, 2016/02/02
- [Qemu-devel] [PULL v2 08/50] iotests: Rename filter_nbd to _filter_nbd in 083, Max Reitz, 2016/02/02
- [Qemu-devel] [PULL v2 10/50] iotests: Move _filter_nbd into common.filter, Max Reitz, 2016/02/02
- [Qemu-devel] [PULL v2 11/50] iotests: Make _filter_nbd drop log lines, Max Reitz, 2016/02/02
- [Qemu-devel] [PULL v2 12/50] iotests: Make _filter_nbd support more URL types, Max Reitz, 2016/02/02