From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42014) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2Lxy-0005lY-Um for qemu-devel@nongnu.org; Tue, 09 Jun 2015 12:01:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z2Lxt-0004k1-B4 for qemu-devel@nongnu.org; Tue, 09 Jun 2015 12:01:30 -0400 Received: from mail-wi0-x22e.google.com ([2a00:1450:400c:c05::22e]:37407) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2Lxt-0004jE-4b for qemu-devel@nongnu.org; Tue, 09 Jun 2015 12:01:25 -0400 Received: by wifx6 with SMTP id x6so22093002wif.0 for ; Tue, 09 Jun 2015 09:01:24 -0700 (PDT) Date: Tue, 9 Jun 2015 17:01:22 +0100 From: Stefan Hajnoczi Message-ID: <20150609160122.GG3181@stefanha-thinkpad.redhat.com> References: <1433776886-27239-1-git-send-email-vsementsov@virtuozzo.com> <1433776886-27239-5-git-send-email-vsementsov@virtuozzo.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="+sHJum3is6Tsg7/J" Content-Disposition: inline In-Reply-To: <1433776886-27239-5-git-send-email-vsementsov@virtuozzo.com> 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: Vladimir Sementsov-Ogievskiy Cc: kwolf@redhat.com, qemu-devel@nongnu.org, Vladimir Sementsov-Ogievskiy , stefanha@redhat.com, den@openvz.org, pbonzini@redhat.com, jsnow@redhat.com --+sHJum3is6Tsg7/J Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. --+sHJum3is6Tsg7/J Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJVdw3SAAoJEJykq7OBq3PIiZYH/jq37eUmlaFi5CGVL1pLG7zB Kfs52643NZnmsPeI/vFlF98nApJTNU05ErNmRMbBhBX+RaG2rA02tLV1+u0ZmmcW aItbag6CoduAsenx5jsUD50hXI37tcrb6uBvs2XjJRwK+Jk8uOtlpuAnDZdU5ekw Vbx3y6gocrYHJGq7g8Wkrb/k/Buj6doWySJoQ/fwOHjEryj0EXSQw8LZvwgWAtQj uNVb/GWIkFkiwcPY3KkALcoySoE2j6rYtOdRA9G2CB6B1RslP6aDqID0SsjZZjrp jKDsmC4s3C0BqJfdGzeMYvIQa8ZTQMpswZC2S4QDO0MNASrvf9UUu/QWGKItACg= =3HDZ -----END PGP SIGNATURE----- --+sHJum3is6Tsg7/J--