On Mon, Aug 26, 2013 at 10:07:23AM -0500, Yaodong Yang wrote: > 1. Is it true that all the requests to disk images need to go through > function bdrv_co_do_readv() or bdrv_co_do_writev()?
Yes, read/write requests go through those functions. > 2. In block-migration thread, the bdrv_co_do_readv is also called to read > blocks from disk images, in order to finish migration. How do migration > thread and IOthread cooperate with each other? there is an coroutine created > inside migration thread and a new botoom half created for this purpose, but I > do not understand well about it. Could someone explain it for me? QEMU has a global mutex (big lock) that is used to protect shared data: /* In migration thread: */ qemu_mutex_lock_iothread(); bdrv_*(bs, ...); qemu_mutex_unlock_iothread(); > 3. What is the meaning of copy on read ? Copy-on-read means that an image file is populated when read requests are processed. It's used together with backing files: template.img <- vm001.qcow2 In the beginning vm001.qcow2 might be empty so all reads go to template.img. When copy-on-read is enabled, data read from template.img will be written to vm001.qcow2. The next time a read is made to the same sectors they can be fetched from vm001.qcow2 instead. This is a useful feature for migrating (copying) an image to a new file system while the guest is still running. It can also be used to reduce network load when template.img is on NFS. Stefan