From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:38611) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QL8lL-0005Nx-Rb for qemu-devel@nongnu.org; Sat, 14 May 2011 02:55:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QL8lK-0004qz-MG for qemu-devel@nongnu.org; Sat, 14 May 2011 02:55:43 -0400 Received: from mail-ey0-f173.google.com ([209.85.215.173]:64348) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QL8lK-0004qq-DO for qemu-devel@nongnu.org; Sat, 14 May 2011 02:55:42 -0400 Received: by eyb6 with SMTP id 6so1085370eyb.4 for ; Fri, 13 May 2011 23:55:41 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1305278792-20933-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1305278792-20933-1-git-send-email-stefanha@linux.vnet.ibm.com> Date: Sat, 14 May 2011 08:55:40 +0200 Message-ID: From: Corentin Chary Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 0/4] Coroutines for better asynchronous programming List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , Paolo Bonzini , Anthony Liguori , qemu-devel@nongnu.org, Blue Swirl On Fri, May 13, 2011 at 11:26 AM, Stefan Hajnoczi wrote: > QEMU is event-driven and suffers when blocking operations are performed b= ecause > VM execution may be stopped until the operation completes. =C2=A0Therefor= e many > operations that could block are performed asynchronously and a callback i= s > invoked when the operation has completed. =C2=A0This allows QEMU to conti= nue > executing while the operation is pending. > > The downside to callbacks is that they split up code into many smaller > functions, each of which is a single step in a state machine that quickly > becomes complex and hard to understand. =C2=A0Callback functions also res= ult in lots > of noise as variables are packed and unpacked into temporary structs that= pass > state to the callback function. > > This patch series introduces coroutines as a solution for writing asynchr= onous > code while still having a nice sequential control flow. =C2=A0The semanti= cs are > explained in the first patch. =C2=A0The second patch adds automated tests= . > > A nice feature of coroutines is that it is relatively easy to take synchr= onous > code and lift it into a coroutine to make it asynchronous. =C2=A0Work has= been done > to move qcow2 request processing into coroutines and thereby make it > asynchronous (today qcow2 will perform synchronous metadata accesses). = =C2=A0This > qcow2 work is still ongoing and not quite ready for mainline yet. > > Coroutines are also being used for virtfs (virtio-9p) so I have submitted= this > patch now because virtfs patches that depend on coroutines are being publ= ished. > > Other areas of QEMU that could take advantage of coroutines include the V= NC > server, migration, and qemu-tools. Hum, the VNC server is already threaded, how would coroutines help ? Do you plan to rewrite the server using coroutines instead of threads ? Thanks --=20 Corentin Chary http://xf.iksaif.net