From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52970) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bD6lY-0008Nw-CY for qemu-devel@nongnu.org; Wed, 15 Jun 2016 05:05:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bD6lT-0001It-BK for qemu-devel@nongnu.org; Wed, 15 Jun 2016 05:05:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39929) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bD6lT-0001Im-4i for qemu-devel@nongnu.org; Wed, 15 Jun 2016 05:05:35 -0400 Date: Wed, 15 Jun 2016 17:05:28 +0800 From: Fam Zheng Message-ID: <20160615090528.GE14453@ad.usersys.redhat.com> References: <1465928228-1184-1-git-send-email-stefanha@redhat.com> <1465928228-1184-4-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1465928228-1184-4-git-send-email-stefanha@redhat.com> Subject: Re: [Qemu-devel] [PATCH v4 3/5] blockjob: add AioContext attached callback List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org, Kevin Wolf , jjherne@linux.vnet.ibm.com, Paolo Bonzini , Jeff Cody , mreitz@redhat.com On Tue, 06/14 19:17, Stefan Hajnoczi wrote: > > +static void block_job_attached_aio_context(AioContext *new_context, > + void *opaque) > +{ > + BlockJob *job = opaque; > + > + if (job->driver->attached_aio_context) { > + job->driver->attached_aio_context(job, new_context); > + } > + > + block_job_resume(job); > +} > + > +static void block_job_detach_aio_context(void *opaque) > +{ > + BlockJob *job = opaque; > + > + /* In case the job terminates during aio_poll()... */ > + block_job_ref(job); > + > + block_job_pause(job); > + > + if (!job->paused) { > + /* If job is !job->busy this kicks it into the next pause point. */ > + block_job_enter(job); > + } > + while (!job->paused && !job->completed) { > + aio_poll(blk_get_aio_context(job->blk), true); For the complete part, we should do it like block_job_finish_sync: while (!job->completed) { aio_poll(job->deferred_to_main_loop ? qemu_get_aio_context() : blk_get_aio_context(job->blk), true); } > + } > + > + block_job_unref(job); > +} > + Fam