[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 21/57] migration_is_setup_or_active
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PULL 21/57] migration_is_setup_or_active |
Date: |
Mon, 9 Nov 2015 18:28:25 +0100 |
From: "Dr. David Alan Gilbert" <address@hidden>
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: Dr. David Alan Gilbert <address@hidden>
Reviewed-by: Juan Quintela <address@hidden>
Signed-off-by: Juan Quintela <address@hidden>
---
migration/migration.c | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index 8380e2f..4317bab 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -444,6 +444,23 @@ MigrationParameters *qmp_query_migrate_parameters(Error
**errp)
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)
{
if (migrate_use_xbzrle()) {
@@ -551,8 +568,7 @@ void
qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
MigrationState *s = migrate_get_current();
MigrationCapabilityStatusList *cap;
- if (s->state == MIGRATION_STATUS_ACTIVE ||
- s->state == MIGRATION_STATUS_SETUP) {
+ if (migration_is_setup_or_active(s->state)) {
error_setg(errp, QERR_MIGRATION_ACTIVE);
return;
}
@@ -682,8 +698,7 @@ static void migrate_fd_cancel(MigrationState *s)
do {
old_state = s->state;
- if (old_state != MIGRATION_STATUS_SETUP &&
- old_state != MIGRATION_STATUS_ACTIVE) {
+ if (!migration_is_setup_or_active(old_state)) {
break;
}
migrate_set_state(s, old_state, MIGRATION_STATUS_CANCELLING);
@@ -815,8 +830,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
params.blk = has_blk && blk;
params.shared = has_inc && inc;
- if (s->state == MIGRATION_STATUS_ACTIVE ||
- s->state == MIGRATION_STATUS_SETUP ||
+ if (migration_is_setup_or_active(s->state) ||
s->state == MIGRATION_STATUS_CANCELLING) {
error_setg(errp, QERR_MIGRATION_ACTIVE);
return;
--
2.5.0
- [Qemu-devel] [PULL 09/57] Add wrapper for setting blocking status on a QEMUFile, (continued)
- [Qemu-devel] [PULL 09/57] Add wrapper for setting blocking status on a QEMUFile, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 11/57] ram_debug_dump_bitmap: Dump a migration bitmap as text, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 12/57] ram_load: Factor out host_from_stream_offset call and check, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 14/57] Rename save_live_complete to save_live_complete_precopy, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 15/57] Add Linux userfaultfd.h header, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 13/57] migrate_init: Call from savevm, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 16/57] Return path: Open a return path on QEMUFile for sockets, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 17/57] Return path: socket_writev_buffer: Block even on non-blocking fd's, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 20/57] Return path: Send responses from destination to source, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 18/57] Migration commands, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 21/57] migration_is_setup_or_active,
Juan Quintela <=
- [Qemu-devel] [PULL 19/57] Return path: Control commands, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 24/57] Add migration-capability boolean for postcopy-ram., Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 22/57] Return path: Source handling of return path, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 25/57] Add wrappers and handlers for sending/receiving the postcopy-ram migration messages., Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 26/57] MIG_CMD_PACKAGED: Send a packaged chunk of migration stream, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 23/57] Rework loadvm path for subloops, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 27/57] Modify save_live_pending for postcopy, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 31/57] MIGRATION_STATUS_POSTCOPY_ACTIVE: Add new migration state, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 28/57] postcopy: OS support test, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 30/57] migration_completion: Take current state, Juan Quintela, 2015/11/09