I am trying to understand the IO paths in QEMU (which I understand emulates IO for KVM) to have a better idea of how it works and get a clear picture of how I can trap all read/write requests being issued by the VM in the QEMU block layer for a project that I am working on.
For example, lets say that we use QCOW2 image format for VMs. Looking into the code, I was able to track the requests as follows:
bdrv_read() -> bdrv_rw_co() -> bdrv_rw_co_entry() -> bdrv_co_do_readv() -> this calls into driver specific functions
qcow2_co_readv() -> bdrv_co_readv() [back into block.c] -> bdrv_co_do_readv()
After this it looks like the driver specific function is called again. I am pretty sure I am missing something here or my understanding is incorrect.
Can you please help me in understanding the complete IO path from the guest VM into QEMU and from QEMU into the host? What are some of the other things I should be careful about.
I am a complete novice in QEMU/KVM environment and would really appreciate any help you can provide.
Thanks in advance,
Aayush