[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH COLO-Frame v11 27/39] COLO failover: Shutdown relate
From: |
zhanghailiang |
Subject: |
[Qemu-devel] [PATCH COLO-Frame v11 27/39] COLO failover: Shutdown related socket fd when do failover |
Date: |
Tue, 24 Nov 2015 17:25:37 +0800 |
If the net connection between COLO's two sides is broken while colo/colo
incoming
thread is blocked in 'read'/'write' socket fd. It will not detect this error
until
connect timeout. It will be a long time.
Here we shutdown all the related socket file descriptors to wake up the blocking
operation in failover BH. Besides, we should close the corresponding file
descriptors
after failvoer BH shutdown them, or there will be an error.
Signed-off-by: zhanghailiang <address@hidden>
Signed-off-by: Li Zhijian <address@hidden>
---
v11:
- Only shutdown fd for once
---
migration/colo.c | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/migration/colo.c b/migration/colo.c
index 4cd7b00..994b80d 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -68,6 +68,14 @@ static void secondary_vm_do_failover(void)
/* recover runstate to normal migration finish state */
autostart = true;
}
+ /*
+ * Make sure colo incoming thread not block in recv,
+ * mis->from_src_file and mis->to_src_file use the same fd,
+ * so here we only need to shutdown it for once.
+ */
+ if (mis->from_src_file) {
+ qemu_file_shutdown(mis->from_src_file);
+ }
old_state = failover_set_state(FAILOVER_STATUS_HANDLING,
FAILOVER_STATUS_COMPLETED);
@@ -92,6 +100,15 @@ static void primary_vm_do_failover(void)
MIGRATION_STATUS_COMPLETED);
}
+ /*
+ * Make sure colo thread no block in recv,
+ * Besides, s->rp_state.from_dst_file and s->to_dst_file use the
+ * same fd, so here we only need to shutdown it for once.
+ */
+ if (s->to_dst_file) {
+ qemu_file_shutdown(s->to_dst_file);
+ }
+
old_state = failover_set_state(FAILOVER_STATUS_HANDLING,
FAILOVER_STATUS_COMPLETED);
if (old_state != FAILOVER_STATUS_HANDLING) {
@@ -333,7 +350,7 @@ static void colo_process_checkpoint(MigrationState *s)
out:
current_time = error_time = qemu_clock_get_ms(QEMU_CLOCK_HOST);
- if (ret < 0) {
+ if (ret < 0 || (!ret && !failover_request_is_active())) {
error_report("%s: %s", __func__, strerror(-ret));
qapi_event_send_colo_exit(COLO_MODE_PRIMARY, COLO_EXIT_REASON_ERROR,
true, strerror(-ret), NULL);
@@ -362,6 +379,11 @@ out:
qsb_free(buffer);
buffer = NULL;
+ /* Hope this not to be too long to loop here */
+ while (failover_get_state() != FAILOVER_STATUS_COMPLETED) {
+ ;
+ }
+ /* Must be called after failover BH is completed */
if (s->rp_state.from_dst_file) {
qemu_fclose(s->rp_state.from_dst_file);
}
@@ -534,7 +556,7 @@ void *colo_process_incoming_thread(void *opaque)
out:
current_time = error_time = qemu_clock_get_ms(QEMU_CLOCK_HOST);
- if (ret < 0) {
+ if (ret < 0 || (!ret && !failover_request_is_active())) {
error_report("colo incoming thread will exit, detect error: %s",
strerror(-ret));
qapi_event_send_colo_exit(COLO_MODE_SECONDARY, COLO_EXIT_REASON_ERROR,
@@ -573,6 +595,11 @@ out:
*/
colo_release_ram_cache();
+ /* Hope this not to be too long to loop here */
+ while (failover_get_state() != FAILOVER_STATUS_COMPLETED) {
+ ;
+ }
+ /* Must be called after failover BH is completed */
if (mis->to_src_file) {
qemu_fclose(mis->to_src_file);
}
--
1.8.3.1
- Re: [Qemu-devel] [PATCH COLO-Frame v11 07/39] migration: Integrate COLO checkpoint process into loadvm, (continued)
- [Qemu-devel] [PATCH COLO-Frame v11 18/39] COLO: Flush PVM's cached RAM into SVM's memory, zhanghailiang, 2015/11/24
- [Qemu-devel] [PATCH COLO-Frame v11 15/39] COLO: Load PVM's dirty pages into SVM's RAM cache temporarily, zhanghailiang, 2015/11/24
- [Qemu-devel] [PATCH COLO-Frame v11 16/39] ram/COLO: Record the dirty pages that SVM received, zhanghailiang, 2015/11/24
- [Qemu-devel] [PATCH COLO-Frame v11 21/39] COLO failover: Introduce a new command to trigger a failover, zhanghailiang, 2015/11/24
- [Qemu-devel] [PATCH COLO-Frame v11 24/39] COLO: Implement failover work for Secondary VM, zhanghailiang, 2015/11/24
- [Qemu-devel] [PATCH COLO-Frame v11 17/39] COLO: Load VMState into qsb before restore it, zhanghailiang, 2015/11/24
- [Qemu-devel] [PATCH COLO-Frame v11 22/39] COLO failover: Introduce state to record failover process, zhanghailiang, 2015/11/24
- [Qemu-devel] [PATCH COLO-Frame v11 27/39] COLO failover: Shutdown related socket fd when do failover,
zhanghailiang <=
- [Qemu-devel] [PATCH COLO-Frame v11 33/39] COLO: Split qemu_savevm_state_begin out of checkpoint process, zhanghailiang, 2015/11/24
- [Qemu-devel] [PATCH COLO-Frame v11 29/39] COLO: Process shutdown command for VM in COLO state, zhanghailiang, 2015/11/24
- [Qemu-devel] [PATCH COLO-Frame v11 37/39] filter-buffer: Introduce a helper function to release packets, zhanghailiang, 2015/11/24
- [Qemu-devel] [PATCH COLO-Frame v11 31/39] savevm: Split load vm state function qemu_loadvm_state, zhanghailiang, 2015/11/24
- [Qemu-devel] [PATCH COLO-Frame v11 39/39] COLO: Add block replication into colo process, zhanghailiang, 2015/11/24
- [Qemu-devel] [PATCH COLO-Frame v11 36/39] filter-buffer: Introduce a helper function to enable/disable default filter, zhanghailiang, 2015/11/24
- [Qemu-devel] [PATCH COLO-Frame v11 35/39] filter-buffer: Accept zero interval, zhanghailiang, 2015/11/24