From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50701) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrqZX-0007Eu-Fd for qemu-devel@nongnu.org; Tue, 03 Jun 2014 11:24:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WrqZR-0003XB-7W for qemu-devel@nongnu.org; Tue, 03 Jun 2014 11:24:19 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:38736 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrqZR-0003X3-1H for qemu-devel@nongnu.org; Tue, 03 Jun 2014 11:24:13 -0400 Date: Tue, 3 Jun 2014 17:24:12 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140603152412.GF21314@irqsave.net> References: <1401801062-9154-1-git-send-email-kwolf@redhat.com> <1401801062-9154-21-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1401801062-9154-21-git-send-email-kwolf@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 20/21] mirror: 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, mreitz@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, armbru@redhat.com The Tuesday 03 Jun 2014 =E0 15:11:01 (+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 mirror block job. >=20 > Signed-off-by: Kevin Wolf > Reviewed-by: Stefan Hajnoczi > --- > block/mirror.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) >=20 > diff --git a/block/mirror.c b/block/mirror.c > index 94c8661..07417d7 100644 > --- a/block/mirror.c > +++ b/block/mirror.c > @@ -350,7 +350,12 @@ static void coroutine_fn mirror_run(void *opaque) > } > =20 > end =3D s->common.len >> BDRV_SECTOR_BITS; > - s->buf =3D qemu_blockalign(bs, s->buf_size); > + s->buf =3D qemu_try_blockalign(bs, s->buf_size); > + if (s->buf =3D=3D NULL) { > + ret =3D -ENOMEM; > + goto immediate_exit; > + } > + > sectors_per_chunk =3D s->granularity >> BDRV_SECTOR_BITS; > mirror_free_init(s); > =20 > --=20 > 1.8.3.1 >=20 >=20 Reviewed-by: Benoit Canet