From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35358) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VROO0-0000AN-PK for qemu-devel@nongnu.org; Wed, 02 Oct 2013 11:30:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VRONs-0003gn-PK for qemu-devel@nongnu.org; Wed, 02 Oct 2013 11:30:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26668) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRONs-0003gc-Gl for qemu-devel@nongnu.org; Wed, 02 Oct 2013 11:30:40 -0400 Message-ID: <524C3C14.6030409@redhat.com> Date: Wed, 02 Oct 2013 17:30:28 +0200 From: Max Reitz MIME-Version: 1.0 References: <1380717228-10135-1-git-send-email-benoit@irqsave.net> <1380717228-10135-2-git-send-email-benoit@irqsave.net> In-Reply-To: <1380717228-10135-2-git-send-email-benoit@irqsave.net> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH V4] block: Add BlockDriver.bdrv_check_ext_snapshot. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?ISO-8859-15?Q?Beno=EEt_Canet?= Cc: kwolf@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com On 2013-10-02 14:33, 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. > > Signed-off-by: Benoit Canet > --- > block.c | 17 +++++++++++++++++ > block/blkverify.c | 2 ++ > blockdev.c | 5 +++++ > include/block/block.h | 14 ++++++++++++++ > include/block/block_int.h | 6 ++++++ > 5 files changed, 44 insertions(+) > > diff --git a/block.c b/block.c > index 93e113a..e891522 100644 > --- a/block.c > +++ b/block.c > @@ -4632,3 +4632,20 @@ int bdrv_amend_options(BlockDriverState *bs, QEM= UOptionParameter *options) > } > return bs->drv->bdrv_amend_options(bs, options); > } > + > +ExtSnapshotPerm bdrv_check_ext_snapshot(BlockDriverState *bs) > +{ > + /* external snashots are allowed by defaults */ I don't really know whether it should rather be "by default", but it=20 certainly should be s/snashots/snapshots/. ;) Also, I'd move this comment below the if statements and above the return=20 EXT_SNAPSHOT_ALLOWED. > + if (bs->drv->bdrv_check_ext_snapshot) { > + return bs->drv->bdrv_check_ext_snapshot(bs); > + } > + if (bs->file && bs->file->drv && bs->file->drv->bdrv_check_ext_sna= pshot) { > + return bs->file->drv->bdrv_check_ext_snapshot(bs); > + } > + return EXT_SNAPSHOT_ALLOWED; > +} > + > +ExtSnapshotPerm bdrv_check_ext_snapshot_forbidden(BlockDriverState *bs= ) > +{ > + return EXT_SNAPSHOT_FORBIDDEN; > +} > diff --git a/block/blkverify.c b/block/blkverify.c > index 2077d8a..b64c638 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_check_ext_snapshot_forbidden, > }; > =20 > static void bdrv_blkverify_init(void) > diff --git a/blockdev.c b/blockdev.c > index 8aa66a9..92029d8 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) !=3D EXT_SNAPSHOT_ALLOW= ED) { > + 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..2bf0e12 100644 > --- a/include/block/block.h > +++ b/include/block/block.h > @@ -244,6 +244,20 @@ int bdrv_check(BlockDriverState *bs, BdrvCheckResu= lt *res, BdrvCheckMode fix); > =20 > int bdrv_amend_options(BlockDriverState *bs_new, QEMUOptionParameter = *options); > =20 > +/* external snapshots */ > + > +typedef enum { > + EXT_SNAPSHOT_ALLOWED, > + EXT_SNAPSHOT_FORBIDDEN, > +} ExtSnapshotPerm; > + > +/* return EXT_SNAPSHOT_ALLOWED if external snapshot is allowed > + * return EXT_SNAPSHOT_FORBIDEN if external snapshot is forbiden s/FORBIDEN/FORBIDDEN/, s/forbiden/forbidden/ > + */ > +ExtSnapshotPerm bdrv_check_ext_snapshot(BlockDriverState *bs); > +/* helper used to forbid external snapshots like in blkverify */ > +ExtSnapshotPerm bdrv_check_ext_snapshot_forbidden(BlockDriverState *bs= ); > + > /* async block I/O */ > typedef void BlockDriverDirtyHandler(BlockDriverState *bs, int64_t se= ctor, > int sector_num); > diff --git a/include/block/block_int.h b/include/block/block_int.h > index 211087a..e6a14ae 100644 > --- a/include/block/block_int.h > +++ b/include/block/block_int.h > @@ -67,6 +67,12 @@ typedef struct BdrvTrackedRequest { > struct BlockDriver { > const char *format_name; > int instance_size; > + > + /* if not defined external snapshots are allowed > + * future block filters will query their children to build the res= ponse > + */ > + ExtSnapshotPerm (*bdrv_check_ext_snapshot)(BlockDriverState *bs); > + > int (*bdrv_probe)(const uint8_t *buf, int buf_size, const char *f= ilename); > int (*bdrv_probe_device)(const char *filename); > =20 Aside from the misspellings (and regardless of whether you decide to=20 move the comment or not): Reviewed-by: Max Reitz