[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 02/49] introduce MIG_STATE_CANCELLING state
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PATCH 02/49] introduce MIG_STATE_CANCELLING state |
Date: |
Mon, 13 Jan 2014 18:39:47 +0100 |
From: "Zhanghaoyu (A)" <address@hidden>
Introduce MIG_STATE_CANCELLING state to avoid starting a new migration task
while the previous one still exist.
Signed-off-by: Zeng Junliang <address@hidden>
Signed-off-by: Zhang Haoyu <address@hidden>
Reviewed-by: Paolo Bonzini <address@hidden>
Signed-off-by: Juan Quintela <address@hidden>
---
migration.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/migration.c b/migration.c
index fd73b97..4ee341b 100644
--- a/migration.c
+++ b/migration.c
@@ -40,6 +40,7 @@ enum {
MIG_STATE_ERROR = -1,
MIG_STATE_NONE,
MIG_STATE_SETUP,
+ MIG_STATE_CANCELLING,
MIG_STATE_CANCELLED,
MIG_STATE_ACTIVE,
MIG_STATE_COMPLETED,
@@ -196,6 +197,7 @@ MigrationInfo *qmp_query_migrate(Error **errp)
info->has_total_time = false;
break;
case MIG_STATE_ACTIVE:
+ case MIG_STATE_CANCELLING:
info->has_status = true;
info->status = g_strdup("active");
info->has_total_time = true;
@@ -282,6 +284,13 @@ void
qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
/* shared migration helpers */
+static void migrate_set_state(MigrationState *s, int old_state, int new_state)
+{
+ if (atomic_cmpxchg(&s->state, old_state, new_state) == new_state) {
+ trace_migrate_set_state(new_state);
+ }
+}
+
static void migrate_fd_cleanup(void *opaque)
{
MigrationState *s = opaque;
@@ -303,18 +312,14 @@ static void migrate_fd_cleanup(void *opaque)
if (s->state != MIG_STATE_COMPLETED) {
qemu_savevm_state_cancel();
+ if (s->state == MIG_STATE_CANCELLING) {
+ migrate_set_state(s, MIG_STATE_CANCELLING, MIG_STATE_CANCELLED);
+ }
}
notifier_list_notify(&migration_state_notifiers, s);
}
-static void migrate_set_state(MigrationState *s, int old_state, int new_state)
-{
- if (atomic_cmpxchg(&s->state, old_state, new_state) == new_state) {
- trace_migrate_set_state(new_state);
- }
-}
-
void migrate_fd_error(MigrationState *s)
{
DPRINTF("setting error state\n");
@@ -334,8 +339,8 @@ static void migrate_fd_cancel(MigrationState *s)
if (old_state != MIG_STATE_SETUP && old_state != MIG_STATE_ACTIVE) {
break;
}
- migrate_set_state(s, old_state, MIG_STATE_CANCELLED);
- } while (s->state != MIG_STATE_CANCELLED);
+ migrate_set_state(s, old_state, MIG_STATE_CANCELLING);
+ } while (s->state != MIG_STATE_CANCELLING);
}
void add_migration_state_change_notifier(Notifier *notify)
@@ -412,7 +417,8 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
params.blk = has_blk && blk;
params.shared = has_inc && inc;
- if (s->state == MIG_STATE_ACTIVE || s->state == MIG_STATE_SETUP) {
+ if (s->state == MIG_STATE_ACTIVE || s->state == MIG_STATE_SETUP ||
+ s->state == MIG_STATE_CANCELLING) {
error_set(errp, QERR_MIGRATION_ACTIVE);
return;
}
--
1.8.4.2
- [Qemu-devel] [PULL 00/49] migration queue, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 01/49] avoid a bogus COMPLETED->CANCELLED transition, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 02/49] introduce MIG_STATE_CANCELLING state,
Juan Quintela <=
- [Qemu-devel] [PATCH 03/49] migration: Fix rate limit, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 05/49] migration: Move QEMU_VM_* defines to migration/migration.h, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 04/49] qemu-file: Make a few functions non-static, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 06/49] savevm: Convert all tabs to spaces, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 08/49] savevm.c: Coding style fix, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 07/49] savevm.c: Coding style fixes, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 11/49] savevm: Small comment about why timer QEMUFile/VMState code is in savevm.c, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 12/49] tests: Some unit tests for vmstate.c, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 10/49] qemu-file: Move QEMUFile code to qemu-file.c, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 09/49] vmstate: Move VMState code to vmstate.c, Juan Quintela, 2014/01/13