From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38019) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2zv8-0006x7-2n for qemu-devel@nongnu.org; Thu, 11 Jun 2015 06:41:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z2zv4-0002ko-Pv for qemu-devel@nongnu.org; Thu, 11 Jun 2015 06:41:14 -0400 Received: from mx2.parallels.com ([199.115.105.18]:47411) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2zv4-0002kU-L5 for qemu-devel@nongnu.org; Thu, 11 Jun 2015 06:41:10 -0400 Message-ID: <557965BC.4050400@virtuozzo.com> Date: Thu, 11 Jun 2015 13:41:00 +0300 From: Vladimir Sementsov-Ogievskiy 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> <5578BB2D.4010801@redhat.com> In-Reply-To: <5578BB2D.4010801@redhat.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit 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: John Snow , Stefan Hajnoczi Cc: kwolf@redhat.com, qemu-devel@nongnu.org, Vladimir Sementsov-Ogievskiy , stefanha@redhat.com, den@openvz.org, pbonzini@redhat.com On 11.06.2015 01:33, John Snow wrote: > > 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 = file->drv; >>> + if (!drv) { >>> + return NULL; >>> + } >>> + if (drv->bdrv_dirty_bitmap_load) { >>> + BdrvDirtyBitmap *bitmap; >>> + uint64_t bitmap_size = bdrv_nb_sectors(bs); >>> + uint8_t *buf = drv->bdrv_dirty_bitmap_load(file, name, bitmap_size, >>> + granularity); >>> + if (buf == NULL) { >>> + return NULL; >>> + } >>> + >>> + bitmap = bdrv_create_dirty_bitmap(bs, granularity, name, errp); >>> + if (bitmap == NULL) { >>> + g_free(buf); >>> + return NULL; >>> + } >>> + >>> + hbitmap_deserialize_part(bitmap->bitmap, buf, 0, bitmap_size); >>> + hbitmap_deserialize_finish(bitmap->bitmap); >> 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. >> > 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 I'll just use bdrv_dirty_bitmap_deserialize_part, etc, which are already in the code. -- Best regards, Vladimir * now, @virtuozzo.com instead of @parallels.com. Sorry for this inconvenience.