[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 07/37] block: Make bdrv_is_inserted() recursive
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 07/37] block: Make bdrv_is_inserted() recursive |
Date: |
Fri, 23 Oct 2015 19:00:54 +0200 |
From: Max Reitz <address@hidden>
If bdrv_is_inserted() is called on the top level BDS, it should make
sure all nodes in the BDS tree are actually inserted.
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/block.c b/block.c
index bdd3338..bb8c067 100644
--- a/block.c
+++ b/block.c
@@ -3143,14 +3143,20 @@ void bdrv_invalidate_cache_all(Error **errp)
bool bdrv_is_inserted(BlockDriverState *bs)
{
BlockDriver *drv = bs->drv;
+ BdrvChild *child;
if (!drv) {
return false;
}
- if (!drv->bdrv_is_inserted) {
- return true;
+ if (drv->bdrv_is_inserted) {
+ return drv->bdrv_is_inserted(bs);
}
- return drv->bdrv_is_inserted(bs);
+ QLIST_FOREACH(child, &bs->children, next) {
+ if (!bdrv_is_inserted(child->bs)) {
+ return false;
+ }
+ }
+ return true;
}
/**
--
1.8.3.1
- [Qemu-block] [PULL 00/37] Block layer patches, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 01/37] block: Remove host floppy support, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 03/37] blockdev: Allow creation of BDS trees without BB, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 02/37] block: Set BDRV_O_INCOMING in bdrv_fill_options(), Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 05/37] block: Make bdrv_is_inserted() return a bool, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 06/37] block: Add blk_is_available(), Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 04/37] iotests: Only create BB if necessary, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 08/37] block/raw_bsd: Drop raw_is_inserted(), Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 07/37] block: Make bdrv_is_inserted() recursive,
Kevin Wolf <=
- [Qemu-block] [PULL 09/37] block: Invoke change media CB before NULLing drv, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 11/37] hw/usb-storage: Check whether BB is inserted, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 10/37] hw/block/fdc: Implement tray status, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 12/37] block: Fix BB AIOCB AioContext without BDS, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 13/37] block: Move guest_block_size into BlockBackend, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 18/37] block: Add BlockBackendRootState, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 14/37] block: Remove wr_highest_sector from BlockAcctStats, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 17/37] block/throttle-groups: Make incref/decref public, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 15/37] block: Move BlockAcctStats into BlockBackend, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 21/37] block: Prepare remaining BB functions for NULL BDS, Kevin Wolf, 2015/10/23