[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 05/38] block: Add blk_is_available()
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH v3 05/38] block: Add blk_is_available() |
Date: |
Wed, 3 Jun 2015 21:43:46 +0200 |
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 <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
block/block-backend.c | 7 ++++++-
include/sysemu/block-backend.h | 1 +
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/block/block-backend.c b/block/block-backend.c
index 29baab2..d034c78 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -749,7 +749,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)
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
index 189e72b..525b323 100644
--- a/include/sysemu/block-backend.h
+++ b/include/sysemu/block-backend.h
@@ -130,6 +130,7 @@ int blk_enable_write_cache(BlockBackend *blk);
void blk_set_enable_write_cache(BlockBackend *blk, bool wce);
void blk_invalidate_cache(BlockBackend *blk, Error **errp);
bool blk_is_inserted(BlockBackend *blk);
+bool blk_is_available(BlockBackend *blk);
void blk_lock_medium(BlockBackend *blk, bool locked);
void blk_eject(BlockBackend *blk, bool eject_flag);
int blk_get_flags(BlockBackend *blk);
--
2.4.1
- [Qemu-devel] [PATCH v3 00/38] blockdev: BlockBackend and media, Max Reitz, 2015/06/03
- [Qemu-devel] [PATCH v3 01/38] block: Remove host floppy support, Max Reitz, 2015/06/03
- [Qemu-devel] [PATCH v3 02/38] blockdev: Allow creation of BDS trees without BB, Max Reitz, 2015/06/03
- [Qemu-devel] [PATCH v3 03/38] iotests: Only create BB if necessary, Max Reitz, 2015/06/03
- [Qemu-devel] [PATCH v3 05/38] block: Add blk_is_available(),
Max Reitz <=
- [Qemu-devel] [PATCH v3 04/38] block: Make bdrv_is_inserted() return a bool, Max Reitz, 2015/06/03
- [Qemu-devel] [PATCH v3 06/38] block: Make bdrv_is_inserted() recursive, Max Reitz, 2015/06/03
- [Qemu-devel] [PATCH v3 08/38] block: Invoke change media CB before NULLing drv, Max Reitz, 2015/06/03
- [Qemu-devel] [PATCH v3 07/38] block/quorum: Implement bdrv_is_inserted(), Max Reitz, 2015/06/03