Remove old MigrationParams
v5 cover Remove old MigrationParams
Hi
changes from v4:
- Address Markus review
* better documentation messages (thanks)
* reorganize error checking to have small data
* Use g_new0
* Improve commints messages
Please review.
[v4]
- patch 1 included again. We have a 'block' capability and a 'block_incremental' parameter
Make Dave happy: rename shared into incremental Make Eric and Markus happy:
block: off -> no block migration, we don't care about
block_incremental value
block: on block_incremental: off -> no incremental block migration
block: on block_incremental: on -> incremental block migration- Use visitors.
You ask if there is not a better way than hand coding a boolean parser. QAPI people (a.k.a. Markus) answer to use a visitor.
Once there, I used it also for integers, not only booleans.
- Use -b/-i parameters. OK, I bit the bullet: You can't use capabilities/parameters and -b/-i: it gives you one error If you use -b/-i, capability parameter is cleanup after the migration ends (Who would have guessed that there are cases where we call migration_fd_error(), but not migration_fd_cleanup()
I think this should make Peter and Markus and Dave happy.
- Integrate migrate block compile time disabling
Well, it conflicted left and right, so I fixed it
Once there, I disable setting/getting block capability if it is disabled.
[v3]
- Patch 1 included in pull request
- disable block_shared when we disable block_enable
- enable block_enabled when we enable block_shared
[v2]
- make migrate_block_set_* take a boolean
- disable block migration in colo to maintain semantics.
[v1]
Upon a time there were MigrationParms (only used for block migration) and then MigrationParams used for everything else. This series:
- create migration capabilities for block parameters
- make the migrate command line parameters to use capabilities
- remove MigrationParams completely
Dr. David Alan Gilbert (1):
block migration: Allow compile time disable
Juan Quintela (4):
hmp: Use visitor api for hmp_migrate_set_parameter()
migration: Create block capability
migration: Remove use of old MigrationParams
migration: Remove old MigrationParams
configure | 11 +++++ hmp.c | 23 ++++++++-- include/migration/block.h | 24 +++++++++++ include/migration/migration.h | 17 ++++---- include/migration/vmstate.h | 1 - include/qemu/typedefs.h | 1 - include/sysemu/sysemu.h | 3 +- migration/Makefile.objs | 2 +- migration/block.c | 17 +------- migration/colo.c | 6 +-- migration/migration.c | 97 +++++++++++++++++++++++++++++++++++++++---- migration/savevm.c | 24 ++++------- qapi-schema.json | 28 +++++++++++-- 13 files changed, 192 insertions(+), 62 deletions(-)
Signature · 1 line
2.9.3
PATCH v5 1/5 hmp: Use visitor api for hmp_migrate_set_parameter()
We only use it for int64 at this point, I am not able to find a way to parse an int with MiB units.
--- hmp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
hmp.c +6 -4
@@ -29,6 +29,7 @@#include "monitor/qdev.h" #include "qapi/opts-visitor.h" #include "qapi/qmp/qerror.h" +#include "qapi/string-input-visitor.h" #include "qapi/string-output-visitor.h" #include "qapi/util.h" #include "qapi-visit.h"
@@ -1523,8 +1524,9 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) {const char *param =qdict_get_str (qdict,"parameter" );const char *valuestr =qdict_get_str (qdict,"value" ); +Visitor *v =string_input_visitor_new (valuestr);uint64_t valuebw =0 ; -long valueint =0 ; +int64_t valueint =0 ;Error *err =NULL ;bool use_int_value = false;int i, ret;
@@ -1582,9 +1584,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) }if (use_int_value) { -if (qemu_strtol (valuestr,NULL ,10 , &valueint) <0 ) { -error_setg (&err,"Unable to parse '%s' as an int" , - valuestr); +visit_type_int (v, param, &valueint, &err); +if (err) { goto cleanup; }/* Set all integers; only one has_FOO will be set, and
@@ -1608,6 +1609,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) } cleanup: +visit_free (v);if (err) {error_report_err (err); }
Signature · 1 line
2.9.3
PATCH v5 2/5 migration: Create block capability
In reply to Juan QuintelaCreate one capability for block migration and one parameter for incremental block migration.
---
- address all Markus comments
- use Markus and Eric text descriptions
--- hmp.c | 13 ++++++++ include/migration/block.h | 2 ++ include/migration/migration.h | 6 ++++ migration/migration.c | 73 +++++++++++++++++++++++++++++++++++++++++++ qapi-schema.json | 28 +++++++++++++++-- 5 files changed, 119 insertions(+), 3 deletions(-)
hmp.c +13 -0
@@ -326,6 +326,10 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)monitor_printf (mon,"%s: %" PRId64"\n" , MigrationParameter_lookup[MIGRATION_PARAMETER_X_CHECKPOINT_DELAY ], params->x_checkpoint_delay); +assert (params->has_block_incremental); +monitor_printf (mon,"%s: %s\n" , + MigrationParameter_lookup[MIGRATION_PARAMETER_BLOCK_INCREMENTAL ], + params->block_incremental ?"on" :"off" ); }qapi_free_MigrationParameters (params);
@@ -1527,6 +1531,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)Visitor *v =string_input_visitor_new (valuestr);uint64_t valuebw =0 ;int64_t valueint =0 ; +bool valuebool = false;Error *err =NULL ;bool use_int_value = false;int i, ret;
@@ -1581,6 +1586,14 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) p.has_x_checkpoint_delay = true; use_int_value = true;break ; +case MIGRATION_PARAMETER_BLOCK_INCREMENTAL : + p.has_block_incremental = true; +visit_type_bool (v, param, &valuebool, &err); +if (err) { + goto cleanup; + } + p.block_incremental = valuebool; +break ; }if (use_int_value) {
include/migration/block.h +2 -0
@@ -20,4 +20,6 @@ uint64_t blk_mig_bytes_transferred(void);uint64_t blk_mig_bytes_remaining (void );uint64_t blk_mig_bytes_total (void ); +void migrate_set_block_enabled (bool value,Error **errp); +#endif /* MIGRATION_BLOCK_H */
include/migration/migration.h +6 -0
@@ -153,6 +153,9 @@ struct MigrationState/* The last error that occurred */ Error *error; +/* Do we have to clean up -b/-i from old migrate parameters */ +/* This feature is deprecated and will be removed */ +bool must_remove_block_options; };void migrate_set_state (int *state,int old_state,int new_state);
@@ -265,6 +268,9 @@ bool migrate_colo_enabled(void);int64_t xbzrle_cache_resize (int64_t new_size); +bool migrate_use_block (void ); +bool migrate_use_block_incremental (void ); +bool migrate_use_compression (void );int migrate_compress_level (void );int migrate_compress_threads (void );
migration/migration.c +73 -0
121 lines not on this page · raw message
qapi-schema.json +25 -3
@@ -894,11 +894,18 @@ # @release-ram: if enabled, qemu will free the migrated ram pages on the source # during postcopy-ram migration. (since 2.9) # +# @block: If enabled, QEMU will also migrate the contents of all block +# devices. Default is disabled. A possible alternative are +# mirror jobs to a builtin NBD server on the destination, which +# are more flexible. +# (Since 2.10) +# # Since: 1.2 ## { 'enum': 'MigrationCapability', 'data': ['xbzrle', 'rdma-pin-all', 'auto-converge', 'zero-blocks', - 'compress', 'events', 'postcopy-ram', 'x-colo', 'release-ram'] } + 'compress', 'events', 'postcopy-ram', 'x-colo', 'release-ram', + 'block' ] } ## # @MigrationCapabilityStatus:
@@ -1009,13 +1016,20 @@ # @x-checkpoint-delay: The delay time (in ms) between two COLO checkpoints in # periodic mode. (Since 2.8) # +# @block-incremental: Affects how much storage is migrated when the +# block migration capability is enabled. When false, the entire +# storage backing chain is migrated into a flattened image at +# the destination; when true, only the active qcow2 layer is +# migrated and the destination must already have access to the +# same backing chain as was used on the source. (since 2.10) +# # Since: 2.4 ## { 'enum': 'MigrationParameter', 'data': ['compress-level', 'compress-threads', 'decompress-threads', 'cpu-throttle-initial', 'cpu-throttle-increment', 'tls-creds', 'tls-hostname', 'max-bandwidth', - 'downtime-limit', 'x-checkpoint-delay' ] } + 'downtime-limit', 'x-checkpoint-delay', 'block-incremental' ] } ## # @migrate-set-parameters:
@@ -1082,6 +1096,13 @@ # # @x-checkpoint-delay: the delay time between two COLO checkpoints. (Since 2.8) # +# @block-incremental: Affects how much storage is migrated when the +# block migration capability is enabled. When false, the entire +# storage backing chain is migrated into a flattened image at +# the destination; when true, only the active qcow2 layer is +# migrated and the destination must already have access to the +# same backing chain as was used on the source. (since 2.10) +# # Since: 2.4 ## { 'struct': 'MigrationParameters',
@@ -1094,7 +1115,8 @@ '*tls-hostname': 'str', '*max-bandwidth': 'int', '*downtime-limit': 'int', - '*x-checkpoint-delay': 'int'} } + '*x-checkpoint-delay': 'int', + '*block-incremental': 'bool' } } ## # @query-migrate-parameters:
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH 2/5] migration: Create block capability
Quoted 16 lines · Juan Quintela
Create one capability for block migration and one parameter for incremental block migration.
Signed-off-by Juan Quintela <[email protected]>---
migration/migration.c +5
-0@@ -1207,6 +1242,26 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,return ; } +if (((has_blk && blk) || (has_inc && inc)) + && (migrate_use_block () ||migrate_use_block_incremental ())) { +error_setg (errp,"Command options are incompatible with current " +"migration capabilities" ); +return ;
migration/migration.c void qmp_migrate(const char *uri, bool has_blk, bool blk, · line 1259
Quoted 10 lines
migration/migration.c +10
-0+ } + +if ((has_blk && blk) || (has_inc & inc)) { +migrate_set_block_enabled (true, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + } + s->must_remove_block_options = true; + }
You wrote:
if (A && B) {
error;
}
if (A) {
stuff;
}
I might have done:
if (A) {
if (B) {
error; }
stuff;
}
but it's the same either way.
qapi-schema.json line 898
Quoted 7 lines
qapi-schema.json +3
-0+++ b/qapi-schema.json@@ -894,11 +894,18 @@ # @release-ram: if enabled, qemu will free the migrated ram pages on the source # during postcopy-ram migration. (since 2.9) # +# @block: If enabled, QEMU will also migrate the contents of all block +# devices. Default is disabled. A possible alternative are
s/are/uses/
qapi-schema.json line 900
Quoted 2 lines
qapi-schema.json +2
-0+# mirror jobs to a builtin NBD server on the destination, which +# are more flexible.
s/are more flexible/offers more flexibility/
qapi-schema.json line 909
Quoted 10 lines
qapi-schema.json +4
-1+# (Since 2.10) +# # Since: 1.2 ## { 'enum': 'MigrationCapability', 'data': ['xbzrle', 'rdma-pin-all', 'auto-converge', 'zero-blocks', - 'compress', 'events', 'postcopy-ram', 'x-colo', 'release-ram'] } + 'compress', 'events', 'postcopy-ram', 'x-colo', 'release-ram', + 'block' ] }
The grammar touchups can be done in preparing the pull request, if there is no other reason for a respin.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PATCH 2/5] migration: Create block capability
Quoted 38 lines · Eric Blake
Quoted 16 lines · Juan Quintela
Create one capability for block migration and one parameter for incremental block migration.
Signed-off-by Juan Quintela <[email protected]>---
migration/migration.c +5
-0@@ -1207,6 +1242,26 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,return ; } +if (((has_blk && blk) || (has_inc && inc)) + && (migrate_use_block () ||migrate_use_block_incremental ())) { +error_setg (errp,"Command options are incompatible with current " +"migration capabilities" ); +return ;migration/migration.c void qmp_migrate(const char *uri, bool has_blk, bool blk, · line 1259
Quoted 10 lines
migration/migration.c +10
-0+ } + +if ((has_blk && blk) || (has_inc & inc)) { +migrate_set_block_enabled (true, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + } + s->must_remove_block_options = true; + }You wrote:
if (A && B) {
error;
}
if (A) {
stuff;
}I might have done:
Quoted 8 lines
if (A) {
if (B) { error;}
stuff;
}but it's the same either way.
One less line, and as I have to respin due to the last patch.
Quoted 9 lines
qapi-schema.json line 898
Quoted 7 lines
qapi-schema.json +3
-0+++ b/qapi-schema.json@@ -894,11 +894,18 @@ # @release-ram: if enabled, qemu will free the migrated ram pages on the source # during postcopy-ram migration. (since 2.9) # +# @block: If enabled, QEMU will also migrate the contents of all block +# devices. Default is disabled. A possible alternative ares/are/uses/
done
Quoted 4 lines
qapi-schema.json line 900
Quoted 2 lines
qapi-schema.json +2
-0+# mirror jobs to a builtin NBD server on the destination, which +# are more flexible.s/are more flexible/offers more flexibility/
done
Quoted 14 lines
qapi-schema.json line 909
Quoted 10 lines
qapi-schema.json +4
-1+# (Since 2.10) +# # Since: 1.2 ## { 'enum': 'MigrationCapability', 'data': ['xbzrle', 'rdma-pin-all', 'auto-converge', 'zero-blocks', - 'compress', 'events', 'postcopy-ram', 'x-colo', 'release-ram'] } + 'compress', 'events', 'postcopy-ram', 'x-colo', 'release-ram', + 'block' ] }The grammar touchups can be done in preparing the pull request, if there is no other reason for a respin.
Quoted 1 line
Reviewed-by Eric Blake <[email protected]>
Thanks, Juan.
PATCH v5 3/5 migration: Remove use of old MigrationParams
In reply to Juan QuintelaWe have change in the previous patch to use migration capabilities for it. Notice that we continue using the old command line flags from migrate command from the time being. Remove the set_params method as now it is empty.
For savevm, one can't do a:
savevm -b/-i foo
but now one can do:
migrate_set_capability block on
savevm foo
And we can't use block migration. We could disable block capability unconditionally, but it would not be much better.
---
- Maintain shared/enabled dependency (Xu suggestion)
- Now we maintain the dependency on the setter functions
- improve error messages
--- include/migration/migration.h | 3 +-- migration/block.c | 17 ++--------------- migration/colo.c | 4 ++-- migration/migration.c | 3 --- migration/savevm.c | 8 ++++++-- 5 files changed, 11 insertions(+), 24 deletions(-)
include/migration/migration.h +1 -2
@@ -39,8 +39,7 @@#define QEMU_VM_SECTION_FOOTER 0x7estruct MigrationParams { -bool blk; -bool shared; +bool unused;/* C doesn't allow empty structs */ };/* Messages sent on the return path from destination to source */
migration/block.c +2 -15
@@ -94,9 +94,6 @@ typedef struct BlkMigBlock { } BlkMigBlock; typedef struct BlkMigState { - /* Written during setup phase. Can be read without a lock. */ - int blk_enable; - int shared_base; QSIMPLEQ_HEAD(bmds_list, BlkMigDevState) bmds_list; int64_t total_sector_sum; bool zero_blocks;
@@ -425,7 +422,7 @@ static int init_blk_migration(QEMUFile *f) bmds->bulk_completed =0 ; bmds->total_sectors = sectors; bmds->completed_sectors =0 ; - bmds->shared_base = block_mig_state.shared_base; + bmds->shared_base =migrate_use_block_incremental ();assert (i < num_bs); bmds_bs[i].bmds = bmds;
@@ -994,22 +991,12 @@ static int block_load(QEMUFile *f, void *opaque, int version_id)return 0 ; } -static void block_set_params (const MigrationParams *params,void *opaque) -{ - block_mig_state.blk_enable = params->blk; - block_mig_state.shared_base = params->shared; - -/* shared base means that blk_enable = 1 */ - block_mig_state.blk_enable |= params->shared; -} -static bool block_is_active (void *opaque) { -return block_mig_state.blk_enable ==1 ; +return migrate_use_block (); }static SaveVMHandlers savevm_block_handlers = { - .set_params = block_set_params, .save_live_setup = block_save_setup, .save_live_iterate = block_save_iterate, .save_live_complete_precopy = block_save_complete,
migration/colo.c +2 -2
@@ -14,6 +14,7 @@#include "qemu/timer.h" #include "sysemu/sysemu.h" #include "migration/colo.h" +#include "migration/block.h" #include "io/channel-buffer.h" #include "trace.h" #include "qemu/error-report.h"
@@ -345,8 +346,7 @@ static int colo_do_checkpoint_transaction(MigrationState *s, }/* Disable block migration */ - s->params.blk =0 ; - s->params.shared =0 ; +migrate_set_block_enabled (false, &local_err);qemu_savevm_state_header (fb);qemu_savevm_state_begin (fb, &s->params);qemu_mutex_lock_iothread ();
migration/migration.c +0 -3
@@ -1224,9 +1224,6 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,MigrationParams params;const char *p; - params.blk = has_blk && blk; - params.shared = has_inc && inc; -if (migration_is_setup_or_active (s->state) || s->state ==MIGRATION_STATUS_CANCELLING || s->state ==MIGRATION_STATUS_COLO ) {
migration/savevm.c +6 -2
@@ -1233,8 +1233,6 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp) {int ret;MigrationParams params = { - .blk =0 , - .shared =0 };MigrationState *ms =migrate_init (¶ms);MigrationStatus status;
@@ -1245,6 +1243,12 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp) goto done; } +if (migrate_use_block ()) { +error_setg (errp,"Block migration and snapshots are incompatible" ); + ret = -EINVAL ; + goto done; + } +qemu_mutex_unlock_iothread ();qemu_savevm_state_header (f);qemu_savevm_state_begin (f, ¶ms);
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH 3/5] migration: Remove use of old MigrationParams
Quoted 17 lines · Juan Quintela
We have change in the previous patch to use migration capabilities for it. Notice that we continue using the old command line flags from migrate command from the time being. Remove the
set_paramsmethod as now it is empty.For savevm, one can't do a:
savevm -b/-i foo
but now one can do:
migrate_set_capabilityblock on
savevm fooAnd we can't use block migration. We could disable block capability unconditionally, but it would not be much better.
Quoted 8 lines
Signed-off-by Juan Quintela <[email protected]>---
- Maintain shared/enabled dependency (Xu suggestion)
- Now we maintain the dependency on the setter functions
- improve error messagesSigned-off-by Juan Quintela <[email protected]>
This second S-o-b gets stripped, but the one that counts is in place (I've made the same mistake before, as well - doing 'git commit --amend -s' on a commit where I already had a --- separator)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PATCH 3/5] migration: Remove use of old MigrationParams
Quoted 25 lines · Eric Blake
Quoted 24 lines · Juan Quintela
We have change in the previous patch to use migration capabilities for it. Notice that we continue using the old command line flags from migrate command from the time being. Remove the
set_paramsmethod as now it is empty.For savevm, one can't do a:
savevm -b/-i foo
but now one can do:
migrate_set_capabilityblock on
savevm fooAnd we can't use block migration. We could disable block capability unconditionally, but it would not be much better.
Signed-off-by Juan Quintela <[email protected]>---
- Maintain shared/enabled dependency (Xu suggestion)
- Now we maintain the dependency on the setter functions
- improve error messages
Quoted 5 lines
Quoted 1 line
Signed-off-by Juan Quintela <[email protected]>This second S-o-b gets stripped, but the one that counts is in place (I've made the same mistake before, as well - doing 'git commit --amend -s' on a commit where I already had a --- separator)
And this time I *really* remove the -s from my git-format-patch alias. I dropped that last week on the terminal, rebooted the machine and ..... magic ... got the old alias O:-)
Quoted 1 line
Reviewed-by Eric Blake <[email protected]>
Thanks
Re: [Qemu-devel] [PATCH 3/5] migration: Remove use of old MigrationParams
In reply to Juan QuintelaQuoted 3 lines · Juan Quintela
We have change in the previous patch to use migration capabilities for it. Notice that we continue using the old command line flags from migrate command from the time being. Remove the
set_paramsmethod as
for the time being
Quoted 6 lines
now it is empty.
For savevm, one can't do a:
savevm -b/-i foo
Quoted 7 lines
but now one can do:
migrate_set_capabilityblock on
savevm fooAnd we can't use block migration. We could disable block capability unconditionally, but it would not be much better.
I think I get what you're trying to say, but only because I have plenty of context right now. Let me try to rephrase:
migration: Use new configuration instead of old MigrationParams
The previous commit introduced a MigrationCapability and a MigrationParameter for block migration. Use them instead of the old MigrationParams.
Take care to reject attempts to combine block migration with snapshots, e.g. like this:
migrate_set_capability block on
savevm foo
Quoted 1 line
Signed-off-by Juan Quintela <[email protected]>
Preferably with a commit message I can still understand three weeks from now:
Re: [Qemu-devel] [PATCH 3/5] migration: Remove use of old MigrationParams
I got confused and replied to an old version. Please ignore.
Quoted 42 lines · Markus Armbruster
Quoted 3 lines · Juan Quintela
We have change in the previous patch to use migration capabilities for it. Notice that we continue using the old command line flags from migrate command from the time being. Remove the
set_paramsmethod asfor the time being
Quoted 6 lines
now it is empty.
For savevm, one can't do a:
savevm -b/-i foo
Quoted 7 lines
but now one can do:
migrate_set_capabilityblock on
savevm fooAnd we can't use block migration. We could disable block capability unconditionally, but it would not be much better.
I think I get what you're trying to say, but only because I have plenty of context right now. Let me try to rephrase:
migration: Use new configuration instead of old MigrationParams
The previous commit introduced a MigrationCapability and a MigrationParameter for block migration. Use them instead of the old MigrationParams.
Take care to reject attempts to combine block migration with snapshots, e.g. like this:
migrate_set_capabilityblock on
savevm fooQuoted 1 line
Signed-off-by Juan Quintela <[email protected]>Preferably with a commit message I can still understand three weeks from now:
Reviewed-by Markus Armbruster <[email protected]>
PATCH v5 4/5 migration: Remove old MigrationParams
In reply to Juan QuintelaNot used anymore after moving block migration to use capabilities.
--- include/migration/migration.h | 10 ++-------- include/migration/vmstate.h | 1 - include/qemu/typedefs.h | 1 - include/sysemu/sysemu.h | 3 +-- migration/colo.c | 2 +- migration/migration.c | 8 +++----- migration/savevm.c | 16 +++------------- 7 files changed, 10 insertions(+), 31 deletions(-)
include/migration/migration.h +2 -8
@@ -38,10 +38,6 @@#define QEMU_VM_COMMAND 0x08#define QEMU_VM_SECTION_FOOTER 0x7e -struct MigrationParams { -bool unused;/* C doesn't allow empty structs */ -}; -/* Messages sent on the return path from destination to source */ enum mig_rp_message_type {MIG_RP_MSG_INVALID =0 ,/* Must be 0 */
@@ -109,12 +105,10 @@ struct MigrationStateQEMUBH *cleanup_bh;QEMUFile *to_dst_file; -/* New style params from 'migrate-set-parameters' */ +/* params from 'migrate-set-parameters' */ MigrationParameters parameters;int state; -/* Old style params from 'migrate' command */ -MigrationParams params;/* State related to return path */ struct {
@@ -207,7 +201,7 @@ void migrate_fd_connect(MigrationState *s);void add_migration_state_change_notifier (Notifier *notify);void remove_migration_state_change_notifier (Notifier *notify); -MigrationState *migrate_init (const MigrationParams *params); +MigrationState *migrate_init (void );bool migration_is_blocked (Error **errp);bool migration_in_setup (MigrationState *);bool migration_is_idle (void );
include/migration/vmstate.h +0 -1
@@ -37,7 +37,6 @@ typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id); typedef struct SaveVMHandlers { /* This runs inside the iothread lock. */ - void (*set_params)(const MigrationParams *params, void * opaque); SaveStateHandler *save_state; void (*cleanup)(void *opaque);
include/qemu/typedefs.h +0 -1
@@ -49,7 +49,6 @@ typedef struct MemoryRegion MemoryRegion;typedef struct MemoryRegionCache MemoryRegionCache ;typedef struct MemoryRegionSection MemoryRegionSection ;typedef struct MigrationIncomingState MigrationIncomingState ; -typedef struct MigrationParams MigrationParams ;typedef struct MigrationState MigrationState ;typedef struct Monitor Monitor ;typedef struct MonitorDef MonitorDef ;
include/sysemu/sysemu.h +1 -2
@@ -102,8 +102,7 @@ enum qemu_vm_cmd {#define MAX_VM_CMD_PACKAGED_SIZE (1ul << 24)bool qemu_savevm_state_blocked (Error **errp); -void qemu_savevm_state_begin (QEMUFile *f, -const MigrationParams *params); +void qemu_savevm_state_begin (QEMUFile *f);void qemu_savevm_state_header (QEMUFile *f);int qemu_savevm_state_iterate (QEMUFile *f,bool postcopy);void qemu_savevm_state_cleanup (void );
migration/colo.c +1 -1
@@ -348,7 +348,7 @@ static int colo_do_checkpoint_transaction(MigrationState *s,/* Disable block migration */ migrate_set_block_enabled (false, &local_err);qemu_savevm_state_header (fb); -qemu_savevm_state_begin (fb, &s->params); +qemu_savevm_state_begin (fb);qemu_mutex_lock_iothread ();qemu_savevm_state_complete_precopy (fb, false);qemu_mutex_unlock_iothread ();
migration/migration.c +3 -5
@@ -1118,7 +1118,7 @@ bool migration_is_idle(void)return false; } -MigrationState *migrate_init (const MigrationParams *params) +MigrationState *migrate_init (void ) {MigrationState *s =migrate_get_current ();
@@ -1132,7 +1132,6 @@ MigrationState *migrate_init(const MigrationParams *params) s->cleanup_bh =0 ; s->to_dst_file =NULL ; s->state =MIGRATION_STATUS_NONE ; - s->params = *params; s->rp_state.from_dst_file =NULL ; s->rp_state.error = false; s->mbps =0.0 ;
@@ -1221,7 +1220,6 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, {Error *local_err =NULL ;MigrationState *s =migrate_get_current (); -MigrationParams params;const char *p; if (migration_is_setup_or_active(s->state) ||
@@ -1259,7 +1257,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,migrate_set_block_incremental (s, true); } - s =migrate_init (¶ms); + s =migrate_init ();if (strstart (uri,"tcp:" , &p)) {tcp_start_outgoing_migration (s, p, &local_err);
@@ -1983,7 +1981,7 @@ static void *migration_thread(void *opaque)qemu_savevm_send_postcopy_advise (s->to_dst_file); } -qemu_savevm_state_begin (s->to_dst_file, &s->params); +qemu_savevm_state_begin (s->to_dst_file); s->setup_time =qemu_clock_get_ms (QEMU_CLOCK_HOST ) - setup_start; migrate_set_state(&s->state, MIGRATION_STATUS_SETUP,
migration/savevm.c +3 -13
@@ -966,21 +966,13 @@ void qemu_savevm_state_header(QEMUFile *f) } -void qemu_savevm_state_begin (QEMUFile *f, -const MigrationParams *params) +void qemu_savevm_state_begin (QEMUFile *f) {SaveStateEntry *se;int ret;trace_savevm_state_begin (); QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { -if (!se->ops || !se->ops->set_params) { -continue ; - } - se->ops->set_params (params, se->opaque); - } - - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {if (!se->ops || !se->ops->save_live_setup) {continue ; }
@@ -1232,9 +1224,7 @@ void qemu_savevm_state_cleanup(void)static int qemu_savevm_state (QEMUFile *f,Error **errp) {int ret; -MigrationParams params = { - }; -MigrationState *ms =migrate_init (¶ms); +MigrationState *ms =migrate_init ();MigrationStatus status; ms->to_dst_file = f;
@@ -1251,7 +1241,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)qemu_mutex_unlock_iothread ();qemu_savevm_state_header (f); -qemu_savevm_state_begin (f, ¶ms); +qemu_savevm_state_begin (f);qemu_mutex_lock_iothread ();while (qemu_file_get_error (f) ==0 ) {
Signature · 1 line
2.9.3
PATCH v5 5/5 block migration: Allow compile time disable
In reply to Juan QuintelaFrom: "Dr. David Alan Gilbert" <[email protected]>
Many users now prefer to use drive_mirror over NBD as an alternative to the older migrate -b option; drive_mirror is more complex to setup but gives you more options (e.g. only migrating some of the disks if some of them are shared).
Allow the large chunk of block migration code to be compiled out for those who don't use it.
Based on a downstream-patch we've had for a while by Jeff Cody.
--- configure | 11 +++++++++++ include/migration/block.h | 24 +++++++++++++++++++++++- migration/Makefile.objs | 2 +- migration/migration.c | 13 +++++++++++++ 4 files changed, 48 insertions(+), 2 deletions(-)
configure +11 -0
@@ -316,6 +316,7 @@ vte="" virglrenderer="" tpm="yes" libssh2="" +live_block_migration="yes" numa="" tcmalloc="no" jemalloc="no"
@@ -1169,6 +1170,10 @@ for opt do ;; --enable-libssh2) libssh2="yes" ;; + --disable-live-block-migration) live_block_migration="no" + ;; + --enable-live-block-migration) live_block_migration="yes" + ;; --disable-numa) numa="no" ;; --enable-numa) numa="yes"
@@ -1401,6 +1406,7 @@ disabled with --disable-FEATURE, default is enabled if available: libnfs nfs support smartcard smartcard support (libcacard) libusb libusb (for usb passthrough) + live-block-migration Block migration in the main migration stream usb-redir usb network redirection support lzo support of lzo compression library snappy support of snappy compression library
@@ -5216,6 +5222,7 @@ echo "TPM support $tpm" echo "libssh2 support $libssh2" echo "TPM passthrough $tpm_passthrough" echo "QOM debugging $qom_cast_debug" +echo "Live block migration $live_block_migration" echo "lzo support $lzo" echo "snappy support $snappy" echo "bzip2 support $bzip2"
@@ -5782,6 +5789,10 @@ if test "$libssh2" = "yes" ; then echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak fi +if test "$live_block_migration" = "yes" ; then + echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak +fi + # USB host support if test "$libusb" = "yes"; then echo "HOST_USB=libusb legacy" >> $config_host_mak
include/migration/block.h +23 -1
@@ -14,12 +14,34 @@#ifndef MIGRATION_BLOCK_H #define MIGRATION_BLOCK_H +#ifdef CONFIG_LIVE_BLOCK_MIGRATION void blk_mig_init (void );int blk_mig_active (void );uint64_t blk_mig_bytes_transferred (void );uint64_t blk_mig_bytes_remaining (void );uint64_t blk_mig_bytes_total (void ); +#else +static inline void blk_mig_init (void ) { } +static inline int blk_mig_active (void ) +{ +return false; +} +static inline uint64_t blk_mig_bytes_transferred (void ) +{ +return 0 ; +} + +static inline uint64_t blk_mig_bytes_remaining (void ) +{ +return 0 ; +} + +static inline uint64_t blk_mig_bytes_total (void ) +{ +return 0 ; +} +#endif /* CONFIG_LIVE_BLOCK_MIGRATION */ +void migrate_set_block_enabled (bool value,Error **errp); -#endif /* MIGRATION_BLOCK_H */
migration/Makefile.objs +1 -1
@@ -9,5 +9,5 @@ common-obj-y += qjson.o common-obj-$(CONFIG_RDMA) += rdma.o -common-obj-y += block.o +common-obj-$(CONFIG_LIVE_BLOCK_MIGRATION) += block.o
migration/migration.c +13 -0
@@ -547,6 +547,11 @@ MigrationCapabilityStatusList *qmp_query_migrate_capabilities(Error **errp) caps =NULL ;/* silence compiler warning */ for (i =0 ; i <MIGRATION_CAPABILITY__MAX ; i++) { +#ifndef CONFIG_LIVE_BLOCK_MIGRATION +if (i ==MIGRATION_CAPABILITY_BLOCK ) { +continue ; + } +#endif if (i ==MIGRATION_CAPABILITY_X_COLO && !colo_supported ()) {continue ; }
@@ -763,6 +768,14 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params, }for (cap = params; cap; cap = cap->next) { +#ifndef CONFIG_LIVE_BLOCK_MIGRATION +if (cap->value->capability ==MIGRATION_CAPABILITY_BLOCK ) { +error_setg (errp,"QEMU compiled without old-style (blk/-b, inc/-i) " +"block migration" ); +error_append_hint (errp,"Use drive_mirror+NBD instead.\n" ); +continue ; + } +#endif if (cap->value->capability ==MIGRATION_CAPABILITY_X_COLO ) {if (!colo_supported ()) { error_setg(errp, "COLO is not currently supported, please"
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH 5/5] block migration: Allow compile time disable
Quoted 23 lines · Juan Quintela
From: "Dr. David Alan Gilbert" <[email protected]>
Many users now prefer to use
drive_mirrorover NBD as an alternative to the older migrate -b option;drive_mirroris more complex to setup but gives you more options (e.g. only migrating some of the disks if some of them are shared).Allow the large chunk of block migration code to be compiled out for those who don't use it.
Based on a downstream-patch we've had for a while by Jeff Cody.
Signed-off-by Dr. David Alan Gilbert <[email protected]>Signed-off-by Juan Quintela <[email protected]>--- configure | 11 +++++++++++ include/migration/block.h | 24 +++++++++++++++++++++++- migration/Makefile.objs | 2 +- migration/migration.c | 13 +++++++++++++ 4 files changed, 48 insertions(+), 2 deletions(-)migration/migration.c +0
-0@@ -763,6 +768,14 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params, }
migration/migration.c void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params, · line 778
Quoted 10 lines
migration/migration.c +8
-0for (cap = params; cap; cap = cap->next) { +#ifndef CONFIG_LIVE_BLOCK_MIGRATION +if (cap->value->capability ==MIGRATION_CAPABILITY_BLOCK ) { +error_setg (errp,"QEMU compiled without old-style (blk/-b, inc/-i) " +"block migration" ); +error_append_hint (errp,"Use drive_mirror+NBD instead.\n" ); +continue ; + } +#endif
If I'm not mistaken, this will cause an unconditional error even if I do the QMP { "command":"migrate", "arguments":{"uri":"...", "blk":false} }
Wouldn't it be better to make the conditional:
if (cap->value->capability == MIGRATION_CAPABILITY_BLOCK && cap->value->state) {
so that I can pass an explicit false, and the error only happens when trying to set the optional parameter to true? I ask, because libvirt (currently) ALWAYS passes the "inc" and "blk" QMP parameters, but generally to an explicit false when it uses NBD+mirror.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org