Received: from eggs.gnu.org ([2001:4830:134:3::10]:40181) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyOa5-0003dm-LT for qemu-devel@nongnu.org; Tue, 09 Dec 2014 12:28:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XyOZw-0000b1-Kj for qemu-devel@nongnu.org; Tue, 09 Dec 2014 12:28:13 -0500 Received: from mail-wg0-x22f.google.com ([2a00:1450:400c:c00::22f]:64175) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyOZw-0000at-DO for qemu-devel@nongnu.org; Tue, 09 Dec 2014 12:28:04 -0500 Received: by mail-wg0-f47.google.com with SMTP id n12so1467974wgh.20 for ; Tue, 09 Dec 2014 09:28:03 -0800 (PST) Date: Tue, 9 Dec 2014 17:28:00 +0000 From: Stefan Hajnoczi Message-ID: <20141209172800.GG27053@stefanha-thinkpad.redhat.com> References: <1417465816-19345-1-git-send-email-jsnow@redhat.com> <1417465816-19345-7-git-send-email-jsnow@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="KR/qxknboQ7+Tpez" Content-Disposition: inline In-Reply-To: <1417465816-19345-7-git-send-email-jsnow@redhat.com> Subject: Re: [Qemu-devel] [PATCH v9 06/10] qmp: Add block-dirty-bitmap-enable and block-dirty-bitmap-disable 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 --KR/qxknboQ7+Tpez Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Dec 01, 2014 at 03:30:12PM -0500, John Snow wrote: > +/** > + * Return a dirty bitmap (if present), after validating > + * the device and bitmap names. Returns NULL on error, > + * including when the device and/or bitmap is not found. > + */ > +static BdrvDirtyBitmap *block_dirty_bitmap_lookup(const char *device, > + const char *name, > + Error **errp) > +{ > + BlockDriverState *bs; > + BdrvDirtyBitmap *bitmap; > + > + if (!device) { > + error_setg(errp, "Device cannot be NULL"); > + return NULL; > + } > + if (!name) { > + error_setg(errp, "Bitmap name cannot be NULL"); > + return NULL; > + } > + > + bs =3D bdrv_lookup_bs(device, NULL, errp); > + if (!bs) { > + return NULL; > + } > + > + bitmap =3D bdrv_find_dirty_bitmap(bs, name); > + if (!bitmap) { > + error_setg(errp, "Dirty bitmap not found: %s", name); > + return NULL; > + } > + > + return bitmap; > +} qmp_block_dirty_bitmap_remove() in an earlier patch should use this instead of duplicating code. > + > /* New and old BlockDriverState structs for atomic group operations */ > =20 > typedef struct BlkTransactionState BlkTransactionState; > @@ -1948,6 +1983,32 @@ void qmp_block_dirty_bitmap_remove(const char *dev= ice, const char *name, > bdrv_release_dirty_bitmap(bs, bitmap); > } > =20 > +void qmp_block_dirty_bitmap_enable(const char *device, const char *name, > + Error **errp) > +{ > + BdrvDirtyBitmap *bitmap; > + > + bitmap =3D block_dirty_bitmap_lookup(device, name, errp); > + if (!bitmap) { > + return; > + } > + > + bdrv_enable_dirty_bitmap(bitmap); > +} > + > +void qmp_block_dirty_bitmap_disable(const char *device, const char *name, > + Error **errp) > +{ > + BdrvDirtyBitmap *bitmap; > + > + bitmap =3D block_dirty_bitmap_lookup(device, name, errp); > + if (!bitmap) { > + return; > + } > + > + bdrv_disable_dirty_bitmap(bitmap); > +} The dirty bitmap is accessed during the BDS request processing code path and is owned by the BDS, so it should be protected by AioContext too. --KR/qxknboQ7+Tpez Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUhzEgAAoJEJykq7OBq3PIHBkIALdXWH0NuSMXNO+r1w2nkllo N5KRb3/1yp7EmCTJc8U6sAvEw8FZqn70zgnF+NiLCoc4hgID7YbEgRt5brm2UNxH KYN3JlljdfkmQAoggm9ZCpGTbtT9ZCUKL6OOFDA6uMf6DjuYv+FHD/B3+ucMk6QY ReH1gIyEzqz6tBGrKakyId8+A5WIbBWSEJsB5vFQRop/jmzOuLTmw85EyvxljHDp yQVnCmQfLyOmU5lwoVHHwTUZPI8yfBhvXVGJ5T3oDtFYkvSGhdSZSvvwsMLMlrTW 9VXAalWDGtiXinxDQTfdvQs5mf0EziSi8USmi/4jiBddArYADm8mBXY+7iIbhfc= =0yRw -----END PGP SIGNATURE----- --KR/qxknboQ7+Tpez--