[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v7 06/39] block: Add blk_is_available()
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH v7 06/39] block: Add blk_is_available() |
Date: |
Mon, 19 Oct 2015 17:53:12 +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>
Reviewed-by: Alberto Garcia <address@hidden>
Reviewed-by: Kevin Wolf <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 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)
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
index 8f2bf10..1e19d1b 100644
--- a/include/sysemu/block-backend.h
+++ b/include/sysemu/block-backend.h
@@ -131,6 +131,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.6.1
- [Qemu-devel] [PATCH v7 00/39] blockdev: BlockBackend and media, Max Reitz, 2015/10/19
- [Qemu-devel] [PATCH v7 02/39] block: Set BDRV_O_INCOMING in bdrv_fill_options(), Max Reitz, 2015/10/19
- [Qemu-devel] [PATCH v7 01/39] block: Remove host floppy support, Max Reitz, 2015/10/19
- [Qemu-devel] [PATCH v7 03/39] blockdev: Allow creation of BDS trees without BB, Max Reitz, 2015/10/19
- [Qemu-devel] [PATCH v7 04/39] iotests: Only create BB if necessary, Max Reitz, 2015/10/19
- [Qemu-devel] [PATCH v7 05/39] block: Make bdrv_is_inserted() return a bool, Max Reitz, 2015/10/19
- [Qemu-devel] [PATCH v7 07/39] block: Make bdrv_is_inserted() recursive, Max Reitz, 2015/10/19
- [Qemu-devel] [PATCH v7 06/39] block: Add blk_is_available(),
Max Reitz <=
- [Qemu-devel] [PATCH v7 09/39] block: Invoke change media CB before NULLing drv, Max Reitz, 2015/10/19
- [Qemu-devel] [PATCH v7 08/39] block/raw_bsd: Drop raw_is_inserted(), Max Reitz, 2015/10/19
- [Qemu-devel] [PATCH v7 10/39] hw/block/fdc: Implement tray status, Max Reitz, 2015/10/19
- [Qemu-devel] [PATCH v7 11/39] hw/usb-storage: Check whether BB is inserted, Max Reitz, 2015/10/19
- [Qemu-devel] [PATCH v7 12/39] block: Fix BB AIOCB AioContext without BDS, Max Reitz, 2015/10/19
- [Qemu-devel] [PATCH v7 14/39] block: Remove wr_highest_sector from BlockAcctStats, Max Reitz, 2015/10/19
- [Qemu-devel] [PATCH v7 13/39] block: Move guest_block_size into BlockBackend, Max Reitz, 2015/10/19
- [Qemu-devel] [PATCH v7 15/39] block: Move BlockAcctStats into BlockBackend, Max Reitz, 2015/10/19
- [Qemu-devel] [PATCH v7 17/39] block/throttle-groups: Make incref/decref public, Max Reitz, 2015/10/19
- [Qemu-devel] [PATCH v7 18/39] block: Add BlockBackendRootState, Max Reitz, 2015/10/19