disable blkverify external snapshot creation
PATCH v4 1/1 disable blkverify external snapshot creation
Hello,
Here is the new version of the snapshot forbidding patch.
v4: do also the check in bs->file->drv (make it work with quorum) [Benoît]
v3:
functions return an enum [Jeff]
rename forbiding function [Kevin]
v2:
Use NULL fields to avoid having to fill the new field in every BlockDriver
[Jeff]
Rename the field [Kevin]
Benoît Canet (1):
block: Add BlockDriver.bdrv_check_ext_snapshot.
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(+)
Signature · 1 line
1.8.1.2
PATCH v4 1/1 block: Add BlockDriver.bdrv_check_ext_snapshot.
This field is used by blkverify to disable external snapshots creation. I will also be used by block filters like quorum to disable external snapshots creation.
--- 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(+)
block.c +17 -0
@@ -4632,3 +4632,20 @@ int bdrv_amend_options(BlockDriverState *bs, QEMUOptionParameter *options) }return bs->drv->bdrv_amend_options (bs, options); } + +ExtSnapshotPerm bdrv_check_ext_snapshot (BlockDriverState *bs) +{ +/* external snashots are allowed by defaults */ +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_snapshot) { +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 ; +}
block/blkverify.c +2 -0
@@ -313,6 +313,8 @@ static BlockDriver bdrv_blkverify = { .bdrv_aio_readv = blkverify_aio_readv, .bdrv_aio_writev = blkverify_aio_writev, .bdrv_aio_flush = blkverify_aio_flush, + + .bdrv_check_ext_snapshot = bdrv_check_ext_snapshot_forbidden, };static void bdrv_blkverify_init (void )
blockdev.c +5 -0
@@ -1131,6 +1131,11 @@ static void external_snapshot_prepare(BlkTransactionState *common, } } +if (bdrv_check_ext_snapshot (state->old_bs) !=EXT_SNAPSHOT_ALLOWED ) { +error_set (errp,QERR_FEATURE_DISABLED ,"snapshot" ); +return ; + } + flags = state->old_bs->open_flags;/* create new image w/backing file */
include/block/block.h +14 -0
@@ -244,6 +244,20 @@ int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix);int bdrv_amend_options (BlockDriverState *bs_new,QEMUOptionParameter *options); +/* 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 +*/ +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 sector,int sector_num);
include/block/block_int.h +6 -0
@@ -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 response +*/ +ExtSnapshotPerm (*bdrv_check_ext_snapshot)(BlockDriverState *bs); +int (*bdrv_probe)(const uint8_t *buf,int buf_size,const char *filename);int (*bdrv_probe_device)(const char *filename);
Signature · 1 line
1.8.1.2
Re: [Qemu-devel] [PATCH V4] block: Add BlockDriver.bdrv_check_ext_snapshot.
Quoted 18 lines · Benoît Canet
This field is used by blkverify to disable external snapshots creation. I will also be used by block filters like quorum to disable external snapshots creation.
Signed-off-by Benoit Canet <[email protected]>--- 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(+)block.c +0
-0
block.c int bdrv_amend_options(BlockDriverState *bs, QEMUOptionParameter *options) · line 4638
Quoted 7 lines
block.c +4
-0@@ -4632,3 +4632,20 @@ int bdrv_amend_options(BlockDriverState *bs, QEMUOptionParameter *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 certainly should be s/snashots/snapshots/. ;) Also, I'd move this comment below the if statements and above the return EXT_SNAPSHOT_ALLOWED.
Quoted 49 lines
block.c +13
-0+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_snapshot) { +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 ; +}block/blkverify.c +2
-0@@ -313,6 +313,8 @@ static BlockDriver bdrv_blkverify = { .bdrv_aio_readv = blkverify_aio_readv, .bdrv_aio_writev = blkverify_aio_writev, .bdrv_aio_flush = blkverify_aio_flush, + + .bdrv_check_ext_snapshot = bdrv_check_ext_snapshot_forbidden, };static void bdrv_blkverify_init (void )blockdev.c +5
-0@@ -1131,6 +1131,11 @@ static void external_snapshot_prepare(BlkTransactionState *common, } } +if (bdrv_check_ext_snapshot (state->old_bs) !=EXT_SNAPSHOT_ALLOWED ) { +error_set (errp,QERR_FEATURE_DISABLED ,"snapshot" ); +return ; + } + flags = state->old_bs->open_flags;/* create new image w/backing file */ include/block/block.h +0
-0@@ -244,6 +244,20 @@ int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix);int bdrv_amend_options (BlockDriverState *bs_new,QEMUOptionParameter *options);
include/block/block.h int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix); · line 255
Quoted 10 lines
include/block/block.h +9
-0+/* 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/
Quoted 15 lines
include/block/block.h +5
-0+*/ +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 sector,int sector_num);include/block/block_int.h +0
-0@@ -67,6 +67,12 @@ typedef struct BdrvTrackedRequest {struct BlockDriver {const char *format_name;
include/block/block_int.h typedef struct BdrvTrackedRequest { · line 78
Quoted 10 lines
include/block/block_int.h +6
-0int instance_size; + +/* if not defined external snapshots are allowed +* future block filters will query their children to build the response +*/ +ExtSnapshotPerm (*bdrv_check_ext_snapshot)(BlockDriverState *bs); +int (*bdrv_probe)(const uint8_t *buf,int buf_size,const char *filename);int (*bdrv_probe_device)(const char *filename);
Aside from the misspellings (and regardless of whether you decide to move the comment or not):
Re: [Qemu-devel] [PATCH V4] block: Add BlockDriver.bdrv_check_ext_snapshot.
Am 02.10.2013 um 17:30 hat Max Reitz geschrieben:
Quoted 11 lines · Benoît Canet
Quoted 5 lines
This field is used by blkverify to disable external snapshots creation. I will also be used by block filters like quorum to disable external snapshots creation.
Signed-off-by Benoit Canet <[email protected]>Aside from the misspellings (and regardless of whether you decide to move the comment or not):
Reviewed-by Max Reitz <[email protected]>
Thanks, fixed up spelling and formatting and applied to the block branch.
Kevin
Re: [Qemu-devel] [PATCH V4] block: Add BlockDriver.bdrv_check_ext_snapshot.
In reply to Benoît CanetQuoted 3 lines · Benoît Canet
This field is used by blkverify to disable external snapshots creation. I will also be used by block filters like quorum to disable external snapshots creation.
Oh, I nearly missed it: s/I will also be/It will also be/ and probably s/external snapshots creation/external snapshot creation/, but I'm not too sure about the last one.
Re: [Qemu-devel] [PATCH V4] block: Add BlockDriver.bdrv_check_ext_snapshot.
Quoted 8 lines · Max Reitz
Quoted 4 lines · Benoît Canet
This field is used by blkverify to disable external snapshots creation. I will also be used by block filters like quorum to disable external snapshots
creation.Oh, I nearly missed it: s/I will also be/It will also be/ and probably s/external snapshots creation/external snapshot creation/, but I'm not too sure about the last one.
As a native speaker, yes, that last change sounds better ("to disable external snapshot creation").
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org