From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O6qmR-0006MC-74 for qemu-devel@nongnu.org; Tue, 27 Apr 2010 15:49:15 -0400 Received: from [140.186.70.92] (port=48184 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O6qmQ-0006LM-0k for qemu-devel@nongnu.org; Tue, 27 Apr 2010 15:49:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O6qmO-0005kv-K5 for qemu-devel@nongnu.org; Tue, 27 Apr 2010 15:49:13 -0400 Received: from mail-bw0-f209.google.com ([209.85.218.209]:55383) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O6qmO-0005kY-FY for qemu-devel@nongnu.org; Tue, 27 Apr 2010 15:49:12 -0400 Received: by bwz1 with SMTP id 1so17267875bwz.2 for ; Tue, 27 Apr 2010 12:49:10 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: Date: Tue, 27 Apr 2010 20:49:09 +0100 Message-ID: Subject: Re: [Qemu-devel] thread synchronization in qcow2.c and qcow2-cluster.c From: Stefan Hajnoczi Content-Type: text/plain; charset=ISO-8859-1 List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Chunqiang (CQ) Tang" Cc: qemu-devel@nongnu.org On Tue, Apr 27, 2010 at 5:06 PM, Chunqiang (CQ) Tang 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