On Tue, Apr 27, 2010 at 5:06 PM, Chunqiang (CQ) Tang <tang...@gmail.com> wrote: > I just started to read the code of qemu-kvm-0.12.3 recently, and was > puzzled by the thread synchronization issue in qcow2.c and > qcow2-cluster.c. Could someone please enlighten me? Thanks!
Is this what you are looking for: kvm-all.c:kvm_cpu_exec: qemu_mutex_unlock_iothread(); ret = kvm_vcpu_ioctl(env, KVM_RUN, 0); qemu_mutex_lock_iothread(); and vl.c:main_loop_wait: ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv); qemu_mutex_lock_iothread(); if (ret > 0) { IOHandlerRecord *pioh; QLIST_FOREACH_SAFE(ioh, &io_handlers, next, pioh) { If I understand correctly the global iothread mutex prevents block driver code from executing concurrently. Stefan