Received: from eggs.gnu.org ([2001:4830:134:3::10]:37518) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsqqU-000122-Oz for qemu-devel@nongnu.org; Fri, 06 Jun 2014 05:54:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WsqqO-00043z-Ba for qemu-devel@nongnu.org; Fri, 06 Jun 2014 05:53:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46853) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsqqO-00043k-2c for qemu-devel@nongnu.org; Fri, 06 Jun 2014 05:53:52 -0400 Date: Fri, 6 Jun 2014 11:53:47 +0200 From: Kevin Wolf Message-ID: <20140606095347.GB4873@noname.redhat.com> References: <1401975393-7255-1-git-send-email-kwolf@redhat.com> <1401975393-7255-15-git-send-email-kwolf@redhat.com> <20140605150902.GD6430@irqsave.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20140605150902.GD6430@irqsave.net> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v4 14/21] raw-win32: Handle failure for potentially large allocations List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?iso-8859-1?Q?Beno=EEt?= Canet Cc: qemu-devel@nongnu.org, stefanha@redhat.com Am 05.06.2014 um 17:09 hat Beno=EEt Canet geschrieben: > The Thursday 05 Jun 2014 =E0 15:36:26 (+0200), Kevin Wolf wrote : > > Some code in the block layer makes potentially huge allocations. Fail= ure > > is not completely unexpected there, so avoid aborting qemu and handle > > out-of-memory situations gracefully. > >=20 > > This patch addresses the allocations in the raw-win32 block driver. > >=20 > > Signed-off-by: Kevin Wolf > > Reviewed-by: Stefan Hajnoczi > > --- > > block/win32-aio.c | 6 +++++- > > 1 file changed, 5 insertions(+), 1 deletion(-) > >=20 > > diff --git a/block/win32-aio.c b/block/win32-aio.c > > index 5d1d199..b8320ce 100644 > > --- a/block/win32-aio.c > > +++ b/block/win32-aio.c > > @@ -138,7 +138,10 @@ BlockDriverAIOCB *win32_aio_submit(BlockDriverSt= ate *bs, > > waiocb->is_read =3D (type =3D=3D QEMU_AIO_READ); > > =20 > > if (qiov->niov > 1) { > > - waiocb->buf =3D qemu_blockalign(bs, qiov->size); > > + waiocb->buf =3D qemu_try_blockalign(bs, qiov->size); > > + if (waiocb->buf =3D=3D NULL) { > > + goto out; > > + } > > if (type & QEMU_AIO_WRITE) { > > iov_to_buf(qiov->iov, qiov->niov, 0, waiocb->buf, qiov->= size); > > } > > @@ -167,6 +170,7 @@ BlockDriverAIOCB *win32_aio_submit(BlockDriverSta= te *bs, > > =20 > > out_dec_count: > > aio->count--; > Isn't waiocb->buf leaked on this path ? The already existing error path you mean? Looks like it, feel free to send a patch. Kevin > > +out: > > qemu_aio_release(waiocb); > > return NULL; > > } > > --=20 > > 1.8.3.1 > >=20 > >=20