From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2oYm-00022g-2h for qemu-devel@nongnu.org; Wed, 10 Jun 2015 18:33:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z2oYi-0003Og-SA for qemu-devel@nongnu.org; Wed, 10 Jun 2015 18:33:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36401) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2oYi-0003OK-ND for qemu-devel@nongnu.org; Wed, 10 Jun 2015 18:33:20 -0400 Message-ID: <5578BB2D.4010801@redhat.com> Date: Wed, 10 Jun 2015 18:33:17 -0400 From: John Snow MIME-Version: 1.0 References: <1433776886-27239-1-git-send-email-vsementsov@virtuozzo.com> <1433776886-27239-5-git-send-email-vsementsov@virtuozzo.com> <20150609160122.GG3181@stefanha-thinkpad.redhat.com> In-Reply-To: <20150609160122.GG3181@stefanha-thinkpad.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 4/8] block: add bdrv_load_dirty_bitmap List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi , Vladimir Sementsov-Ogievskiy Cc: kwolf@redhat.com, qemu-devel@nongnu.org, Vladimir Sementsov-Ogievskiy , stefanha@redhat.com, den@openvz.org, pbonzini@redhat.com On 06/09/2015 12:01 PM, Stefan Hajnoczi wrote: > On Mon, Jun 08, 2015 at 06:21:22PM +0300, Vladimir Sementsov-Ogievskiy = wrote: >> +BdrvDirtyBitmap *bdrv_load_dirty_bitmap(BlockDriverState *bs, >> + BlockDriverState *file, >> + int granularity, >> + const char *name, >> + Error **errp) >> +{ >> + BlockDriver *drv =3D file->drv; >> + if (!drv) { >> + return NULL; >> + } >> + if (drv->bdrv_dirty_bitmap_load) { >> + BdrvDirtyBitmap *bitmap; >> + uint64_t bitmap_size =3D bdrv_nb_sectors(bs); >> + uint8_t *buf =3D drv->bdrv_dirty_bitmap_load(file, name, bitm= ap_size, >> + granularity); >> + if (buf =3D=3D NULL) { >> + return NULL; >> + } >> + >> + bitmap =3D bdrv_create_dirty_bitmap(bs, granularity, name, er= rp); >> + if (bitmap =3D=3D NULL) { >> + g_free(buf); >> + return NULL; >> + } >> + >> + hbitmap_deserialize_part(bitmap->bitmap, buf, 0, bitmap_size)= ; >> + hbitmap_deserialize_finish(bitmap->bitmap); >=20 > How about passing bitmap and errp into drv->bdrv_dirty_bitmap_load? > That way bdrv_dirty_bitmap_load() can stream using > hbitmap_deserialize_part() and does not need to allocate the full > bitmap. It can also report errors properly. >=20 My hunch is that this was avoided because BdrvDirtyBitmap is currently a structure local only to block.c, but I would be fine with shifting the header to block_int.h and giving the BdrvDirtyBitmap some limited exposure outside of the block core file to facilitate some cleaner function prototypes here. OR, you could have the qcow2 layer rely on serialization functions that are written back here in block.c that supports feeding it out chunk-by-chunk. Whatever happens to feel cleaner is (probably) fine by me. --js