migration: export fewer options
PATCH 1/1 migration: export fewer options
A small number of migration options are accessed by migration clients, but to see them clients must include all of options.h, which is mostly for migration core code. migrate_mode() in particular will be needed by multiple clients.
Refactor the option declarations so clients can see the necessary few via misc.h, which already exports a portion of the client API.
---
I suggest that eventually we should define a single file migration/client.h which exports everything needed by the simpler clients: blockers, notifiers, options, cpr, and state accessors.
---
--- hw/vfio/migration.c | 1 - hw/virtio/virtio-balloon.c | 1 - include/migration/misc.h | 1 + include/migration/options-pub.h | 24 ++++++++++++++++++++++++ migration/options.h | 6 +----- system/dirtylimit.c | 1 - 6 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 include/migration/options-pub.h
hw/vfio/migration.c +0 -1
@@ -18,7 +18,6 @@#include "sysemu/runstate.h" #include "hw/vfio/vfio-common.h" #include "migration/migration.h" -#include "migration/options.h" #include "migration/savevm.h" #include "migration/vmstate.h" #include "migration/qemu-file.h"
hw/virtio/virtio-balloon.c +0 -1
@@ -32,7 +32,6 @@#include "qemu/error-report.h" #include "migration/misc.h" #include "migration/migration.h" -#include "migration/options.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h"
include/migration/misc.h +1 -0
@@ -17,6 +17,7 @@#include "qemu/notify.h" #include "qapi/qapi-types-migration.h" #include "qapi/qapi-types-net.h" +#include "migration/options-pub.h" /* migration/ram.c */
include/migration/options-pub.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* QEMU public migration capabilities +* +* Copyright (c) 2012-2023 Red Hat Inc +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef QEMU_MIGRATION_OPTIONS_PUB_H +#define QEMU_MIGRATION_OPTIONS_PUB_H + +/* capabilities */ + +bool migrate_background_snapshot (void ); +bool migrate_dirty_limit (void ); +bool migrate_postcopy_ram (void ); +bool migrate_switchover_ack (void ); + +/* parameters */ + +MigMode migrate_mode (void ); + +#endif
migration/options.h +1 -5
@@ -16,6 +16,7 @@#include "hw/qdev-properties.h" #include "hw/qdev-properties-system.h" +#include "migration/options-pub.h" /* migration properties */
@@ -24,12 +25,10 @@ extern Property migration_properties[];/* capabilities */ bool migrate_auto_converge (void ); -bool migrate_background_snapshot (void );bool migrate_block (void );bool migrate_colo (void );bool migrate_compress (void );bool migrate_dirty_bitmaps (void ); -bool migrate_dirty_limit (void );bool migrate_events (void );bool migrate_ignore_shared (void );bool migrate_late_block_activate (void );
@@ -37,11 +36,9 @@ bool migrate_multifd(void);bool migrate_pause_before_switchover (void );bool migrate_postcopy_blocktime (void );bool migrate_postcopy_preempt (void ); -bool migrate_postcopy_ram (void );bool migrate_rdma_pin_all (void );bool migrate_release_ram (void );bool migrate_return_path (void ); -bool migrate_switchover_ack (void );bool migrate_validate_uuid (void );bool migrate_xbzrle (void );bool migrate_zero_blocks (void );
@@ -83,7 +80,6 @@ uint8_t migrate_max_cpu_throttle(void);uint64_t migrate_max_bandwidth (void );uint64_t migrate_avail_switchover_bandwidth (void );uint64_t migrate_max_postcopy_bandwidth (void ); -MigMode migrate_mode (void );int migrate_multifd_channels (void );MultiFDCompression migrate_multifd_compression (void );int migrate_multifd_zlib_level (void );
system/dirtylimit.c +0 -1
@@ -26,7 +26,6 @@#include "trace.h" #include "migration/misc.h" #include "migration/migration.h" -#include "migration/options.h" /* * Dirtylimit stop working if dirty page rate error
Signature · 1 line
1.8.3.1
Quoted 9 lines · Steve Sistare
A small number of migration options are accessed by migration clients, but to see them clients must include all of
options.h, which is mostly for migration core code.migrate_mode()in particular will be needed by multiple clients.Refactor the option declarations so clients can see the necessary few via
misc.h, which already exports a portion of the client API.Signed-off-by Steve Sistare <[email protected]>
Sounds reasonable, queued, thanks.
Quoted 4 lines
---
I suggest that eventually we should define a single filemigration/client.hwhich exports everything needed by the simpler clients: blockers, notifiers, options, cpr, and state accessors.
What's the difference v.s. current migration/misc.h?
Signature · 1 line
Peter Xu
Quoted 11 lines · Peter Xu
Quoted 9 lines · Steve Sistare
A small number of migration options are accessed by migration clients, but to see them clients must include all of
options.h, which is mostly for migration core code.migrate_mode()in particular will be needed by multiple clients.Refactor the option declarations so clients can see the necessary few via
misc.h, which already exports a portion of the client API.Signed-off-by Steve Sistare <[email protected]>
Quoted 8 lines
Sounds reasonable, queued, thanks.
Quoted 4 lines
---
I suggest that eventually we should define a single filemigration/client.hwhich exports everything needed by the simpler clients: blockers, notifiers, options, cpr, and state accessors.What's the difference v.s. current
migration/misc.h?
This file would be sufficient for most clients:
include/migration/client.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef MIGRATION_CLIENT_H +#define MIGRATION_CLIENT_H +#include "migration/misc.h" +#include "migration/blocker.h" +#include "migration/client-options.h" +#endif
Or, we could rename misc.h -> client.h and include blocker.h and client-options.h in it.
I just like the idea that most clients could include a single, obviously named file to use the most-common exported API. "misc.h" is not obvious, and not complete.
- Steve
Quoted 14 lines · Steve Sistare
A small number of migration options are accessed by migration clients, but to see them clients must include all of
options.h, which is mostly for migration core code.migrate_mode()in particular will be needed by multiple clients.Refactor the option declarations so clients can see the necessary few via
misc.h, which already exports a portion of the client API.Signed-off-by Steve Sistare <[email protected]>---
I suggest that eventually we should define a single filemigration/client.hwhich exports everything needed by the simpler clients: blockers, notifiers, options, cpr, and state accessors.
---
Quoted 6 lines
--- hw/vfio/migration.c | 1 - hw/virtio/virtio-balloon.c | 1 - include/migration/misc.h | 1 + include/migration/options-pub.h | 24 ++++++++++++++++++++++++ migration/options.h | 6 +-----
Unusual naming. We have zero headers named -pub.h or -public.h, and dozens named like -int.h or -internal.h. Please stick to the existing convention.
[...]
Quoted 23 lines · Markus Armbruster
Quoted 14 lines · Steve Sistare
A small number of migration options are accessed by migration clients, but to see them clients must include all of
options.h, which is mostly for migration core code.migrate_mode()in particular will be needed by multiple clients.Refactor the option declarations so clients can see the necessary few via
misc.h, which already exports a portion of the client API.Signed-off-by Steve Sistare <[email protected]>---
I suggest that eventually we should define a single filemigration/client.hwhich exports everything needed by the simpler clients: blockers, notifiers, options, cpr, and state accessors.
---Quoted 6 lines
--- hw/vfio/migration.c | 1 - hw/virtio/virtio-balloon.c | 1 - include/migration/misc.h | 1 + include/migration/options-pub.h | 24 ++++++++++++++++++++++++ migration/options.h | 6 +-----
Quoted 3 lines
Unusual naming. We have zero headers named
-pub.hor-public.h, and dozens named like-int.hor-internal.h. Please stick to the existing convention.
In the spirit of minimizing changes, I went that route to avoid renaming the existing migration/options.h and its references:
0 migration/block-dirty-bit 82 #include "options.h"
1 migration/block.c 32 #include "options.h"
2 migration/colo.c 37 #include "options.h"
3 migration/migration-hmp-c 35 #include "options.h"
4 migration/migration.c 68 #include "options.h" 5 migration/multifd-zlib.c 21 #include "options.h" 6 migration/multifd-zstd.c 21 #include "options.h" 7 migration/multifd.c 29 #include "options.h" 8 migration/options.c 30 #include "options.h" 9 migration/postcopy-ram.c 40 #include "options.h" a migration/qemu-file.c 33 #include "options.h" b migration/ram-compress.c 37 #include "options.h" c migration/ram.c 63 #include "options.h" d migration/rdma.c 40 #include "options.h" e migration/savevm.c 71 #include "options.h" f migration/socket.c 30 #include "options.h" g migration/tls.c 25 #include "options.h"
But I take your point.
Peter, which do you prefer?
A. rename: migration/options.h -> migration/options-internal.h
rename: include/migration/options-pub.h -> include/migration/options.h
B. rename: include/migration/options.h -> include/migration/client-options.h
I prefer B. If you prefer B, but want a different file name, please choose the final name.
- Steve
Quoted 49 lines · Steven Sistare
Quoted 23 lines · Markus Armbruster
Quoted 14 lines · Steve Sistare
A small number of migration options are accessed by migration clients, but to see them clients must include all of
options.h, which is mostly for migration core code.migrate_mode()in particular will be needed by multiple clients.Refactor the option declarations so clients can see the necessary few via
misc.h, which already exports a portion of the client API.Signed-off-by Steve Sistare <[email protected]>---
I suggest that eventually we should define a single filemigration/client.hwhich exports everything needed by the simpler clients: blockers, notifiers, options, cpr, and state accessors.
---Quoted 6 lines
--- hw/vfio/migration.c | 1 - hw/virtio/virtio-balloon.c | 1 - include/migration/misc.h | 1 + include/migration/options-pub.h | 24 ++++++++++++++++++++++++ migration/options.h | 6 +-----Quoted 3 lines
Unusual naming. We have zero headers named
-pub.hor-public.h, and dozens named like-int.hor-internal.h. Please stick to the existing convention.In the spirit of minimizing changes, I went that route to avoid renaming the existing
migration/options.hand its references:0 migration/block-dirty-bit 82 #include "
options.h"
1migration/block.c32 #include "options.h"
2migration/colo.c37 #include "options.h"
3 migration/migration-hmp-c 35 #include "options.h"4 migration/migration.c 68 #include "options.h" 5 migration/multifd-zlib.c 21 #include "options.h" 6 migration/multifd-zstd.c 21 #include "options.h" 7 migration/multifd.c 29 #include "options.h" 8 migration/options.c 30 #include "options.h" 9 migration/postcopy-ram.c 40 #include "options.h" a migration/qemu-file.c 33 #include "options.h" b migration/ram-compress.c 37 #include "options.h" c migration/ram.c 63 #include "options.h" d migration/rdma.c 40 #include "options.h" e migration/savevm.c 71 #include "options.h" f migration/socket.c 30 #include "options.h" g migration/tls.c 25 #include "options.h"
Quoted 3 lines
But I take your point.
Peter, which do you prefer?
From statistics, "-internal.h" wins "-int.h":
$ git grep "\-internal.h" | wc -l 135 $ git grep "\-int.h" | wc -l 3
Quoted 8 lines
A. rename:
migration/options.h->migration/options-internal.hrename: include/migration/options-pub.h -> include/migration/options.hB. rename:
include/migration/options.h->include/migration/client-options.hI prefer B. If you prefer B, but want a different file name, please choose the final name.
Personally I don't have a strong opinion on the name. I'll see whether Markus has any comment.
[and of course, I removed this patch from -staging queue to keep the
discussion going..]
Signature · 1 line
Peter Xu
Quoted 52 lines · Peter Xu
Quoted 51 lines · Steven Sistare
Quoted 23 lines · Markus Armbruster
Quoted 14 lines · Steve Sistare
A small number of migration options are accessed by migration clients, but to see them clients must include all of
options.h, which is mostly for migration core code.migrate_mode()in particular will be needed by multiple clients.Refactor the option declarations so clients can see the necessary few via
misc.h, which already exports a portion of the client API.Signed-off-by Steve Sistare <[email protected]>---
I suggest that eventually we should define a single filemigration/client.hwhich exports everything needed by the simpler clients: blockers, notifiers, options, cpr, and state accessors.
---Quoted 6 lines
--- hw/vfio/migration.c | 1 - hw/virtio/virtio-balloon.c | 1 - include/migration/misc.h | 1 + include/migration/options-pub.h | 24 ++++++++++++++++++++++++ migration/options.h | 6 +-----Quoted 3 lines
Unusual naming. We have zero headers named
-pub.hor-public.h, and dozens named like-int.hor-internal.h. Please stick to the existing convention.In the spirit of minimizing changes, I went that route to avoid renaming the existing
migration/options.hand its references:0 migration/block-dirty-bit 82 #include "
options.h"
1migration/block.c32 #include "options.h"
2migration/colo.c37 #include "options.h"
3 migration/migration-hmp-c 35 #include "options.h"4 migration/migration.c 68 #include "options.h" 5 migration/multifd-zlib.c 21 #include "options.h" 6 migration/multifd-zstd.c 21 #include "options.h" 7 migration/multifd.c 29 #include "options.h" 8 migration/options.c 30 #include "options.h" 9 migration/postcopy-ram.c 40 #include "options.h" a migration/qemu-file.c 33 #include "options.h" b migration/ram-compress.c 37 #include "options.h" c migration/ram.c 63 #include "options.h" d migration/rdma.c 40 #include "options.h" e migration/savevm.c 71 #include "options.h" f migration/socket.c 30 #include "options.h" g migration/tls.c 25 #include "options.h"But I take your point.
Quoted 8 lines
Quoted 1 line
Peter, which do you prefer?
From statistics, "
-internal.h" wins "-int.h":$ git grep "\-internal.h" | wc -l 135 $ git grep "\-int.h" | wc -l 3
Yes, I did the same search to choose the name for option A below. But in option B, I keep the existing name for the private file, and choose a new name for the public file. There is no suffix in use in qemu to denote a public file; we just use names indicating the functionality, so I chose client-options.h.
Let's use client-options.h and move on. I am preparing another cleanup series that I think you will like.
- Steve
Quoted 14 lines
Quoted 7 lines
A. rename:
migration/options.h->migration/options-internal.hrename: include/migration/options-pub.h -> include/migration/options.hB. rename:
include/migration/options.h->include/migration/client-options.hI prefer B. If you prefer B, but want a different file name, please choose the final name.
Personally I don't have a strong opinion on the name. I'll see whether Markus has any comment.
[and of course, I removed this patch from -staging queue to keep the
discussion going..]