From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WATfX-0006xN-I5 for qemu-devel@nongnu.org; Mon, 03 Feb 2014 19:15:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WATfS-00082f-FP for qemu-devel@nongnu.org; Mon, 03 Feb 2014 19:15:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:13491) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WATfS-00081D-7K for qemu-devel@nongnu.org; Mon, 03 Feb 2014 19:15:10 -0500 Date: Mon, 3 Feb 2014 19:15:03 -0500 From: Jeff Cody Message-ID: <20140204001503.GA29994@localhost.localdomain> References: <1390509099-695-1-git-send-email-benoit.canet@irqsave.net> <1390509099-695-6-git-send-email-benoit.canet@irqsave.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1390509099-695-6-git-send-email-benoit.canet@irqsave.net> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH V6 5/8] block: Create authorizations mechanism for external snapshot and resize. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?iso-8859-1?Q?Beno=EEt?= Canet Cc: kwolf@redhat.com, famz@redhat.com, =?iso-8859-1?Q?Beno=EEt?= Canet , qemu-devel@nongnu.org, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com On Thu, Jan 23, 2014 at 09:31:36PM +0100, Beno=EEt Canet wrote: > From: Beno=EEt Canet >=20 > Signed-off-by: Benoit Canet > --- > block.c | 65 +++++++++++++++++++++++++++++++++++++++= +------- > block/blkverify.c | 2 +- > blockdev.c | 2 +- > include/block/block.h | 20 +++++++-------- > include/block/block_int.h | 12 ++++++--- > 5 files changed, 77 insertions(+), 24 deletions(-) >=20 > diff --git a/block.c b/block.c > index e1bc732..3e0994b 100644 > --- a/block.c > +++ b/block.c > @@ -5088,21 +5088,68 @@ int bdrv_amend_options(BlockDriverState *bs, QE= MUOptionParameter *options) > return bs->drv->bdrv_amend_options(bs, options); > } > =20 > -ExtSnapshotPerm bdrv_check_ext_snapshot(BlockDriverState *bs) > +/* Used to recurse on single child block filters. > + * Single child block filter will store their child in bs->file. > + */ > +bool bdrv_generic_is_first_non_filter(BlockDriverState *bs, > + BlockDriverState *candidate) > { > - if (bs->drv->bdrv_check_ext_snapshot) { > - return bs->drv->bdrv_check_ext_snapshot(bs); > + if (!bs->drv) { > + return false; > + } > + > + if (!bs->drv->authorizations[BS_IS_A_FILTER]) { > + if (bs =3D=3D candidate) { > + return true; > + } else { > + return false; > + } This seems to break external snapshots; after this patch, I can no longer perform live ext snapshots (on qcow2, raw, etc..), unless I am doing something incorrectly. Instead of checking for bs =3D=3D candidate, was it intended to check to see if !strcmp(bs->filename, candidiate->filename) was true? Or maybe it is how bdrv_is_first_non_filter() is called (see below): > diff --git a/blockdev.c b/blockdev.c > index 3c27911..8f95c7f 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -1250,7 +1250,7 @@ static void external_snapshot_prepare(BlkTransact= ionState *common, > } > } > =20 > - if (bdrv_check_ext_snapshot(state->old_bs) !=3D EXT_SNAPSHOT_ALLOW= ED) { > + if (!bdrv_is_first_non_filter(state->old_bs)) { Should this be: !bdrv_is_first_non_filter(state->old_bs->file)? > error_set(errp, QERR_FEATURE_DISABLED, "snapshot"); > return; > } > diff --git a/include/block/block.h b/include/block/block.h > index b4a77e6..59d9f12 100644 > --- a/include/block/block.h > +++ b/include/block/block.h > @@ -287,16 +287,16 @@ int bdrv_amend_options(BlockDriverState *bs_new, = QEMUOptionParameter *options); > /* external snapshots */ > =20 > typedef enum { > - EXT_SNAPSHOT_ALLOWED, > - EXT_SNAPSHOT_FORBIDDEN, > -} ExtSnapshotPerm; > - > -/* return EXT_SNAPSHOT_ALLOWED if external snapshot is allowed > - * return EXT_SNAPSHOT_FORBIDDEN if external snapshot is 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= ); > + BS_IS_A_FILTER, > + BS_FILTER_PASS_DOWN, > + BS_AUTHORIZATION_COUNT, > +} BsAuthorization; > + > +bool bdrv_generic_is_first_non_filter(BlockDriverState *bs, > + BlockDriverState *candidate); > +bool bdrv_recurse_is_first_non_filter(BlockDriverState *bs, > + BlockDriverState *candidate); > +bool bdrv_is_first_non_filter(BlockDriverState *candidate); > =20 > /* async block I/O */ > typedef void BlockDriverDirtyHandler(BlockDriverState *bs, int64_t sec= tor, > diff --git a/include/block/block_int.h b/include/block/block_int.h > index f3f518c..611a955 100644 > --- a/include/block/block_int.h > +++ b/include/block/block_int.h > @@ -69,10 +69,16 @@ struct BlockDriver { > const char *format_name; > int instance_size; > =20 > - /* if not defined external snapshots are allowed > - * future block filters will query their children to build the res= ponse > + /* this table of boolean contains authorizations for the block ope= rations */ > + bool authorizations[BS_AUTHORIZATION_COUNT]; > + /* for snapshots complex block filter like Quorum can implement th= e > + * following recursive callback instead of BS_IS_A_FILTER. > + * It's purpose is to recurse on the filter children while calling > + * bdrv_recurse_is_first_non_filter on them. > + * For a sample implementation look in the future Quorum block fil= ter. > */ > - ExtSnapshotPerm (*bdrv_check_ext_snapshot)(BlockDriverState *bs); > + bool (*bdrv_recurse_is_first_non_filter)(BlockDriverState *bs, > + BlockDriverState *candida= te); > =20 > int (*bdrv_probe)(const uint8_t *buf, int buf_size, const char *fi= lename); > int (*bdrv_probe_device)(const char *filename); > --=20 > 1.8.3.2 >=20 >=20