qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] migration: Fix possible bug for migrate cancel
@ 2014-03-24 13:04 arei.gonglei
  2014-03-24 14:14 ` Eric Blake
  2014-03-24 15:47 ` Paolo Bonzini
  0 siblings, 2 replies; 9+ messages in thread
From: arei.gonglei @ 2014-03-24 13:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: quintela, yanqiangjun, lefty.zhao, owasserm, Gonglei,
	zengjunliang, pbonzini

From: zengjunliang <zengjunliang@huawei.com>

Return error for migrate cancel, when migration status is not
MIG_STATE_SETUP or MIG_STATE_ACTIVE. Thus, libvirt can can
perceive the operation fails.

Signed-off-by: zengjunliang <zengjunliang@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 include/qapi/qmp/qerror.h | 3 +++
 migration.c               | 5 +++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index da75abf..b13e3e0 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -164,6 +164,9 @@ void qerror_report_err(Error *err);
 #define QERR_MIGRATION_ACTIVE \
     ERROR_CLASS_GENERIC_ERROR, "There's a migration process in progress"
 
+#define QERR_MIGRATION_COMPLETED \
+    ERROR_CLASS_GENERIC_ERROR, "There's no migration process in progress"
+
 #define QERR_MIGRATION_NOT_SUPPORTED \
     ERROR_CLASS_GENERIC_ERROR, "State blocked by non-migratable device '%s'"
 
diff --git a/migration.c b/migration.c
index e0e24d4..2f34c67 100644
--- a/migration.c
+++ b/migration.c
@@ -336,7 +336,7 @@ void migrate_fd_error(MigrationState *s)
     notifier_list_notify(&migration_state_notifiers, s);
 }
 
-static void migrate_fd_cancel(MigrationState *s)
+static void migrate_fd_cancel(MigrationState *s, Error **errp)
 {
     int old_state ;
     DPRINTF("cancelling migration\n");
@@ -344,6 +344,7 @@ static void migrate_fd_cancel(MigrationState *s)
     do {
         old_state = s->state;
         if (old_state != MIG_STATE_SETUP && old_state != MIG_STATE_ACTIVE) {
+            error_set(errp, QERR_MIGRATION_COMPLETED);
             break;
         }
         migrate_set_state(s, old_state, MIG_STATE_CANCELLING);
@@ -470,7 +471,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
 
 void qmp_migrate_cancel(Error **errp)
 {
-    migrate_fd_cancel(migrate_get_current());
+    migrate_fd_cancel(migrate_get_current(), errp);
 }
 
 void qmp_migrate_set_cache_size(int64_t value, Error **errp)
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-03-28 12:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-24 13:04 [Qemu-devel] [PATCH] migration: Fix possible bug for migrate cancel arei.gonglei
2014-03-24 14:14 ` Eric Blake
2014-03-24 15:47 ` Paolo Bonzini
2014-03-24 16:00   ` Eric Blake
2014-03-25 11:15     ` Gonglei (Arei)
2014-03-28  9:18     ` Gonglei (Arei)
2014-03-28  9:28       ` Paolo Bonzini
2014-03-28 11:30         ` Dr. David Alan Gilbert
2014-03-28 12:16           ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).