From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46495) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyNDz-0004H2-TL for qemu-devel@nongnu.org; Tue, 09 Dec 2014 11:01:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XyNDp-0004QI-Aj for qemu-devel@nongnu.org; Tue, 09 Dec 2014 11:01:19 -0500 Received: from mail-wg0-x22a.google.com ([2a00:1450:400c:c00::22a]:41369) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyNDo-0004QA-NX for qemu-devel@nongnu.org; Tue, 09 Dec 2014 11:01:09 -0500 Received: by mail-wg0-f42.google.com with SMTP id z12so1244316wgg.1 for ; Tue, 09 Dec 2014 08:01:08 -0800 (PST) Date: Tue, 9 Dec 2014 16:00:59 +0000 From: Stefan Hajnoczi Message-ID: <20141209160059.GD27053@stefanha-thinkpad.redhat.com> References: <1417465816-19345-1-git-send-email-jsnow@redhat.com> <1417465816-19345-3-git-send-email-jsnow@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="3Gf/FFewwPeBMqCJ" Content-Disposition: inline In-Reply-To: <1417465816-19345-3-git-send-email-jsnow@redhat.com> Subject: Re: [Qemu-devel] [PATCH v9 02/10] qmp: Add block-dirty-bitmap-add and block-dirty-bitmap-remove List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow Cc: kwolf@redhat.com, Fam Zheng , armbru@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, vsementsov@parallels.com, stefanha@redhat.com, pbonzini@redhat.com --3Gf/FFewwPeBMqCJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Dec 01, 2014 at 03:30:08PM -0500, John Snow wrote: > diff --git a/block.c b/block.c > index e5c6ccf..3f27519 100644 > --- a/block.c > +++ b/block.c > @@ -5420,6 +5420,25 @@ int bdrv_get_dirty(BlockDriverState *bs, BdrvDirty= Bitmap *bitmap, int64_t sector > } > } > =20 > +#define BDB_MIN_DEF_GRANULARITY 4096 > +#define BDB_MAX_DEF_GRANULARITY 65536 > +#define BDB_DEFAULT_GRANULARITY BDB_MAX_DEF_GRANULARITY > + > +uint64_t bdrv_dbm_calc_def_granularity(BlockDriverState *bs) Long names are unwieldy but introducing multiple abbreviations is not a good solution, it makes the code more confusing (BDB vs dbm). I would call the function bdrv_get_default_bitmap_granularity(). The constants weren't necessary since the point of this function is to capture the default value. No one else should use the constants - otherwise there is a high probability that they are reimplementing this logic. I would just leave them as literals in the code. > diff --git a/blockdev.c b/blockdev.c > index 5651a8e..4d30b09 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -1894,6 +1894,60 @@ void qmp_block_set_io_throttle(const char *device,= int64_t bps, int64_t bps_rd, > aio_context_release(aio_context); > } > =20 > +void qmp_block_dirty_bitmap_add(const char *device, const char *name, > + bool has_granularity, int64_t granularit= y, > + Error **errp) > +{ > + BlockDriverState *bs; > + > + bs =3D bdrv_lookup_bs(device, NULL, errp); Markus: I think we need to support node-name here so dirty bitmaps can be applied at any node in the graph? > + if (!bs) { > + return; > + } These new monitor commands need to acquire/release the BlockDriverState's AioContext like the other monitor commands. This ensures that BDS accesses in other threads are synchronized (stopped while we run). AioContext *aio_context; aio_context =3D bdrv_get_aio_context(bs); aio_context_acquire(aio_context); =2E.. out: aio_context_release(aio_context); --3Gf/FFewwPeBMqCJ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUhxy7AAoJEJykq7OBq3PIznYIAJotGGfTIfgWR1y5jV/M/1qn 4SH4YsSoMHz8WBMnjimcDjWchVbHYuHV32QorYN9cke68lZ+fkzmqaEegYaglM5u IHe+OEGf8ydYVtoUbhAtGc1wx6SmCYbhkkcJaxJeJqrOij+mHFzJvjSynELB1iXd qmCWtNFbzjztnp6wqrMtt+fupnv8R6C6h8w9ZILQIAWejih04ZFsWuuPq8ESX3vQ tlEczybtoF3TSc8PC4Xp6kLdy8fmQX0z8Uu/PpKz3QY+2LhiGpg20Z2BEgTZOXAV o1q7NFglQKDrNI8n450d2AkGQWf1s4gI1t8byJZ8QDdGC5AvmjkBzweYK0YNLZk= =BkwR -----END PGP SIGNATURE----- --3Gf/FFewwPeBMqCJ--