Message ID | 1423501897-30410-9-git-send-email-mreitz@redhat.com |
---|---|
State | New |
Headers | show |
On 02/09/2015 10:11 AM, Max Reitz wrote: > 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 <mreitz@redhat.com> > --- > block.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) Reviewed-by: Eric Blake <eblake@redhat.com> > > diff --git a/block.c b/block.c > index ee7dfba..dafa4b7 100644 > --- a/block.c > +++ b/block.c > @@ -5237,10 +5237,9 @@ bool bdrv_is_inserted(BlockDriverState *bs) > if (!drv) { > return false; > } > - if (!drv->bdrv_is_inserted) { > - return true; > - } > - return drv->bdrv_is_inserted(bs); > + return (!drv->bdrv_is_inserted || drv->bdrv_is_inserted(bs)) && > + (!bs->file || bdrv_is_inserted(bs->file)) && > + (!bs->backing_hd || bdrv_is_inserted(bs->backing_hd)); > } > > /** >
diff --git a/block.c b/block.c index ee7dfba..dafa4b7 100644 --- a/block.c +++ b/block.c @@ -5237,10 +5237,9 @@ bool bdrv_is_inserted(BlockDriverState *bs) if (!drv) { return false; } - if (!drv->bdrv_is_inserted) { - return true; - } - return drv->bdrv_is_inserted(bs); + return (!drv->bdrv_is_inserted || drv->bdrv_is_inserted(bs)) && + (!bs->file || bdrv_is_inserted(bs->file)) && + (!bs->backing_hd || bdrv_is_inserted(bs->backing_hd)); } /**
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 <mreitz@redhat.com> --- block.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)