On Mon, Mar 31, 2014 at 10:09:13PM +0800, longguang.yue wrote: > from the aspect of qemu, there are file and block disk type, > what is the final difference between the two types ? > if its type is block and source is volume or physical disk, who finally > read/write the disk? > i thought block is raw format, so raw driver will do the actual r/w, am i > right? > if so qemu r/w using fileio no matter what disk type it is ? > > what is the call flows when disk type is block when vm r/w?
QEMU is a host userspace application and it performs disk I/O on behalf of the guest. The difference between raw image files and host block devices (e.g. LVM logical volumes or host partitions) is very small - the code for both is shared in block/raw-posix.c. If you are using the default -drive aio=threads option then a thread pool will perform pread()/pwrite()/preadv()/pwritev()/fdatasync(). If you are using -drive aio=native then Linux AIO APIs are used (io_submit() and io_getevents()). Stefan