From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VF1M2-00024E-Hb for qemu-devel@nongnu.org; Thu, 29 Aug 2013 08:29:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VF1Lq-0001DG-T7 for qemu-devel@nongnu.org; Thu, 29 Aug 2013 08:29:38 -0400 Received: from mail-ee0-x235.google.com ([2a00:1450:4013:c00::235]:45644) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VF1Lq-0001Ct-Lg for qemu-devel@nongnu.org; Thu, 29 Aug 2013 08:29:26 -0400 Received: by mail-ee0-f53.google.com with SMTP id b15so206438eek.12 for ; Thu, 29 Aug 2013 05:29:25 -0700 (PDT) Date: Thu, 29 Aug 2013 14:29:22 +0200 From: Stefan Hajnoczi Message-ID: <20130829122922.GB17744@stefanha-thinkpad.redhat.com> References: <1376070245-22557-1-git-send-email-charlie@ctshepherd.com> <1376070245-22557-5-git-send-email-charlie@ctshepherd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1376070245-22557-5-git-send-email-charlie@ctshepherd.com> Subject: Re: [Qemu-devel] [RFC v2 05/15] Make qcow2_open synchronous List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Charlie Shepherd Cc: kwolf@redhat.com, pbonzini@redhat.com, gabriel@kerneis.info, qemu-devel@nongnu.org On Fri, Aug 09, 2013 at 07:43:55PM +0200, Charlie Shepherd wrote: > +static int qcow2_open(BlockDriverState *bs, QDict *options, int flags) > +{ > + Coroutine *co; > + struct QOpenCo qo = { > + .bs = bs, > + .options = options, > + .flags = flags, > + .ret = NOT_DONE, > + }; > + > + co = qemu_coroutine_create(qcow2_co_open_entry); > + qemu_coroutine_enter(co, &qo); > + while (qo.ret == NOT_DONE) { > + qemu_aio_wait(); > + } I think a cleaner approach is a bool qo.done field instead of using a magic NOT_DONE value. This way the return value of qcow2_co_open() can never collide with NOT_DONE. (In block.c we use NOT_DONE but I'd like to start using a separate field to indicate completion in new places.)