Received: from eggs.gnu.org ([2001:4830:134:3::10]:42020) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjS5m-0001ga-9T for qemu-devel@nongnu.org; Wed, 29 Oct 2014 08:11:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XjS5d-000373-8f for qemu-devel@nongnu.org; Wed, 29 Oct 2014 08:11:10 -0400 Received: from mail-la0-x22d.google.com ([2a00:1450:4010:c03::22d]:40260) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjS5c-00036z-Td for qemu-devel@nongnu.org; Wed, 29 Oct 2014 08:11:01 -0400 Received: by mail-la0-f45.google.com with SMTP id gm9so2379069lab.32 for ; Wed, 29 Oct 2014 05:10:59 -0700 (PDT) Date: Wed, 29 Oct 2014 12:10:56 +0000 From: Stefan Hajnoczi Message-ID: <20141029121056.GA32180@stefanha-thinkpad.redhat.com> References: <1413889440-32577-1-git-send-email-stefanha@redhat.com> <1413889440-32577-3-git-send-email-stefanha@redhat.com> <544790B5.5040006@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ew6BAiZeqk4r7MaW" Content-Disposition: inline In-Reply-To: <544790B5.5040006@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2 02/11] blockdev: acquire AioContext in do_qmp_query_block_jobs_one() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Kevin Wolf , Paolo Bonzini , Fam Zheng , qemu-devel@nongnu.org, Stefan Hajnoczi --ew6BAiZeqk4r7MaW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Oct 22, 2014 at 01:10:45PM +0200, Max Reitz wrote: > On 2014-10-21 at 13:03, Stefan Hajnoczi wrote: > >Make sure that query-block-jobs acquires the BlockDriverState > >AioContext so that the blockjob isn't running in another thread while we > >access its state. > > > >Signed-off-by: Stefan Hajnoczi > >Reviewed-by: Max Reitz > >--- > > blockdev.c | 9 +++++++-- > > 1 file changed, 7 insertions(+), 2 deletions(-) > > > >diff --git a/blockdev.c b/blockdev.c > >index 1c7dab4..fd55904 100644 > >--- a/blockdev.c > >+++ b/blockdev.c > >@@ -2649,14 +2649,19 @@ fail: > > static void do_qmp_query_block_jobs_one(void *opaque, BlockDriverState= *bs) > > { > > BlockJobInfoList **prev =3D opaque; > >- BlockJob *job =3D bs->job; > >+ AioContext *aio_context; > >+ > >+ aio_context =3D bdrv_get_aio_context(bs); > >+ aio_context_acquire(aio_context); > >- if (job) { > >+ if (bs->job) { > > BlockJobInfoList *elem =3D g_new0(BlockJobInfoList, 1); > > elem->value =3D block_job_query(bs->job); > > (*prev)->next =3D elem; > > *prev =3D elem; > > } > >+ > >+ aio_context_release(aio_context); > > } > > BlockJobInfoList *qmp_query_block_jobs(Error **errp) >=20 > As already said in my review for v1, this conflicts with Markus's patch > "block: Eliminate bdrv_iterate(), use bdrv_next()"; it's still not in > master, but by now the pull request has been sent so I guess it's up to y= ou > to resolve it. ;-) Yes. The conflict is small, here is the resolution: diff --git a/blockdev.c b/blockdev.c index 501473d..40fc5d6 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2628,12 +2628,18 @@ BlockJobInfoList *qmp_query_block_jobs(Error **errp) BlockDriverState *bs; =20 for (bs =3D bdrv_next(NULL); bs; bs =3D bdrv_next(bs)) { + AioContext *aio_context =3D bdrv_get_aio_context(bs); + + aio_context_acquire(aio_context); + if (bs->job) { BlockJobInfoList *elem =3D g_new0(BlockJobInfoList, 1); elem->value =3D block_job_query(bs->job); *p_next =3D elem; p_next =3D &elem->next; } + + aio_context_release(aio_context); } =20 return head; --ew6BAiZeqk4r7MaW Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUUNlQAAoJEJykq7OBq3PIcy8IAIOYLC1vsKbPhrF/gnivjDGN zWqDofR70Zo+cxF8ZiR2T8hm2AcXg2LVO+1t/UF/Aj6XJgGU+DDHI+L0ucY6dkc8 STZNy7nGU2cg6s+4qn1vTuRJzqW4VENkK+tmxKltcl3iwqKVWBF8n0+t310wDvDA CiGv/DzFdLI2eHOn/z8gd8wI4ixZJFgl1FsROLykFPDhIYgYBoS7tzKgOeLTDsGy BegqT/KBcrGbpGPSuSYq2AEXYuyp8hNpHef0XRYM0wkVNFcwKPWmRI2x71Jg0KMx kDQtbtka6czZ51im/Ug25eGGVJqXGysMPTgipxHaP7j2kHgIpLbUzOQY8VtfMYE= =/391 -----END PGP SIGNATURE----- --ew6BAiZeqk4r7MaW--