* [Qemu-devel] [PATCH V4] disable blkverify external snapshot creation
@ 2013-10-02 12:33 Benoît Canet
2013-10-02 12:33 ` [Qemu-devel] [PATCH V4] block: Add BlockDriver.bdrv_check_ext_snapshot Benoît Canet
0 siblings, 1 reply; 6+ messages in thread
From: Benoît Canet @ 2013-10-02 12:33 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, jcody, Benoît Canet, stefanha
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(+)
--
1.8.1.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH V4] block: Add BlockDriver.bdrv_check_ext_snapshot.
2013-10-02 12:33 [Qemu-devel] [PATCH V4] disable blkverify external snapshot creation Benoît Canet
@ 2013-10-02 12:33 ` Benoît Canet
2013-10-02 15:30 ` Max Reitz
2013-10-02 15:33 ` Max Reitz
0 siblings, 2 replies; 6+ messages in thread
From: Benoît Canet @ 2013-10-02 12:33 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, jcody, Benoît Canet, stefanha
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 <benoit@irqsave.net>
---
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, 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;
+}
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 = {
.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)
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(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 */
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, 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);
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 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);
--
1.8.1.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH V4] block: Add BlockDriver.bdrv_check_ext_snapshot.
2013-10-02 12:33 ` [Qemu-devel] [PATCH V4] block: Add BlockDriver.bdrv_check_ext_snapshot Benoît Canet
@ 2013-10-02 15:30 ` Max Reitz
2013-10-09 10:22 ` Kevin Wolf
2013-10-02 15:33 ` Max Reitz
1 sibling, 1 reply; 6+ messages in thread
From: Max Reitz @ 2013-10-02 15:30 UTC (permalink / raw)
To: Benoît Canet; +Cc: kwolf, jcody, qemu-devel, stefanha
On 2013-10-02 14:33, Benoît 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 snapshots
> creation.
>
> Signed-off-by: Benoit Canet <benoit@irqsave.net>
> ---
> 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, 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.
> + 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;
> +}
> 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 = {
> .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)
> 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(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 */
> 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, 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
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 sector,
> 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 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):
Reviewed-by: Max Reitz <mreitz@redhat.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH V4] block: Add BlockDriver.bdrv_check_ext_snapshot.
2013-10-02 12:33 ` [Qemu-devel] [PATCH V4] block: Add BlockDriver.bdrv_check_ext_snapshot Benoît Canet
2013-10-02 15:30 ` Max Reitz
@ 2013-10-02 15:33 ` Max Reitz
2013-10-02 15:42 ` Eric Blake
1 sibling, 1 reply; 6+ messages in thread
From: Max Reitz @ 2013-10-02 15:33 UTC (permalink / raw)
To: Benoît Canet; +Cc: kwolf, jcody, qemu-devel, stefanha
On 2013-10-02 14:33, Benoît 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 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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH V4] block: Add BlockDriver.bdrv_check_ext_snapshot.
2013-10-02 15:33 ` Max Reitz
@ 2013-10-02 15:42 ` Eric Blake
0 siblings, 0 replies; 6+ messages in thread
From: Eric Blake @ 2013-10-02 15:42 UTC (permalink / raw)
To: Max Reitz; +Cc: kwolf, jcody, Benoît Canet, stefanha, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 659 bytes --]
On 10/02/2013 09:33 AM, Max Reitz wrote:
> On 2013-10-02 14:33, Benoît 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
>> 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").
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH V4] block: Add BlockDriver.bdrv_check_ext_snapshot.
2013-10-02 15:30 ` Max Reitz
@ 2013-10-09 10:22 ` Kevin Wolf
0 siblings, 0 replies; 6+ messages in thread
From: Kevin Wolf @ 2013-10-09 10:22 UTC (permalink / raw)
To: Max Reitz; +Cc: jcody, Benoît Canet, stefanha, qemu-devel
Am 02.10.2013 um 17:30 hat Max Reitz geschrieben:
> On 2013-10-02 14:33, Benoît 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 snapshots
> >creation.
> >
> >Signed-off-by: Benoit Canet <benoit@irqsave.net>
> Aside from the misspellings (and regardless of whether you decide to
> move the comment or not):
>
> Reviewed-by: Max Reitz <mreitz@redhat.com>
Thanks, fixed up spelling and formatting and applied to the block
branch.
Kevin
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-10-09 10:22 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-02 12:33 [Qemu-devel] [PATCH V4] disable blkverify external snapshot creation Benoît Canet
2013-10-02 12:33 ` [Qemu-devel] [PATCH V4] block: Add BlockDriver.bdrv_check_ext_snapshot Benoît Canet
2013-10-02 15:30 ` Max Reitz
2013-10-09 10:22 ` Kevin Wolf
2013-10-02 15:33 ` Max Reitz
2013-10-02 15:42 ` Eric Blake
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).