From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 1/8] add migration state change notifiers
Date: Mon, 24 Jan 2011 17:20:42 +0100 [thread overview]
Message-ID: <1295886049-30548-2-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1295886049-30548-1-git-send-email-kraxel@redhat.com>
This patch adds functions to register and unregister notifiers for
migration state changes and a function to query the migration state.
The notifier is called on every state change. Once after establishing a
new migration object (which is in active state then) and once when the
state changes from active to completed, canceled or error.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
migration.c | 28 ++++++++++++++++++++++++++++
migration.h | 5 +++++
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/migration.c b/migration.c
index d593b1d..3612572 100644
--- a/migration.c
+++ b/migration.c
@@ -36,6 +36,9 @@ static int64_t max_throttle = (32 << 20);
static MigrationState *current_migration;
+static NotifierList migration_state_notifiers =
+ NOTIFIER_LIST_INITIALIZER(migration_state_notifiers);
+
int qemu_start_incoming_migration(const char *uri)
{
const char *p;
@@ -121,6 +124,7 @@ int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
}
current_migration = s;
+ notifier_list_notify(&migration_state_notifiers);
return 0;
}
@@ -272,6 +276,7 @@ void migrate_fd_error(FdMigrationState *s)
{
DPRINTF("setting error state\n");
s->state = MIG_STATE_ERROR;
+ notifier_list_notify(&migration_state_notifiers);
migrate_fd_cleanup(s);
}
@@ -329,6 +334,7 @@ ssize_t migrate_fd_put_buffer(void *opaque, const void *data, size_t size)
monitor_resume(s->mon);
}
s->state = MIG_STATE_ERROR;
+ notifier_list_notify(&migration_state_notifiers);
}
return ret;
@@ -389,6 +395,7 @@ void migrate_fd_put_ready(void *opaque)
state = MIG_STATE_ERROR;
}
s->state = state;
+ notifier_list_notify(&migration_state_notifiers);
}
}
@@ -408,6 +415,7 @@ void migrate_fd_cancel(MigrationState *mig_state)
DPRINTF("cancelling migration\n");
s->state = MIG_STATE_CANCELLED;
+ notifier_list_notify(&migration_state_notifiers);
qemu_savevm_state_cancel(s->mon, s->file);
migrate_fd_cleanup(s);
@@ -421,6 +429,7 @@ void migrate_fd_release(MigrationState *mig_state)
if (s->state == MIG_STATE_ACTIVE) {
s->state = MIG_STATE_CANCELLED;
+ notifier_list_notify(&migration_state_notifiers);
migrate_fd_cleanup(s);
}
qemu_free(s);
@@ -452,3 +461,22 @@ int migrate_fd_close(void *opaque)
qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
return s->close(s);
}
+
+void add_migration_state_change_notifier(Notifier *notify)
+{
+ notifier_list_add(&migration_state_notifiers, notify);
+}
+
+void remove_migration_state_change_notifier(Notifier *notify)
+{
+ notifier_list_remove(&migration_state_notifiers, notify);
+}
+
+int get_migration_state(void)
+{
+ if (current_migration) {
+ return migrate_fd_get_status(current_migration);
+ } else {
+ return MIG_STATE_ERROR;
+ }
+}
diff --git a/migration.h b/migration.h
index d13ed4f..2170792 100644
--- a/migration.h
+++ b/migration.h
@@ -16,6 +16,7 @@
#include "qdict.h"
#include "qemu-common.h"
+#include "notify.h"
#define MIG_STATE_ERROR -1
#define MIG_STATE_COMPLETED 0
@@ -134,4 +135,8 @@ static inline FdMigrationState *migrate_to_fms(MigrationState *mig_state)
return container_of(mig_state, FdMigrationState, mig_state);
}
+void add_migration_state_change_notifier(Notifier *notify);
+void remove_migration_state_change_notifier(Notifier *notify);
+int get_migration_state(void);
+
#endif
--
1.7.1
next prev parent reply other threads:[~2011-01-24 16:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-24 16:20 [Qemu-devel] [PULL 0/8] spice patch queue Gerd Hoffmann
2011-01-24 16:20 ` Gerd Hoffmann [this message]
2011-01-24 16:20 ` [Qemu-devel] [PATCH 2/8] spice/vnc: client migration Gerd Hoffmann
2011-01-24 16:20 ` [Qemu-devel] [PATCH 3/8] spice: MAINTAINERS update Gerd Hoffmann
2011-01-24 16:20 ` [Qemu-devel] [PATCH 4/8] vnc/spice: fix "never" and "now" expire_time Gerd Hoffmann
2011-01-24 16:20 ` [Qemu-devel] [PATCH 5/8] spice/qxl: zap spice 0.4 migration compatibility bits Gerd Hoffmann
2011-01-24 16:20 ` [Qemu-devel] [PATCH 6/8] qxl: locking fix Gerd Hoffmann
2011-01-24 16:20 ` [Qemu-devel] [PATCH 7/8] configure: Fix spice probe Gerd Hoffmann
2011-01-28 13:37 ` [Qemu-devel] " Paolo Bonzini
2011-01-24 16:20 ` [Qemu-devel] [PATCH 8/8] spice: add chardev (v5) Gerd Hoffmann
-- strict thread matches above, loose matches on Subject: below --
2011-01-27 10:12 [Qemu-devel] [PULL 0/8] spice patch queue Gerd Hoffmann
2011-01-27 10:12 ` [Qemu-devel] [PATCH 1/8] add migration state change notifiers Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1295886049-30548-2-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).