[Lguest] [PATCH] lguest.c: truncate problems in handle_block_output

Rusty Russell rusty at rustcorp.com.au
Wed Sep 26 09:53:48 EST 2007


On Tue, 2007-09-25 at 17:13 +0100, Chris Malley wrote:
> Hi
> 
> I have been experiencing consistent problems with an lguest under moderate
> I/O conditions (e.g. when updating the distribution with yum) where the guest
> crashes with "Write past end 2965302784+4294967295", and I end up with a
> zero-length disk image.
> 
> Turns out this is because (a) the offset is *not* 4294967295, but the failure
> code -1 (so in fact it isn't a "Write past end" at all, just a write failure).
> And (b) because my block device is 4G and ftruncate() can't handle it, the 
> file is truncated to zero bytes.

Hi Chris,

	Thanks for the patch!  But I can't figure out why you are getting a
write failure to trigger this.  We open it with O_LARGEFILE: are you
running out of disk space?

The ftruncate vs ftrucate64 bug is nasty.  The block stuff is changing
for 2.6.24, but of course I had the same bug there too...

>  		len = readv(dev->fd, reply, reply_num);
> -		*lenp = len;
> +		if (len < 0) {
> +			err(1, "Read failed with error %u", errno);
> +			*lenp = 0;
> +		} else
> +			*lenp = len;
>  	}

BTW, we don't need the *lenp = 0 after the err() here.

Thanks!
Rusty.




More information about the Lguest mailing list