<div dir="ltr">I just sent the question to the qemu developer mailing list. But as I did, I remembered this sd_truncate is also called from  sd_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov):<div>


<br></div><div><div>static coroutine_fn int sd_co_writev(BlockDriverState *bs, int64_t sector_num,</div><div>                        int nb_sectors, QEMUIOVector *qiov)</div><div>{</div><div>    SheepdogAIOCB *acb;</div>

<div>
    int ret;</div><div><br></div><div>    if (bs->growable && sector_num + nb_sectors > bs->total_sectors) {</div><div>        ret = sd_truncate(bs, (sector_num + nb_sectors) * BDRV_SECTOR_SIZE);</div><div>


        if (ret < 0) {</div><div>            return ret;</div><div>        }</div><div>        bs->total_sectors = sector_num + nb_sectors;</div><div>    }</div><div><br></div><div>    acb = sd_aio_setup(bs, qiov, sector_num, nb_sectors);</div>


<div>    acb->aio_done_func = sd_write_done;</div><div>    acb->aiocb_type = AIOCB_WRITE_UDATA;</div><div><br></div><div>    ret = sd_co_rw_vector(acb);</div></div><div>...</div><div>}</div><div><br></div><div>This function is mapped to bdrv_co_writev in the qemu driver. </div>


<div>Looking at the test in this function, the only way a shrink could happen - I guess - is if the units in sector_num and nb_sectors are inconsistent (esp since there's a conversion to "BDRV_SECTOR_SIZE") in relation to bs->total_sectors. </div>


<div>I am using qcow2 file format and created the image with qemu-img -t qcow2 create sheepdog:name. Could it be related?</div><div><br></div><div>What do you think? </div><div><br></div><div>Hadrien </div><div class="gmail_extra">


<br><br><div class="gmail_quote">2013/12/12 Liu Yuan <span dir="ltr"><<a href="mailto:namei.unix@gmail.com" target="_blank">namei.unix@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div>On Thu, Dec 12, 2013 at 11:36:06AM +0100, Hadrien KOHL wrote:<br>
> Hi,<br>
><br>
</div><div>> Thanks, that's interesting. I don't have any component I can think of that<br>
> does this though.<br>
> Could it be possible that the kernel/filesystem of the host is doing it on<br>
> it's own?<br>
><br>
<br>
</div>IMO only 'qemu-img resize'(probably libvirt has similar function) and<br>
'dog vdi resize' can resize the volume.<br>
<br>
But any higher component in QEMU might call .bdrv_truncate() too, which is out<br>
of my cscope. I'd suggest you ask the qemu list that anyone else execept<br>
'qemu-img resize' would call .bdrv_truncate() while VM is running.<br>
<br>
Thanks<br>
<span><font color="#888888">Yuan<br>
</font></span></blockquote></div><br></div></div>