block: Add BlockDriver.bdrv_check_ext_snapshot.
This field is used by blkverify to disable external snapshots creation. It will also be used by block filters like quorum to disable external snapshot creation. Signed-off-by: Benoit Canet <benoit@irqsave.net> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
92bc50a5ad
commit
f6186f49e2
19
block.c
19
block.c
@ -4647,3 +4647,22 @@ int bdrv_amend_options(BlockDriverState *bs, QEMUOptionParameter *options)
|
||||
}
|
||||
return bs->drv->bdrv_amend_options(bs, options);
|
||||
}
|
||||
|
||||
ExtSnapshotPerm bdrv_check_ext_snapshot(BlockDriverState *bs)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
/* external snapshots are allowed by default */
|
||||
return EXT_SNAPSHOT_ALLOWED;
|
||||
}
|
||||
|
||||
ExtSnapshotPerm bdrv_check_ext_snapshot_forbidden(BlockDriverState *bs)
|
||||
{
|
||||
return EXT_SNAPSHOT_FORBIDDEN;
|
||||
}
|
||||
|
@ -417,6 +417,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)
|
||||
|
@ -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 */
|
||||
|
@ -248,6 +248,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_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);
|
||||
|
||||
/* async block I/O */
|
||||
typedef void BlockDriverDirtyHandler(BlockDriverState *bs, int64_t sector,
|
||||
int sector_num);
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user