summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2015-10-19 17:53:12 +0200
committerKevin Wolf <kwolf@redhat.com>2015-10-23 18:18:22 +0200
commitdb0284f86a31ec66d138f0f7794321c306af969e (patch)
tree41bef170c6daa645b59b37f77334e77f9479ccdb /block
parente031f750483377a5e5de4c92af68dfa68e4d0aae (diff)
downloadhqemu-db0284f86a31ec66d138f0f7794321c306af969e.zip
hqemu-db0284f86a31ec66d138f0f7794321c306af969e.tar.gz
block: Add blk_is_available()
blk_is_available() returns true iff the BDS is inserted (which means blk_bs() is not NULL and bdrv_is_inserted() returns true) and if the tray of the guest device is closed. blk_is_inserted() is changed to return true only if blk_bs() is not NULL. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/block-backend.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/block/block-backend.c b/block/block-backend.c
index 1db002c..74642dc 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -771,7 +771,12 @@ void blk_invalidate_cache(BlockBackend *blk, Error **errp)
bool blk_is_inserted(BlockBackend *blk)
{
- return bdrv_is_inserted(blk->bs);
+ return blk->bs && bdrv_is_inserted(blk->bs);
+}
+
+bool blk_is_available(BlockBackend *blk)
+{
+ return blk_is_inserted(blk) && !blk_dev_is_tray_open(blk);
}
void blk_lock_medium(BlockBackend *blk, bool locked)
OpenPOWER on IntegriCloud