qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/1] block: add block device shared field


From: Brian Steffens
Subject: [Qemu-devel] [PATCH 1/1] block: add block device shared field
Date: Fri, 1 Sep 2017 20:10:54 +0000

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 <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]