Commit 28d7a789 authored by Max Reitz's avatar Max Reitz Committed by Kevin Wolf
Browse files

block: Make bdrv_is_inserted() recursive



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: default avatarMax Reitz <mreitz@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
parent db0284f8
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -3143,15 +3143,21 @@ 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);
    }
    QLIST_FOREACH(child, &bs->children, next) {
        if (!bdrv_is_inserted(child->bs)) {
            return false;
        }
    }
    return true;
}

/**
 * Return whether the media changed since the last call to this