From: Brian Steffens <briansteffens@gmail.com>
To: qemu-devel@nongnu.org
Cc: Brian Steffens <briansteffens@gmail.com>
Subject: [Qemu-devel] [PATCH 1/1] block: add block device shared field
Date: Fri, 1 Sep 2017 20:10:54 +0000 [thread overview]
Message-ID: <20170901201054.11738-1-briansteffens@gmail.com> (raw)
This adds a boolean option called 'shared' to block devices. It defaults
to off/false. When enabled for a particular block device, the 'shared' option
causes the block migration code to skip over syncing of that device. This
allows controlling exactly which block devices get synced during a migration.
Signed-off-by: Brian Steffens <briansteffens@gmail.com>
---
block.c | 7 +++++++
block/qapi.c | 2 ++
include/block/block.h | 1 +
include/block/block_int.h | 3 +++
migration/block.c | 4 ++++
qapi/block-core.json | 2 +-
6 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/block.c b/block.c
index 3308814bba..6dafcce046 100644
--- a/block.c
+++ b/block.c
@@ -2466,6 +2466,13 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
bdrv_backing_options(&flags, options, flags, options);
}
+ /* Check for shared flag */
+ /* See cautionary note on accessing @options above */
+ bs->shared =
+ g_strcmp0(qdict_get_try_str(options, BDRV_OPT_SHARED), "on") == 0 ||
+ qdict_get_try_bool(options, BDRV_OPT_SHARED, false);
+ qdict_del(options, BDRV_OPT_SHARED);
+
bs->open_flags = flags;
bs->options = options;
options = qdict_clone_shallow(options);
diff --git a/block/qapi.c b/block/qapi.c
index 5f1a71f5d2..42e2a33008 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -66,6 +66,8 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,
info->detect_zeroes = bs->detect_zeroes;
+ info->shared = bs->shared;
+
if (blk && blk_get_public(blk)->throttle_state) {
ThrottleConfig cfg;
diff --git a/include/block/block.h b/include/block/block.h
index ab80195378..8f6ab743d2 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -110,6 +110,7 @@ typedef struct HDGeometry {
#define BDRV_OPT_READ_ONLY "read-only"
#define BDRV_OPT_DISCARD "discard"
#define BDRV_OPT_FORCE_SHARE "force-share"
+#define BDRV_OPT_SHARED "shared"
#define BDRV_SECTOR_BITS 9
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 7571c0aaaf..6508c90ca9 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -672,6 +672,9 @@ struct BlockDriverState {
/* Only read/written by whoever has set active_flush_req to true. */
unsigned int flushed_gen; /* Flushed write generation */
+
+ /* Shared devices are not migrated. */
+ bool shared;
};
struct BlockBackendRootState {
diff --git a/migration/block.c b/migration/block.c
index 9171f60028..b347c3dc61 100644
--- a/migration/block.c
+++ b/migration/block.c
@@ -402,6 +402,10 @@ static int init_blk_migration(QEMUFile *f)
bmds_bs = g_malloc0(num_bs * sizeof(*bmds_bs));
for (i = 0, bs = bdrv_first(&it); bs; bs = bdrv_next(&it), i++) {
+ if (bs->shared) {
+ continue;
+ }
+
if (bdrv_is_read_only(bs)) {
continue;
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 833c602150..a52e10f9cd 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -365,7 +365,7 @@
'*bps_wr_max_length': 'int', '*iops_max_length': 'int',
'*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int',
'*iops_size': 'int', '*group': 'str', 'cache': 'BlockdevCacheInfo',
- 'write_threshold': 'int' } }
+ 'write_threshold': 'int', 'shared': 'bool' } }
##
# @BlockDeviceIoStatus:
--
2.13.1
next reply other threads:[~2017-09-01 20:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-01 20:10 Brian Steffens [this message]
2017-09-01 20:21 ` [Qemu-devel] [PATCH 1/1] block: add block device shared field Eric Blake
2017-09-05 9:56 ` Stefan Hajnoczi
2017-09-05 15:10 ` Brian Steffens
2017-09-06 14:16 ` Stefan Hajnoczi
2017-09-06 5:58 ` Fam Zheng
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=20170901201054.11738-1-briansteffens@gmail.com \
--to=briansteffens@gmail.com \
--cc=qemu-devel@nongnu.org \
/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).