On 07/05/2015 16:07, Kevin Wolf wrote: > This is not right for two reasons: The first is that this is > BlockBackend code
I think it would take effect for the qemu-nbd case though. > and it wouldn't even take effect for the qcow2 case > where we're writing past EOF only on the protocol layer. The second is > that -ENOSPC is only for writes and not for reads. This is right. Reads in the kernel return 0, but in QEMU we do not want that. The code currently returns -EIO, but perhaps -EINVAL is a better match. It also happens to be what Linux returns for discards. Paolo > For the protocol level, bdrv_aligned_preadv() has code to handle reads > past EOF if bs->zero_beyond_eof is set. This is always the case, except > for qcow2, which has the snapshot VM state after EOF, so the driver is > called for that. > > For writes, the driver is always called. The expectiation is that beyond > EOF it resizes the image file if it can, and returns -ENOSPC if it can't. > We could change this to have a check directly in bdrv_aligned_pwrite() > and then drivers would have to advertise whether they can extend a file > beyond EOF or not so we know whether to apply the check or not > (essentially the growable flag that Max wants to add), but I'm not sure > what we would win with that.