[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH COLO-Frame v7 16/34] COLO failover: Introduce state
From: |
zhanghailiang |
Subject: |
[Qemu-devel] [PATCH COLO-Frame v7 16/34] COLO failover: Introduce state to record failover process |
Date: |
Thu, 9 Jul 2015 11:16:24 +0800 |
When handling failover, we do different things according to the different stage
of failover process, here we introduce a global atomic variable to record the
status of failover.
We add four failover status to indicate the different stage of failover process.
You should use the helpers to get and set the value.
Signed-off-by: zhanghailiang <address@hidden>
---
include/migration/failover.h | 9 +++++++++
migration/colo-failover.c | 24 ++++++++++++++++++++++++
trace-events | 1 +
3 files changed, 34 insertions(+)
diff --git a/include/migration/failover.h b/include/migration/failover.h
index 1785b52..56d57d7 100644
--- a/include/migration/failover.h
+++ b/include/migration/failover.h
@@ -15,6 +15,15 @@
#include "qemu-common.h"
+typedef enum COLOFailoverStatus {
+ FAILOVER_STATUS_NONE = 0,
+ FAILOVER_STATUS_REQUEST = 1, /* Request but not handled */
+ FAILOVER_STATUS_HANDLING = 2, /* In the process of handling failover */
+ FAILOVER_STATUS_COMPLETED = 3, /* Finish the failover process */
+} COLOFailoverStatus;
+
+int failover_set_state(int old_state, int new_state);
+int failover_get_state(void);
void failover_request_active(Error **errp);
#endif
diff --git a/migration/colo-failover.c b/migration/colo-failover.c
index af068d3..1bf22f5 100644
--- a/migration/colo-failover.c
+++ b/migration/colo-failover.c
@@ -14,8 +14,11 @@
#include "migration/failover.h"
#include "qmp-commands.h"
#include "qapi/qmp/qerror.h"
+#include "qemu/error-report.h"
+#include "trace.h"
static QEMUBH *failover_bh;
+static COLOFailoverStatus failover_state;
static void colo_failover_bh(void *opaque)
{
@@ -26,10 +29,31 @@ static void colo_failover_bh(void *opaque)
void failover_request_active(Error **errp)
{
+ if (failover_set_state(FAILOVER_STATUS_NONE, FAILOVER_STATUS_REQUEST)
+ != FAILOVER_STATUS_NONE) {
+ error_setg(errp, "COLO failover is already actived");
+ return;
+ }
failover_bh = qemu_bh_new(colo_failover_bh, NULL);
qemu_bh_schedule(failover_bh);
}
+int failover_set_state(int old_state, int new_state)
+{
+ int old;
+
+ old = atomic_cmpxchg(&failover_state, old_state, new_state);;
+ if (old == old_state) {
+ trace_failover_set_state(new_state);
+ }
+ return old;
+}
+
+int failover_get_state(void)
+{
+ return atomic_read(&failover_state);
+}
+
void qmp_colo_lost_heartbeat(Error **errp)
{
if (get_colo_mode() == COLO_MODE_UNKNOWN) {
diff --git a/trace-events b/trace-events
index c34c7c4..20551c8 100644
--- a/trace-events
+++ b/trace-events
@@ -1475,6 +1475,7 @@
rdma_start_outgoing_migration_after_rdma_source_init(void) ""
# migration/colo.c
colo_vm_state_change(const char *old, const char *new) "Change '%s' => '%s'"
colo_receive_message(const char *msg) "Receive '%s'"
+failover_set_state(int new_state) "new state %d"
# kvm-all.c
kvm_ioctl(int type, void *arg) "type 0x%x, arg %p"
--
1.7.12.4
- [Qemu-devel] [PATCH COLO-Frame v7 04/34] colo-comm/migration: skip colo info section for special cases, (continued)
- [Qemu-devel] [PATCH COLO-Frame v7 04/34] colo-comm/migration: skip colo info section for special cases, zhanghailiang, 2015/07/08
- [Qemu-devel] [PATCH COLO-Frame v7 03/34] COLO: migrate colo related info to slave, zhanghailiang, 2015/07/08
- [Qemu-devel] [PATCH COLO-Frame v7 19/34] COLO failover: Don't do failover during loading VM's state, zhanghailiang, 2015/07/08
- [Qemu-devel] [PATCH COLO-Frame v7 23/34] COLO NIC: Implement colo nic device interface configure(), zhanghailiang, 2015/07/08
- [Qemu-devel] [PATCH COLO-Frame v7 18/34] qmp event: Add event notification for COLO error, zhanghailiang, 2015/07/08
- [Qemu-devel] [PATCH COLO-Frame v7 20/34] COLO: Add new command parameter 'forward_nic' 'colo_script' for net, zhanghailiang, 2015/07/08
- [Qemu-devel] [PATCH COLO-Frame v7 17/34] COLO failover: Implement COLO primary/secondary vm failover work, zhanghailiang, 2015/07/08
- [Qemu-devel] [PATCH COLO-Frame v7 21/34] COLO NIC: Init/remove colo nic devices when add/cleanup tap devices, zhanghailiang, 2015/07/08
- [Qemu-devel] [PATCH COLO-Frame v7 28/34] COLO: Do checkpoint according to the result of packets comparation, zhanghailiang, 2015/07/08
- [Qemu-devel] [PATCH COLO-Frame v7 27/34] COLO: Handle nfnetlink message from proxy module, zhanghailiang, 2015/07/08
- [Qemu-devel] [PATCH COLO-Frame v7 16/34] COLO failover: Introduce state to record failover process,
zhanghailiang <=
- [Qemu-devel] [PATCH COLO-Frame v7 26/34] COLO NIC: Some init work related with proxy module, zhanghailiang, 2015/07/08