提交 f6844b99 编写于 作者: D Dr. David Alan Gilbert 提交者: Juan Quintela

migration_is_setup_or_active

Add 'migration_is_setup_or_active' utility function to check state.
(It gets postcopy added to it's list later on in the series)
Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: NJuan Quintela <quintela@redhat.com>
Signed-off-by: NJuan Quintela <quintela@redhat.com>
上级 6decec93
...@@ -444,6 +444,23 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) ...@@ -444,6 +444,23 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp)
return params; return params;
} }
/*
* Return true if we're already in the middle of a migration
* (i.e. any of the active or setup states)
*/
static bool migration_is_setup_or_active(int state)
{
switch (state) {
case MIGRATION_STATUS_ACTIVE:
case MIGRATION_STATUS_SETUP:
return true;
default:
return false;
}
}
static void get_xbzrle_cache_stats(MigrationInfo *info) static void get_xbzrle_cache_stats(MigrationInfo *info)
{ {
if (migrate_use_xbzrle()) { if (migrate_use_xbzrle()) {
...@@ -551,8 +568,7 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params, ...@@ -551,8 +568,7 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
MigrationState *s = migrate_get_current(); MigrationState *s = migrate_get_current();
MigrationCapabilityStatusList *cap; MigrationCapabilityStatusList *cap;
if (s->state == MIGRATION_STATUS_ACTIVE || if (migration_is_setup_or_active(s->state)) {
s->state == MIGRATION_STATUS_SETUP) {
error_setg(errp, QERR_MIGRATION_ACTIVE); error_setg(errp, QERR_MIGRATION_ACTIVE);
return; return;
} }
...@@ -682,8 +698,7 @@ static void migrate_fd_cancel(MigrationState *s) ...@@ -682,8 +698,7 @@ static void migrate_fd_cancel(MigrationState *s)
do { do {
old_state = s->state; old_state = s->state;
if (old_state != MIGRATION_STATUS_SETUP && if (!migration_is_setup_or_active(old_state)) {
old_state != MIGRATION_STATUS_ACTIVE) {
break; break;
} }
migrate_set_state(s, old_state, MIGRATION_STATUS_CANCELLING); migrate_set_state(s, old_state, MIGRATION_STATUS_CANCELLING);
...@@ -815,8 +830,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, ...@@ -815,8 +830,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
params.blk = has_blk && blk; params.blk = has_blk && blk;
params.shared = has_inc && inc; params.shared = has_inc && inc;
if (s->state == MIGRATION_STATUS_ACTIVE || if (migration_is_setup_or_active(s->state) ||
s->state == MIGRATION_STATUS_SETUP ||
s->state == MIGRATION_STATUS_CANCELLING) { s->state == MIGRATION_STATUS_CANCELLING) {
error_setg(errp, QERR_MIGRATION_ACTIVE); error_setg(errp, QERR_MIGRATION_ACTIVE);
return; return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册