On Thu, Aug 9, 2012 at 10:07 AM, Benoît Canet <[email protected]> wrote:
>> > +static int64_t quorum_getlength(BlockDriverState *bs)
>> > +{
>> > +    BDRVQuorumState *s = bs->opaque;
>> > +    int i;
>> > +    int64_t ret;
>> > +
>> > +    /* return the length of the first available quorum file */
>> > +    for (i = 0, ret = bdrv_getlength(s->bs[i]);
>> > +         ret == -ENOMEDIUM && i <= 2;
>> > +         i++, ret = bdrv_getlength(s->bs[i])) {
>> > +    }
>>
>> Why is -ENOMEDIUM an expected error value?
>
> I put the -ENOMEDIUM test because of the following piece of code.
> /**
>  * Length of a file in bytes. Return < 0 if error or unknown.
>  */
> int64_t bdrv_getlength(BlockDriverState *bs)
> {
>     BlockDriver *drv = bs->drv;
>     if (!drv)
>         return -ENOMEDIUM;
>
> Still I am not sure it's needed. What is your stance on this ?

A BlockDriverState has more than just block filter or image format
state, it also has some guest-visible state unfortunately.  The
BlockDriverState attached to the guest's storage controller (e.g. IDE
CD-ROM) can be closed by blockdev.c:eject_device() and left as an
empty BlockDriverState with ->drv == NULL.

I think we don't need to worry about this in a block filter like
quorum because all child BlockDriverStates will not be ejected.

Stefan

Reply via email to