* [Qemu-devel] [PATCH 1/1] block: add block device shared field
@ 2017-09-01 20:10 Brian Steffens
2017-09-01 20:21 ` Eric Blake
2017-09-05 9:56 ` Stefan Hajnoczi
0 siblings, 2 replies; 6+ messages in thread
From: Brian Steffens @ 2017-09-01 20:10 UTC (permalink / raw)
To: qemu-devel; +Cc: Brian Steffens
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 1/1] block: add block device shared field
2017-09-01 20:10 [Qemu-devel] [PATCH 1/1] block: add block device shared field Brian Steffens
@ 2017-09-01 20:21 ` Eric Blake
2017-09-05 9:56 ` Stefan Hajnoczi
1 sibling, 0 replies; 6+ messages in thread
From: Eric Blake @ 2017-09-01 20:21 UTC (permalink / raw)
To: Brian Steffens, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1504 bytes --]
On 09/01/2017 03:10 PM, Brian Steffens wrote:
> 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(-)
>
> +++ 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' } }
Missing documentation, which should include '(since 2.11)'. The new
parameter should be optional on input; but it looks like you've only
modified a structure that is present on output - so you're missing a
QAPI edit that mirrors the command-line edit.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 1/1] block: add block device shared field
2017-09-01 20:10 [Qemu-devel] [PATCH 1/1] block: add block device shared field Brian Steffens
2017-09-01 20:21 ` Eric Blake
@ 2017-09-05 9:56 ` Stefan Hajnoczi
2017-09-05 15:10 ` Brian Steffens
2017-09-06 5:58 ` Fam Zheng
1 sibling, 2 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2017-09-05 9:56 UTC (permalink / raw)
To: Brian Steffens; +Cc: qemu-devel, Kevin Wolf, Max Reitz, qemu-block
On Fri, Sep 01, 2017 at 08:10:54PM +0000, Brian Steffens wrote:
> 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(-)
Thanks for the patch! Please email the relevant maintainers:
$ scripts/get_maintainer.pl -f block.c
Kevin Wolf <kwolf@redhat.com> (supporter:Block layer core)
Max Reitz <mreitz@redhat.com> (supporter:Block layer core)
qemu-block@nongnu.org (open list:Block layer core)
qemu-devel@nongnu.org (open list:All patches CC here)
I have CCed them so they see this email.
> 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;
> + }
> +
Have you considered extending the 'migrate' command with a list of
drives instead?
{ 'command': 'migrate',
'data': {'*blk': 'bool',
'*drives': ['str'], <--- new!
...}}
That way the set of drives doesn't need to be decided until migration
time. It avoids adding new state to BlockDriverState that is used only
by the legacy block/migration.c code.
In case you haven't seen it, the preferred approach for non-shared
storage migration is drive-mirror + NBD. The block/migration.c code is
an older feature that is less flexible. More info on drive-mirror +
NBD:
http://wiki.libvirt.org/page/NBD_storage_migration
Slide 29 in http://events.linuxfoundation.org/sites/events/files/slides/A-Practical-Look-at-QEMU-Block-Layer-Primitives.pdf
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 1/1] block: add block device shared field
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
1 sibling, 1 reply; 6+ messages in thread
From: Brian Steffens @ 2017-09-05 15:10 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: qemu-devel, Kevin Wolf, Max Reitz, qemu-block
Thanks for taking a look at the patch and fixing the missing CC
addresses!
> Have you considered extending the 'migrate' command with a list of
> drives instead?
That was my original plan but I thought having information on whether a
device is shared or not could potentially be useful to other systems. If
not then you're right, it would be a lighter touch to add it only to the
'migrate' command.
> In case you haven't seen it, the preferred approach for non-shared
> storage migration is drive-mirror + NBD. The block/migration.c code is
> an older feature that is less flexible. More info on drive-mirror +
> NBD:
I didn't realize drive-mirror + NBD was the preferred approach. Are
there any plans to drop support for the block/migration.c style?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 1/1] block: add block device shared field
2017-09-05 9:56 ` Stefan Hajnoczi
2017-09-05 15:10 ` Brian Steffens
@ 2017-09-06 5:58 ` Fam Zheng
1 sibling, 0 replies; 6+ messages in thread
From: Fam Zheng @ 2017-09-06 5:58 UTC (permalink / raw)
To: Brian Steffens, Stefan Hajnoczi
Cc: Kevin Wolf, qemu-devel, qemu-block, Max Reitz
On Tue, 09/05 10:56, Stefan Hajnoczi wrote:
> On Fri, Sep 01, 2017 at 08:10:54PM +0000, Brian Steffens wrote:
> > 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(-)
>
> Thanks for the patch! Please email the relevant maintainers:
>
> $ scripts/get_maintainer.pl -f block.c
> Kevin Wolf <kwolf@redhat.com> (supporter:Block layer core)
> Max Reitz <mreitz@redhat.com> (supporter:Block layer core)
> qemu-block@nongnu.org (open list:Block layer core)
> qemu-devel@nongnu.org (open list:All patches CC here)
>
> I have CCed them so they see this email.
>
> > 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) {
If we go with this approach, I'd prefer a more specific name like
bs->skip_block_migration; "shared" has a lot meanings so is less readable.
Fam
> > + continue;
> > + }
> > +
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 1/1] block: add block device shared field
2017-09-05 15:10 ` Brian Steffens
@ 2017-09-06 14:16 ` Stefan Hajnoczi
0 siblings, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2017-09-06 14:16 UTC (permalink / raw)
To: Brian Steffens; +Cc: qemu-devel, Kevin Wolf, Max Reitz, qemu-block
On Tue, Sep 05, 2017 at 11:10:55AM -0400, Brian Steffens wrote:
> > Have you considered extending the 'migrate' command with a list of
> > drives instead?
>
> That was my original plan but I thought having information on whether a
> device is shared or not could potentially be useful to other systems. If
> not then you're right, it would be a lighter touch to add it only to the
> 'migrate' command.
I agree with Fam that bs->shared doesn't necessarily have the same
meaning to everyone. Therefore I suggest extending the 'migrate'
command instead.
> > In case you haven't seen it, the preferred approach for non-shared
> > storage migration is drive-mirror + NBD. The block/migration.c code is
> > an older feature that is less flexible. More info on drive-mirror +
> > NBD:
>
> I didn't realize drive-mirror + NBD was the preferred approach. Are
> there any plans to drop support for the block/migration.c style?
migration/block.c is not formally deprecated yet. It's still used by
libvirt in situations where NBD connections are not desirable.
Eventually it will probably be deprecated and then removed after 2 more
QEMU releases according to the deprecation policy (see qemu-doc.texi).
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-09-06 14:16 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-01 20:10 [Qemu-devel] [PATCH 1/1] block: add block device shared field Brian Steffens
2017-09-01 20:21 ` 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
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.