Optimized some code for COLO
v2 cover Optimized some code for COLO
Optimized some code for COLO and fixed a qemu crash when guest shutdown in COLO mode.
leirao (3):
Optimize seq_sorter function for colo-compare Reduce the time of checkpoint for COLO
Fix the qemu crash when guest shutdown in COLO mode
migration/ram.c | 14 +++++++++++++- net/colo-compare.c | 6 +----- softmmu/vl.c | 1 + 3 files changed, 15 insertions(+), 6 deletions(-)
--
1.8.3.1
PATCH v2 1/3 Optimize seq_sorter function for colo-compare
The seq of tcp has been filled in fill_pkt_tcp_info, it can be used directly here.
--- net/colo-compare.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
net/colo-compare.c +1 -5
@@ -196,11 +196,7 @@ static void colo_compare_inconsistency_notify(CompareState *s)static gint seq_sorter (Packet *a,Packet *b,gpointer data) { -struct tcp_hdr *atcp, *btcp; - - atcp = (struct tcp_hdr *)(a->transport_header); - btcp = (struct tcp_hdr *)(b->transport_header); -return ntohl (atcp->th_seq) -ntohl (btcp->th_seq); +return a->tcp_seq - b->tcp_seq; }static void fill_pkt_tcp_info (void *data,uint32_t *max_ack)
Signature · 1 line
1.8.3.1
RE: [PATCH v2 1/3] Optimize seq_sorter function for colo-compare
Quoted 11 lines
-----Original Message-----
From: Rao, Lei <[email protected]>
Sent: Tuesday, September 22, 2020 5:25 PM
To: Zhang, Chen <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Rao, Lei <[email protected]>
Subject: [PATCH v2 1/3] Optimizeseq_sorterfunction for colo-compare
Quoted 3 lines
The seq of tcp has been filled in
fill_pkt_tcp_info, it can be used directly here.Signed-off-by leirao <[email protected]>
By the way, please add Zhijian's reviewed-by in new version of patches.
Thanks
Zhang Chen
Quoted 23 lines
--- net/colo-compare.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)net/colo-compare.c index renamed from net/colo-compare.c +0
-03a45d64..86980ce 100644
net/colo-compare.c +1
-6@@ -196,11 +196,7 @@ static void colo_compare_inconsistency_notify(CompareState *s)static gint seq_sorter (Packet *a,Packet *b,gpointer data) { -struct tcp_hdr *atcp, *btcp; - - atcp = (struct tcp_hdr *)(a->transport_header); - btcp = (struct tcp_hdr *)(b->transport_header); -return ntohl (atcp->th_seq) -ntohl (btcp->th_seq); +return a->tcp_seq - b->tcp_seq; }static void fill_pkt_tcp_info (void *data,uint32_t *max_ack) --1.8.3.1
PATCH v2 2/3 Reduce the time of checkpoint for COLO
In reply to leiraowe should set ram_bulk_stage to false after ram_state_init, otherwise the bitmap will be unused in migration_bitmap_find_dirty. all pages in ram cache will be flushed to the ram of secondary guest for each checkpoint.
--- migration/ram.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
migration/ram.c +13 -1
@@ -3018,6 +3018,18 @@ static void decompress_data_with_multi_threads(QEMUFile *f,qemu_mutex_unlock (&decomp_done_lock); } +/* +* we must set ram_bulk_stage to fasle, otherwise in +* migation_bitmap_find_dirty the bitmap will be unused and +* all the pages in ram cache wil be flushed to the ram of +* secondary VM. +*/ +static void colo_init_ram_state (void ) +{ +ram_state_init (&ram_state); + ram_state->ram_bulk_stage = false; +} +/* * colo cache: this is for secondary VM, we cache the whole * memory of the secondary VM, it is need to hold the global lock
@@ -3061,7 +3073,7 @@ int colo_init_ram_cache(void) } } -ram_state_init (&ram_state); +colo_init_ram_state ();return 0 ; }
Signature · 1 line
1.8.3.1
RE: [PATCH v2 2/3] Reduce the time of checkpoint for COLO
Quoted 11 lines
-----Original Message-----
From: Rao, Lei <[email protected]>
Sent: Tuesday, September 22, 2020 5:25 PM
To: Zhang, Chen <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Rao, Lei <[email protected]>
Subject: [PATCH v2 2/3] Reduce the time of checkpoint for COLO
Quoted 6 lines
we should set
ram_bulk_stageto false afterram_state_init, otherwise the bitmap will be unused inmigration_bitmap_find_dirty.
all pages in ram cache will be flushed to the ram of secondary guest for each checkpoint.Signed-off-by leirao <[email protected]>
Thanks
Zhang Chen
Quoted 38 lines
--- migration/ram.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)migration/ram.c +12
-0@@ -3018,6 +3018,18 @@ static voiddecompress_data_with_multi_threads (QEMUFile *f, qemu_mutex_unlock(&decomp_done_lock); } +/* +* we must set ram_bulk_stage to fasle, otherwise in +* migation_bitmap_find_dirty the bitmap will be unused and +* all the pages in ram cache wil be flushed to the ram of +* secondary VM. +*/ +static void colo_init_ram_state (void ) +{ +ram_state_init (&ram_state); + ram_state->ram_bulk_stage = false; +} +/* * colo cache: this is for secondary VM, we cache the whole * memory of the secondary VM, it is need to hold the global lock @@ -
3061,7 +3073,7 @@ intcolo_init_ram_cache(void)} }migration/ram.c +1
-2-ram_state_init (&ram_state); +colo_init_ram_state ();return 0 ; } --1.8.3.1
Re: [PATCH v2 2/3] Reduce the time of checkpoint for COLO
In reply to leiraoQuoted 15 lines · leirao
we should set
ram_bulk_stageto false afterram_state_init, otherwise the bitmap will be unused inmigration_bitmap_find_dirty. all pages in ram cache will be flushed to the ram of secondary guest for each checkpoint.Signed-off-by leirao <[email protected]>--- migration/ram.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)migration/ram.c +0
-0
migration/ram.c static void decompress_data_with_multi_threads(QEMUFile *f, · line 3022
Quoted 5 lines
migration/ram.c +2
-0@@ -3018,6 +3018,18 @@ static void decompress_data_with_multi_threads(QEMUFile *f,qemu_mutex_unlock (&decomp_done_lock); } +/* +* we must set ram_bulk_stage to fasle, otherwise in
a typo: s/fasle/false
Quoted 22 lines
migration/ram.c +11
-1+* migation_bitmap_find_dirty the bitmap will be unused and +* all the pages in ram cache wil be flushed to the ram of +* secondary VM. +*/ +static void colo_init_ram_state (void ) +{ +ram_state_init (&ram_state); + ram_state->ram_bulk_stage = false; +} +/* * colo cache: this is for secondary VM, we cache the whole * memory of the secondary VM, it is need to hold the global lock @@ -3061,7 +3073,7 @@ int colo_init_ram_cache(void) } } -ram_state_init (&ram_state); +colo_init_ram_state ();return 0 ; }
PATCH v2 3/3 Fix the qemu crash when guest shutdown in COLO mode
In reply to leiraoIn COLO mode, if the startup parameters of QEMU include "no-shutdown", QEMU will crash when the guest shutdown. The root cause is when the guest shutdown, the state of VM will switch COLO to SHUTDOWN. When do checkpoint again, the state will be changed to COLO. But the state switch is undefined in runstate_transitions_def, we should add it. This patch fixes the following:
qemu-system-x86_64: invalid runstate transition: 'shutdown' -> 'colo' Aborted
--- softmmu/vl.c | 1 + 1 file changed, 1 insertion(+)
softmmu/vl.c +1 -0
@@ -631,6 +631,7 @@ static const RunStateTransition runstate_transitions_def[] = { { RUN_STATE_SHUTDOWN, RUN_STATE_PAUSED }, { RUN_STATE_SHUTDOWN, RUN_STATE_FINISH_MIGRATE }, { RUN_STATE_SHUTDOWN, RUN_STATE_PRELAUNCH }, + { RUN_STATE_SHUTDOWN, RUN_STATE_COLO }, { RUN_STATE_DEBUG, RUN_STATE_SUSPENDED }, { RUN_STATE_RUNNING, RUN_STATE_SUSPENDED },
Signature · 1 line
1.8.3.1
RE: [PATCH v2 3/3] Fix the qemu crash when guest shutdown in COLO mode
Quoted 21 lines
-----Original Message-----
From: Rao, Lei <[email protected]>
Sent: Tuesday, September 22, 2020 5:25 PM
To: Zhang, Chen <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Rao, Lei <[email protected]>
Subject: [PATCH v2 3/3] Fix the qemu crash when guest shutdown in COLO modeIn COLO mode, if the startup parameters of QEMU include "no-shutdown", QEMU will crash when the guest shutdown. The root cause is when the guest shutdown, the state of VM will switch COLO to SHUTDOWN. When do checkpoint again, the state will be changed to COLO. But the state switch is undefined in
runstate_transitions_def, we should add it.
This patch fixes the following:
qemu-system-x86_64: invalid runstate transition: 'shutdown' -> 'colo' Aborted
Quoted 1 line
Signed-off-by leirao <[email protected]>
Thanks
Zhang Chen
Quoted 18 lines
--- softmmu/vl.c | 1 + 1 file changed, 1 insertion(+)softmmu/vl.c +1
-0@@ -631,6 +631,7 @@ static const RunStateTransition runstate_transitions_def[] = { { RUN_STATE_SHUTDOWN, RUN_STATE_PAUSED }, { RUN_STATE_SHUTDOWN, RUN_STATE_FINISH_MIGRATE }, { RUN_STATE_SHUTDOWN, RUN_STATE_PRELAUNCH }, + { RUN_STATE_SHUTDOWN, RUN_STATE_COLO }, { RUN_STATE_DEBUG, RUN_STATE_SUSPENDED },{
RUN_STATE_RUNNING,RUN_STATE_SUSPENDED},
--
1.8.3.1