From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsZM8-0005lr-8K for qemu-devel@nongnu.org; Thu, 05 Jun 2014 11:13:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WsZM2-0007e1-9s for qemu-devel@nongnu.org; Thu, 05 Jun 2014 11:13:28 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:46242 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsZ6L-00088Z-O3 for qemu-devel@nongnu.org; Thu, 05 Jun 2014 10:57:09 -0400 Date: Thu, 5 Jun 2014 16:57:08 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140605145708.GA6430@irqsave.net> References: <1401975393-7255-1-git-send-email-kwolf@redhat.com> <1401975393-7255-14-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1401975393-7255-14-git-send-email-kwolf@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v4 13/21] raw-posix: Handle failure for potentially large allocations List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: benoit.canet@irqsave.net, qemu-devel@nongnu.org, stefanha@redhat.com The Thursday 05 Jun 2014 =E0 15:36:25 (+0200), Kevin Wolf wrote : > Some code in the block layer makes potentially huge allocations. Failur= e > 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-posix block driver. >=20 > Signed-off-by: Kevin Wolf > Reviewed-by: Stefan Hajnoczi > --- > block/raw-posix.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) >=20 > diff --git a/block/raw-posix.c b/block/raw-posix.c > index b7f0f26..0cdf957 100644 > --- a/block/raw-posix.c > +++ b/block/raw-posix.c > @@ -753,7 +753,11 @@ static ssize_t handle_aiocb_rw(RawPosixAIOData *ai= ocb) > * Ok, we have to do it the hard way, copy all segments into > * a single aligned buffer. > */ > - buf =3D qemu_blockalign(aiocb->bs, aiocb->aio_nbytes); > + buf =3D qemu_try_blockalign(aiocb->bs, aiocb->aio_nbytes); > + if (buf =3D=3D NULL) { > + return -ENOMEM; > + } > + > if (aiocb->aio_type & QEMU_AIO_WRITE) { > char *p =3D buf; > int i; > --=20 > 1.8.3.1 >=20 >=20 Reviewed-by: Benoit Canet