From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57548) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPEju-0003wf-IY for qemu-devel@nongnu.org; Thu, 26 Sep 2013 12:48:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VPEjj-0005gy-IK for qemu-devel@nongnu.org; Thu, 26 Sep 2013 12:48:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23962) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPEjj-0005g0-9J for qemu-devel@nongnu.org; Thu, 26 Sep 2013 12:48:19 -0400 Date: Thu, 26 Sep 2013 12:48:13 -0400 From: Jeff Cody Message-ID: <20130926164813.GA29688@localhost.localdomain> References: <1380206029-9740-1-git-send-email-benoit@irqsave.net> <1380206029-9740-2-git-send-email-benoit@irqsave.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1380206029-9740-2-git-send-email-benoit@irqsave.net> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH V2] block: Add BlockDriver.bdrv_check_ext_snapshot. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?iso-8859-1?Q?Beno=EEt?= Canet Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com On Thu, Sep 26, 2013 at 04:33:49PM +0200, Beno=EEt Canet wrote: > This field is used by blkverify to disable external snapshots creation. > I will also be used by block filters like quorum to disable external sn= apshots > creation. >=20 > Signed-off-by: Benoit Canet > --- > block.c | 14 ++++++++++++++ > block/blkverify.c | 2 ++ > blockdev.c | 5 +++++ > include/block/block.h | 7 +++++++ > include/block/block_int.h | 8 ++++++++ > 5 files changed, 36 insertions(+) >=20 > diff --git a/block.c b/block.c > index 4833b37..4da6fd9 100644 > --- a/block.c > +++ b/block.c > @@ -4632,3 +4632,17 @@ int bdrv_amend_options(BlockDriverState *bs, QEM= UOptionParameter *options) > } > return bs->drv->bdrv_amend_options(bs, options); > } > + > +bool bdrv_check_ext_snapshot(BlockDriverState *bs) > +{ > + /* external snashots are enabled by defaults */ > + if (!bs->drv->bdrv_check_ext_snapshot) { > + return true; > + } > + return bs->drv->bdrv_check_ext_snapshot(bs); > +} > + > +bool bdrv_forbid_ext_snapshot(BlockDriverState *bs) > +{ > + return false; > +} The only problem I have with this now, is that "bdrv_forbid_ext_snapshot()" returns false, to indicate that "forbid ext snapshot" is true. Looking at the function above, I would come to the opposite conclusion as to what it does. I understand why - you want the function name assigned to .bdrv_check_ext_snapshot to reflect the action, but then that causes the boolean return to be misleading. Maybe returning an enum would be more natural? I apologize if this seems too pedantic. :) Thanks, Jeff > diff --git a/block/blkverify.c b/block/blkverify.c > index 2077d8a..c548923 100644 > --- a/block/blkverify.c > +++ b/block/blkverify.c > @@ -313,6 +313,8 @@ static BlockDriver bdrv_blkverify =3D { > .bdrv_aio_readv =3D blkverify_aio_readv, > .bdrv_aio_writev =3D blkverify_aio_writev, > .bdrv_aio_flush =3D blkverify_aio_flush, > + > + .bdrv_check_ext_snapshot =3D bdrv_forbid_ext_snapshot, > }; > =20 > static void bdrv_blkverify_init(void) > diff --git a/blockdev.c b/blockdev.c > index 8aa66a9..5c16f1b 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -1131,6 +1131,11 @@ static void external_snapshot_prepare(BlkTransac= tionState *common, > } > } > =20 > + if (!bdrv_check_ext_snapshot(state->old_bs)) { > + error_set(errp, QERR_FEATURE_DISABLED, "snapshot"); > + return; > + } > + > flags =3D state->old_bs->open_flags; > =20 > /* create new image w/backing file */ > diff --git a/include/block/block.h b/include/block/block.h > index f808550..df19610 100644 > --- a/include/block/block.h > +++ b/include/block/block.h > @@ -244,6 +244,13 @@ int bdrv_check(BlockDriverState *bs, BdrvCheckResu= lt *res, BdrvCheckMode fix); > =20 > int bdrv_amend_options(BlockDriverState *bs_new, QEMUOptionParameter *= options); > =20 > +/* external snapshots */ > + > +/* return true if external snapshot is allowed, false if not */ > +bool bdrv_check_ext_snapshot(BlockDriverState *bs); > +/* helper used to forbid external snapshots like in blkverify */ > +bool bdrv_forbid_ext_snapshot(BlockDriverState *bs); > + > /* async block I/O */ > typedef void BlockDriverDirtyHandler(BlockDriverState *bs, int64_t sec= tor, > int sector_num); > diff --git a/include/block/block_int.h b/include/block/block_int.h > index 211087a..cb92355 100644 > --- a/include/block/block_int.h > +++ b/include/block/block_int.h > @@ -67,6 +67,14 @@ typedef struct BdrvTrackedRequest { > struct BlockDriver { > const char *format_name; > int instance_size; > + > + /* if not defined external snapshots are allowed > + * if return true external snapshots are allowed > + * if return false external snapshots are not allowed > + * future block filters will query their children to build the res= ponse > + */ > + bool (*bdrv_check_ext_snapshot)(BlockDriverState *bs); > + > int (*bdrv_probe)(const uint8_t *buf, int buf_size, const char *fi= lename); > int (*bdrv_probe_device)(const char *filename); > =20 > --=20 > 1.8.1.2 >=20 >=20