[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC V2 05/10] quorum: Add quorum_getlength().
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [RFC V2 05/10] quorum: Add quorum_getlength(). |
Date: |
Thu, 9 Aug 2012 10:14:30 +0100 |
On Thu, Aug 9, 2012 at 10:07 AM, Benoît Canet <address@hidden> 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
[Qemu-devel] [RFC V2 09/10] quorum: Add quorum_aio_readv., Benoît Canet, 2012/08/07
[Qemu-devel] [RFC V2 07/10] blkverify: Make blkverify_iovec_clone() and blkverify_iovec_compare() public, Benoît Canet, 2012/08/07