qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Benoît Canet" <benoit@irqsave.net>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, jcody@redhat.com,
	"Benoît Canet" <benoit@irqsave.net>,
	stefanha@redhat.com
Subject: [Qemu-devel] [PATCH V2] block: Add BlockDriver.bdrv_check_ext_snapshot.
Date: Thu, 26 Sep 2013 16:33:49 +0200	[thread overview]
Message-ID: <1380206029-9740-2-git-send-email-benoit@irqsave.net> (raw)
In-Reply-To: <1380206029-9740-1-git-send-email-benoit@irqsave.net>

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                   | 14 ++++++++++++++
 block/blkverify.c         |  2 ++
 blockdev.c                |  5 +++++
 include/block/block.h     |  7 +++++++
 include/block/block_int.h |  8 ++++++++
 5 files changed, 36 insertions(+)

diff --git a/block.c b/block.c
index 4833b37..4da6fd9 100644
--- a/block.c
+++ b/block.c
@@ -4632,3 +4632,17 @@ int bdrv_amend_options(BlockDriverState *bs, QEMUOptionParameter *options)
     }
     return bs->drv->bdrv_amend_options(bs, options);
 }
+
+bool bdrv_check_ext_snapshot(BlockDriverState *bs)
+{
+    /* external snashots are enabled by defaults */
+    if (!bs->drv->bdrv_check_ext_snapshot) {
+        return true;
+    }
+    return bs->drv->bdrv_check_ext_snapshot(bs);
+}
+
+bool bdrv_forbid_ext_snapshot(BlockDriverState *bs)
+{
+    return false;
+}
diff --git a/block/blkverify.c b/block/blkverify.c
index 2077d8a..c548923 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_forbid_ext_snapshot,
 };
 
 static void bdrv_blkverify_init(void)
diff --git a/blockdev.c b/blockdev.c
index 8aa66a9..5c16f1b 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)) {
+        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..df19610 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -244,6 +244,13 @@ int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix);
 
 int bdrv_amend_options(BlockDriverState *bs_new, QEMUOptionParameter *options);
 
+/* external snapshots */
+
+/* return true if external snapshot is allowed, false if not */
+bool bdrv_check_ext_snapshot(BlockDriverState *bs);
+/* helper used to forbid external snapshots like in blkverify */
+bool bdrv_forbid_ext_snapshot(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..cb92355 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -67,6 +67,14 @@ typedef struct BdrvTrackedRequest {
 struct BlockDriver {
     const char *format_name;
     int instance_size;
+
+    /* if not defined external snapshots are allowed
+     * if return true external snapshots are allowed
+     * if return false external snapshots are not allowed
+     * future block filters will query their children to build the response
+     */
+    bool (*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

  reply	other threads:[~2013-09-26 14:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-26 14:33 [Qemu-devel] [PATCH V2] disable blkverify external snapshot creation Benoît Canet
2013-09-26 14:33 ` Benoît Canet [this message]
2013-09-26 16:48   ` [Qemu-devel] [PATCH V2] block: Add BlockDriver.bdrv_check_ext_snapshot Jeff Cody
2013-09-27  9:52     ` Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1380206029-9740-2-git-send-email-benoit@irqsave.net \
    --to=benoit@irqsave.net \
    --cc=jcody@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).