Skip to contentSkip to conversation

some confusion on qemu i/o pocess and the qcow2 format

Qemu-devel 浩樊啊 2 participants 5 messages Nov 20, 2015 – Dec 22, 2015 1 message not in the archive

lore
Share & tools
lore

浩樊啊

author
#0 lore raw

1.what is the difference of bdrv_co_readv and bdrv_aio_readv?
2.I am confused about the I/O pocess of qcow2, i find. Can anybody tell me the detail pocess? or arethere any useful tools to trace the pocess?

#1 lore raw
Quoted 1 line · 浩樊啊

1.what is the difference of bdrv_co_readv and bdrv_aio_readv?

bdrv_aio_readv() takes a callback function pointer and returns a request struct. The callback will be invoked when the request has completed.

bdrv_co_readv() must be called from coroutine context. It performs the request and then returns. This is similar to traditional preadv(2) except the coroutine will yield back to the QEMU event loop instead of blocking the thread.

Please take a look at include/qemu/coroutine.h if you'd like to learn more about coroutines.

I have also written about coroutines here:
http://blog.vmsplice.net/2014/01/coroutines-in-qemu-basics.html

Quoted 1 line

2.I am confused about the I/O pocess of qcow2, i find. Can anybody tell me the detail pocess? or arethere any useful tools to trace the pocess?

Unless you have more specific questions, the only advice I can give is to read the source code and/or add printfs to help you understand the code execution.

#3 lore raw

Re: [Qemu-devel] 回复: some confusion on qemu i/o pocess and the qcow2format

In reply to a message not in the archive
Quoted 4 lines · 浩樊啊

I read the source code of qcow2.
I can see bdrv_co_do_readv---bdrv_co_do_preadv---bdrv_aligned_preadv---drv->bdrv_co_readv (here drv.bdrv_co_readv=qcow2_co_readv)
but when I read qcow2_co_readv->bdrv_co_readv->bdrv_co_do_readv->bdrv_co_do_preadv I am confused about this. qcow2_co_readv use bdrv_co_do_preadv again?

The qcow2 BlockDriverState uses a file BlockDriverState to do the actual I/O. This way the qcow2 image format can be used on POSIX files, iSCSI LUNs, Gluster files, etc.

It means that qcow2 code does not call preadv(2)/pwritev(2) directly but instead uses another BlockDriverState to perform the actual I/O. In QEMU we keep "image format" block drivers (e.g. qcow2, vmdk, vhdx) separate from "protocol" block drivers (e.g. POSIX, Win32, Gluster, Sheepdog, iSCSI).

Stefan

author
#4 lore raw

[Qemu-devel] 回复: 回复: someconfusion on qemu i/o pocess and the qcow2format

I want to change the queue_size of virtio-blk ring from 128 to 1024, so I change here:
s->vq = virtio_add_queue(vdev, 128, virtio_blk_handle_output);
but the vm will not work. Are any thing i missed ?

#5 lore raw

Re: [Qemu-devel] 回复: 回复: someconfusion on qemu i/o pocess and the qcow2format

Quoted 3 lines · 浩樊啊

I want to change the queue_size of virtio-blk ring from 128 to 1024, so I change here:
s->vq = virtio_add_queue(vdev, 128, virtio_blk_handle_output);
but the vm will not work. Are any thing i missed ?

I think 1024 should work in theory (it's the max supported virtqueue size). You'd have to debug it to figure out why.

Stefan