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