|
|
0a122b |
From b5a3f9ac5db568ddfb572d11fb4d6a659c0f5bfa Mon Sep 17 00:00:00 2001
|
|
|
0a122b |
From: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
|
|
|
0a122b |
Date: Wed, 15 Jan 2014 19:42:28 +0100
|
|
|
0a122b |
Subject: [PATCH 02/34] introduce MIG_STATE_CANCELLING state
|
|
|
0a122b |
|
|
|
0a122b |
RH-Author: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
|
|
|
0a122b |
Message-id: <1389814948-3983-3-git-send-email-dgilbert@redhat.com>
|
|
|
0a122b |
Patchwork-id: 56731
|
|
|
0a122b |
O-Subject: [RHEL-7.0 qemu-kvm PATCH 2/2] introduce MIG_STATE_CANCELLING state
|
|
|
0a122b |
Bugzilla: 1053699
|
|
|
0a122b |
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>
|
|
|
0a122b |
RH-Acked-by: Juan Quintela <quintela@redhat.com>
|
|
|
0a122b |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
0a122b |
|
|
|
0a122b |
From: "Zhanghaoyu (A)" <haoyu.zhang@huawei.com>
|
|
|
0a122b |
|
|
|
0a122b |
Introduce MIG_STATE_CANCELLING state to avoid starting a new migration task while the previous one still exist.
|
|
|
0a122b |
|
|
|
0a122b |
Signed-off-by: Zeng Junliang <zengjunliang@huawei.com>
|
|
|
0a122b |
Signed-off-by: Zhang Haoyu <haoyu.zhang@huawei.com>
|
|
|
0a122b |
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
0a122b |
Signed-off-by: Juan Quintela <quintela@redhat.com>
|
|
|
0a122b |
(cherry picked from commit 51cf4c1a99a172679c2949a2d58a2a4ee307b557)
|
|
|
0a122b |
|
|
|
0a122b |
Conflicts:
|
|
|
0a122b |
migration.c
|
|
|
0a122b |
---
|
|
|
0a122b |
migration.c | 26 ++++++++++++++++----------
|
|
|
0a122b |
1 file changed, 16 insertions(+), 10 deletions(-)
|
|
|
0a122b |
|
|
|
0a122b |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
0a122b |
---
|
|
|
0a122b |
migration.c | 26 ++++++++++++++++----------
|
|
|
0a122b |
1 files changed, 16 insertions(+), 10 deletions(-)
|
|
|
0a122b |
|
|
|
0a122b |
diff --git a/migration.c b/migration.c
|
|
|
0a122b |
index 735f7ca..21f7247 100644
|
|
|
0a122b |
--- a/migration.c
|
|
|
0a122b |
+++ b/migration.c
|
|
|
0a122b |
@@ -39,6 +39,7 @@ enum {
|
|
|
0a122b |
MIG_STATE_ERROR = -1,
|
|
|
0a122b |
MIG_STATE_NONE,
|
|
|
0a122b |
MIG_STATE_SETUP,
|
|
|
0a122b |
+ MIG_STATE_CANCELLING,
|
|
|
0a122b |
MIG_STATE_CANCELLED,
|
|
|
0a122b |
MIG_STATE_ACTIVE,
|
|
|
0a122b |
MIG_STATE_COMPLETED,
|
|
|
0a122b |
@@ -194,6 +195,7 @@ MigrationInfo *qmp_query_migrate(Error **errp)
|
|
|
0a122b |
info->has_total_time = false;
|
|
|
0a122b |
break;
|
|
|
0a122b |
case MIG_STATE_ACTIVE:
|
|
|
0a122b |
+ case MIG_STATE_CANCELLING:
|
|
|
0a122b |
info->has_status = true;
|
|
|
0a122b |
info->status = g_strdup("active");
|
|
|
0a122b |
info->has_total_time = true;
|
|
|
0a122b |
@@ -280,6 +282,13 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
|
|
|
0a122b |
|
|
|
0a122b |
/* shared migration helpers */
|
|
|
0a122b |
|
|
|
0a122b |
+static void migrate_set_state(MigrationState *s, int old_state, int new_state)
|
|
|
0a122b |
+{
|
|
|
0a122b |
+ if (atomic_cmpxchg(&s->state, old_state, new_state) == new_state) {
|
|
|
0a122b |
+ trace_migrate_set_state(new_state);
|
|
|
0a122b |
+ }
|
|
|
0a122b |
+}
|
|
|
0a122b |
+
|
|
|
0a122b |
static void migrate_fd_cleanup(void *opaque)
|
|
|
0a122b |
{
|
|
|
0a122b |
MigrationState *s = opaque;
|
|
|
0a122b |
@@ -301,18 +310,14 @@ static void migrate_fd_cleanup(void *opaque)
|
|
|
0a122b |
|
|
|
0a122b |
if (s->state != MIG_STATE_COMPLETED) {
|
|
|
0a122b |
qemu_savevm_state_cancel();
|
|
|
0a122b |
+ if (s->state == MIG_STATE_CANCELLING) {
|
|
|
0a122b |
+ migrate_set_state(s, MIG_STATE_CANCELLING, MIG_STATE_CANCELLED);
|
|
|
0a122b |
+ }
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
notifier_list_notify(&migration_state_notifiers, s);
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
-static void migrate_set_state(MigrationState *s, int old_state, int new_state)
|
|
|
0a122b |
-{
|
|
|
0a122b |
- if (atomic_cmpxchg(&s->state, old_state, new_state) == new_state) {
|
|
|
0a122b |
- trace_migrate_set_state(new_state);
|
|
|
0a122b |
- }
|
|
|
0a122b |
-}
|
|
|
0a122b |
-
|
|
|
0a122b |
void migrate_fd_error(MigrationState *s)
|
|
|
0a122b |
{
|
|
|
0a122b |
DPRINTF("setting error state\n");
|
|
|
0a122b |
@@ -332,8 +337,8 @@ static void migrate_fd_cancel(MigrationState *s)
|
|
|
0a122b |
if (old_state != MIG_STATE_SETUP && old_state != MIG_STATE_ACTIVE) {
|
|
|
0a122b |
break;
|
|
|
0a122b |
}
|
|
|
0a122b |
- migrate_set_state(s, old_state, MIG_STATE_CANCELLED);
|
|
|
0a122b |
- } while (s->state != MIG_STATE_CANCELLED);
|
|
|
0a122b |
+ migrate_set_state(s, old_state, MIG_STATE_CANCELLING);
|
|
|
0a122b |
+ } while (s->state != MIG_STATE_CANCELLING);
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
void add_migration_state_change_notifier(Notifier *notify)
|
|
|
0a122b |
@@ -418,7 +423,8 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
|
|
|
0a122b |
}
|
|
|
0a122b |
#endif
|
|
|
0a122b |
|
|
|
0a122b |
- if (s->state == MIG_STATE_ACTIVE || s->state == MIG_STATE_SETUP) {
|
|
|
0a122b |
+ if (s->state == MIG_STATE_ACTIVE || s->state == MIG_STATE_SETUP ||
|
|
|
0a122b |
+ s->state == MIG_STATE_CANCELLING) {
|
|
|
0a122b |
error_set(errp, QERR_MIGRATION_ACTIVE);
|
|
|
0a122b |
return;
|
|
|
0a122b |
}
|
|
|
0a122b |
--
|
|
|
0a122b |
1.7.1
|
|
|
0a122b |
|