From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YstmC-0002rk-0Y for qemu-devel@nongnu.org; Thu, 14 May 2015 10:06:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ystm8-0006Yc-4C for qemu-devel@nongnu.org; Thu, 14 May 2015 10:06:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42993) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ystm7-0006YW-VQ for qemu-devel@nongnu.org; Thu, 14 May 2015 10:06:12 -0400 Date: Thu, 14 May 2015 22:06:09 +0800 From: Fam Zheng Message-ID: <20150514140609.GD22867@ad.nay.redhat.com> References: <55547907.5000203@cn.fujitsu.com> <55547B12.8020905@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55547B12.8020905@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2] mirror: correct buf_size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wen Congyang , Paolo Bonzini Cc: Kevin Wolf , Jeff Cody , qemu-devl On Thu, 05/14 12:38, Paolo Bonzini wrote: > > > On 14/05/2015 12:29, Wen Congyang wrote: > > > > If buf_size % granularity is not 0, mirror_free_init() will > > do dangerous things. > > > > Signed-off-by: Wen Congyang > > --- > > block/mirror.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/block/mirror.c b/block/mirror.c > > index 58f391a..9521212 100644 > > --- a/block/mirror.c > > +++ b/block/mirror.c > > @@ -684,7 +684,7 @@ static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target, > > s->is_none_mode = is_none_mode; > > s->base = base; > > s->granularity = granularity; > > - s->buf_size = MAX(buf_size, granularity); > > + s->buf_size = ROUND_UP(buf_size, granularity); > > > > s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, NULL, errp); > > if (!s->dirty_bitmap) { > > > > Reviewed-by: Paolo Bonzini What if buf_size is negative? Fam