Skip to contentSkip to conversation

COLO net and runstate bugfix/optimization

PATCH In review Zhang Chen 3 participants 16 messages Apr 1, 2022 – Jul 6, 2022 Networking

lore
Share & tools
lore

Zhang Chen

author
#0 lore raw

v2 cover COLO net and runstate bugfix/optimization

This series fix some COLO related issues in internal stress testing.

- V2:
- Add more comments in patch 2/4 commit log.

Zhang Chen (4):
softmmu/runstate.c: add RunStateTransition support form COLO to
PRELAUNCH
net/colo: Fix a "double free" crash to clear the conn_list net/colo.c: No need to track conn_list for filter-rewriter net/colo.c: fix segmentation fault when packet is not parsed correctly

 net/colo-compare.c    |  2 +-
 net/colo.c            | 11 +++++++++--
 net/filter-rewriter.c |  2 +-
 net/trace-events      |  1 +
 softmmu/runstate.c    |  1 +
 5 files changed, 13 insertions(+), 4 deletions(-)
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v2 1/4 softmmu/runstate.c: add RunStateTransition support form COLO to PRELAUNCH

If the checkpoint occurs when the guest finishes restarting but has not started running, the runstate_set() may reject the transition from COLO to PRELAUNCH with the crash log:

{"timestamp": {"seconds": 1593484591, "microseconds": 26605},\
"event": "RESET", "data": {"guest": true, "reason": "guest-reset"}}
qemu-system-x86_64: invalid runstate transition: 'colo' -> 'prelaunch'

Long-term testing says that it's pretty safe.

---
 softmmu/runstate.c | 1 +
 1 file changed, 1 insertion(+)
softmmu/runstate.c +1 -0
index e0d869b21a..c021c56338 100644
@@ -127,6 +127,7 @@ static const RunStateTransition runstate_transitions_def[] = {
     { RUN_STATE_RESTORE_VM, RUN_STATE_PRELAUNCH },
 
     { RUN_STATE_COLO, RUN_STATE_RUNNING },
+    { RUN_STATE_COLO, RUN_STATE_PRELAUNCH },
     { RUN_STATE_COLO, RUN_STATE_SHUTDOWN},
 
     { RUN_STATE_RUNNING, RUN_STATE_DEBUG },
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH V2 1/4] softmmu/runstate.c: add RunStateTransition support form COLO to PRELAUNCH

Quoted 5 lines · Zhang Chen

If the checkpoint occurs when the guest finishes restarting but has not started running, the runstate_set() may reject the transition from COLO to PRELAUNCH with the crash log:

Quoted 8 lines

{"timestamp": {"seconds": 1593484591, "microseconds": 26605},\
"event": "RESET", "data": {"guest": true, "reason": "guest-reset"}}
qemu-system-x86_64: invalid runstate transition: 'colo' -> 'prelaunch'

Long-term testing says that it's pretty safe.

I'd expect this to get ack from the relevant maintainers.

Thanks

Quoted 19 lines
---
 softmmu/runstate.c | 1 +
 1 file changed, 1 insertion(+)
softmmu/runstate.c +1 -1
index e0d869b21a..c021c56338 100644
@@ -127,6 +127,7 @@ static const RunStateTransition runstate_transitions_def[] = {
     { RUN_STATE_RESTORE_VM, RUN_STATE_PRELAUNCH },
 
     { RUN_STATE_COLO, RUN_STATE_RUNNING },
+    { RUN_STATE_COLO, RUN_STATE_PRELAUNCH },
     { RUN_STATE_COLO, RUN_STATE_SHUTDOWN},
 
     { RUN_STATE_RUNNING, RUN_STATE_DEBUG },
--

2.25.1

#3 lore raw

RE: [PATCH V2 1/4] softmmu/runstate.c: add RunStateTransition support form COLO to PRELAUNCH

Quoted 21 lines

-----Original Message-----
From: Jason Wang <[email protected]>
Sent: Wednesday, April 27, 2022 4:57 PM
To: Zhang, Chen <[email protected]>
Cc: Li Zhijian <[email protected]>; qemu-dev <qemu- [email protected]>; Like Xu <[email protected]>
Subject: Re: [PATCH V2 1/4] softmmu/runstate.c: add RunStateTransition support form COLO to PRELAUNCH

Quoted 9 lines · Zhang Chen

If the checkpoint occurs when the guest finishes restarting but has not started running, the runstate_set() may reject the transition from COLO to PRELAUNCH with the crash log:

{"timestamp": {"seconds": 1593484591, "microseconds": 26605},\
"event": "RESET", "data": {"guest": true, "reason": "guest-reset"}}
qemu-system-x86_64: invalid runstate transition: 'colo' -> 'prelaunch'

Quoted 7 lines
Quoted 4 lines

Long-term testing says that it's pretty safe.

I'd expect this to get ack from the relevant maintainers.

The scripts/get_maintainer.pl can't find relevant maintainers for this patch. Maybe Paolo have time to cover this simple patch related to runstate?

Thanks
Chen

Quoted 22 lines

Thanks

softmmu/runstate.c static const RunStateTransition

Quoted 9 lines
---
 softmmu/runstate.c | 1 +
 1 file changed, 1 insertion(+)
softmmu/runstate.c index renamed from softmmu/runstate.c +0 -0

e0d869b21a..c021c56338 100644

softmmu/runstate.c +0 -0
@@ -127,6 +127,7 @@ static const RunStateTransition

runstate_transitions_def[] = {

Quoted 10 lines
softmmu/runstate.c +1 -1
     { RUN_STATE_RESTORE_VM, RUN_STATE_PRELAUNCH },
 
     { RUN_STATE_COLO, RUN_STATE_RUNNING },
+    { RUN_STATE_COLO, RUN_STATE_PRELAUNCH },
     { RUN_STATE_COLO, RUN_STATE_SHUTDOWN},
 
     { RUN_STATE_RUNNING, RUN_STATE_DEBUG },
--

2.25.1

#4 lore raw

RE: [PATCH V2 1/4] softmmu/runstate.c: add RunStateTransition support form COLO to PRELAUNCH

Quoted 35 lines

-----Original Message-----
From: Zhang, Chen
Sent: Wednesday, April 27, 2022 5:26 PM
To: Jason Wang <[email protected]>; Paolo Bonzini <[email protected]>
Cc: Li Zhijian <[email protected]>; qemu-dev <qemu- [email protected]>; Like Xu <[email protected]>
Subject: RE: [PATCH V2 1/4] softmmu/runstate.c: add RunStateTransition support form COLO to PRELAUNCH

Quoted 21 lines

-----Original Message-----
From: Jason Wang <[email protected]>
Sent: Wednesday, April 27, 2022 4:57 PM
To: Zhang, Chen <[email protected]>
Cc: Li Zhijian <[email protected]>; qemu-dev <qemu- [email protected]>; Like Xu <[email protected]>
Subject: Re: [PATCH V2 1/4] softmmu/runstate.c: add RunStateTransition support form COLO to PRELAUNCH

Quoted 11 lines · Zhang Chen

If the checkpoint occurs when the guest finishes restarting but has not started running, the runstate_set() may reject the transition from COLO to PRELAUNCH with the crash log:

{"timestamp": {"seconds": 1593484591, "microseconds": 26605},\
"event": "RESET", "data": {"guest": true, "reason": "guest-reset"}}
qemu-system-x86_64: invalid runstate transition: 'colo' -> 'prelaunch'

Long-term testing says that it's pretty safe.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I'd expect this to get ack from the relevant maintainers.

The scripts/get_maintainer.pl can't find relevant maintainers for this patch. Maybe Paolo have time to cover this simple patch related to runstate?

No news for a while, any comments for unmaintained files changes ? Ping...

Thanks
Chen

Quoted 26 lines

Thanks
Chen

Quoted 22 lines

Thanks

softmmu/runstate.c static const RunStateTransition

Quoted 9 lines
---
 softmmu/runstate.c | 1 +
 1 file changed, 1 insertion(+)
softmmu/runstate.c index renamed from softmmu/runstate.c +0 -0

e0d869b21a..c021c56338 100644

softmmu/runstate.c +0 -0
@@ -127,6 +127,7 @@ static const RunStateTransition

runstate_transitions_def[] = {

Quoted 10 lines
softmmu/runstate.c +1 -1
     { RUN_STATE_RESTORE_VM, RUN_STATE_PRELAUNCH },
 
     { RUN_STATE_COLO, RUN_STATE_RUNNING },
+    { RUN_STATE_COLO, RUN_STATE_PRELAUNCH },
     { RUN_STATE_COLO, RUN_STATE_SHUTDOWN},
 
     { RUN_STATE_RUNNING, RUN_STATE_DEBUG },
--

2.25.1

#5 lore raw

Re: [PATCH V2 1/4] softmmu/runstate.c: add RunStateTransition support form COLO to PRELAUNCH

Quoted 39 lines · Chen
Quoted 39 lines

-----Original Message-----
From: Zhang, Chen
Sent: Wednesday, April 27, 2022 5:26 PM
To: Jason Wang <[email protected]>; Paolo Bonzini <[email protected]>
Cc: Li Zhijian <[email protected]>; qemu-dev <qemu- [email protected]>; Like Xu <[email protected]>
Subject: RE: [PATCH V2 1/4] softmmu/runstate.c: add RunStateTransition support form COLO to PRELAUNCH

Quoted 24 lines

-----Original Message-----
From: Jason Wang <[email protected]>
Sent: Wednesday, April 27, 2022 4:57 PM
To: Zhang, Chen <[email protected]>
Cc: Li Zhijian <[email protected]>; qemu-dev <qemu- [email protected]>; Like Xu <[email protected]>
Subject: Re: [PATCH V2 1/4] softmmu/runstate.c: add RunStateTransition support form COLO to PRELAUNCH

Quoted 13 lines · Zhang Chen

If the checkpoint occurs when the guest finishes restarting but has not started running, the runstate_set() may reject the transition from COLO to PRELAUNCH with the crash log:

{"timestamp": {"seconds": 1593484591, "microseconds": 26605},\
"event": "RESET", "data": {"guest": true, "reason": "guest-reset"}}
qemu-system-x86_64: invalid runstate transition: 'colo' -> 'prelaunch'

Long-term testing says that it's pretty safe.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I'd expect this to get ack from the relevant maintainers.

The scripts/get_maintainer.pl can't find relevant maintainers for this patch. Maybe Paolo have time to cover this simple patch related to runstate?

No news for a while, any comments for unmaintained files changes ? Ping...

Adding David and Juan.

Thanks

Quoted 31 lines

Thanks
Chen

Quoted 26 lines

Thanks
Chen

Quoted 22 lines

Thanks

softmmu/runstate.c static const RunStateTransition

Quoted 9 lines
---
 softmmu/runstate.c | 1 +
 1 file changed, 1 insertion(+)
softmmu/runstate.c index renamed from softmmu/runstate.c +0 -0

e0d869b21a..c021c56338 100644

softmmu/runstate.c +0 -0
@@ -127,6 +127,7 @@ static const RunStateTransition

runstate_transitions_def[] = {

Quoted 10 lines
softmmu/runstate.c +1 -1
     { RUN_STATE_RESTORE_VM, RUN_STATE_PRELAUNCH },
 
     { RUN_STATE_COLO, RUN_STATE_RUNNING },
+    { RUN_STATE_COLO, RUN_STATE_PRELAUNCH },
     { RUN_STATE_COLO, RUN_STATE_SHUTDOWN},
 
     { RUN_STATE_RUNNING, RUN_STATE_DEBUG },
--

2.25.1

#6 lore raw

Re: [PATCH V2 1/4] softmmu/runstate.c: add RunStateTransition support form COLO to PRELAUNCH

Quoted 43 lines · * Jason Wang ([email protected]) wrote:
Quoted 42 lines · Chen
Quoted 42 lines

-----Original Message-----
From: Zhang, Chen
Sent: Wednesday, April 27, 2022 5:26 PM
To: Jason Wang <[email protected]>; Paolo Bonzini <[email protected]>
Cc: Li Zhijian <[email protected]>; qemu-dev <qemu- [email protected]>; Like Xu <[email protected]>
Subject: RE: [PATCH V2 1/4] softmmu/runstate.c: add RunStateTransition support form COLO to PRELAUNCH

Quoted 26 lines

-----Original Message-----
From: Jason Wang <[email protected]>
Sent: Wednesday, April 27, 2022 4:57 PM
To: Zhang, Chen <[email protected]>
Cc: Li Zhijian <[email protected]>; qemu-dev <qemu- [email protected]>; Like Xu <[email protected]>
Subject: Re: [PATCH V2 1/4] softmmu/runstate.c: add RunStateTransition support form COLO to PRELAUNCH

Quoted 5 lines · Zhang Chen

If the checkpoint occurs when the guest finishes restarting but has not started running, the runstate_set() may reject the transition from COLO to PRELAUNCH with the crash log:

Quoted 8 lines

{"timestamp": {"seconds": 1593484591, "microseconds": 26605},\
"event": "RESET", "data": {"guest": true, "reason": "guest-reset"}}
qemu-system-x86_64: invalid runstate transition: 'colo' -> 'prelaunch'

Long-term testing says that it's pretty safe.

I'd expect this to get ack from the relevant maintainers.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

The scripts/get_maintainer.pl can't find relevant maintainers for this patch. Maybe Paolo have time to cover this simple patch related to runstate?

No news for a while, any comments for unmaintained files changes ? Ping...

Adding David and Juan.

This looks OK to me;

it should be fine to merge it along with the pull that takes the other patches.

Dave

Quoted 34 lines

Thanks

Quoted 31 lines

Thanks
Chen

Quoted 26 lines

Thanks
Chen

Quoted 22 lines

Thanks

softmmu/runstate.c static const RunStateTransition

Quoted 9 lines
---
 softmmu/runstate.c | 1 +
 1 file changed, 1 insertion(+)
softmmu/runstate.c index renamed from softmmu/runstate.c +0 -0

e0d869b21a..c021c56338 100644

softmmu/runstate.c +0 -0
@@ -127,6 +127,7 @@ static const RunStateTransition

runstate_transitions_def[] = {

Quoted 10 lines
softmmu/runstate.c +1 -1
     { RUN_STATE_RESTORE_VM, RUN_STATE_PRELAUNCH },
 
     { RUN_STATE_COLO, RUN_STATE_RUNNING },
+    { RUN_STATE_COLO, RUN_STATE_PRELAUNCH },
     { RUN_STATE_COLO, RUN_STATE_SHUTDOWN},
 
     { RUN_STATE_RUNNING, RUN_STATE_DEBUG },
--

2.25.1

Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
#7 lore raw

Re: [PATCH V2 1/4] softmmu/runstate.c: add RunStateTransition support form COLO to PRELAUNCH

Quoted 48 lines · Dr. David Alan Gilbert
Quoted 46 lines · * Jason Wang ([email protected]) wrote:
Quoted 45 lines · Chen
Quoted 44 lines

-----Original Message-----
From: Zhang, Chen
Sent: Wednesday, April 27, 2022 5:26 PM
To: Jason Wang <[email protected]>; Paolo Bonzini <[email protected]>
Cc: Li Zhijian <[email protected]>; qemu-dev <qemu- [email protected]>; Like Xu <[email protected]>
Subject: RE: [PATCH V2 1/4] softmmu/runstate.c: add RunStateTransition support form COLO to PRELAUNCH

Quoted 19 lines

-----Original Message-----
From: Jason Wang <[email protected]>
Sent: Wednesday, April 27, 2022 4:57 PM
To: Zhang, Chen <[email protected]>
Cc: Li Zhijian <[email protected]>; qemu-dev <qemu- [email protected]>; Like Xu <[email protected]>
Subject: Re: [PATCH V2 1/4] softmmu/runstate.c: add RunStateTransition support form COLO to PRELAUNCH

Quoted 9 lines · Zhang Chen

If the checkpoint occurs when the guest finishes restarting but has not started running, the runstate_set() may reject the transition from COLO to PRELAUNCH with the crash log:

{"timestamp": {"seconds": 1593484591, "microseconds": 26605},\
"event": "RESET", "data": {"guest": true, "reason": "guest-reset"}}
qemu-system-x86_64: invalid runstate transition: 'colo' -> 'prelaunch'

Quoted 7 lines
Quoted 4 lines

Long-term testing says that it's pretty safe.

I'd expect this to get ack from the relevant maintainers.

The scripts/get_maintainer.pl can't find relevant maintainers for this patch. Maybe Paolo have time to cover this simple patch related to runstate?

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

No news for a while, any comments for unmaintained files changes ? Ping...

Adding David and Juan.

This looks OK to me;

Great.

Quoted 3 lines

it should be fine to merge it along with the pull that takes the other patches.

Yes, I've queued this series.

Thanks

Quoted 40 lines

Dave

Quoted 34 lines

Thanks

Quoted 31 lines

Thanks
Chen

Quoted 26 lines

Thanks
Chen

Quoted 22 lines

Thanks

softmmu/runstate.c static const RunStateTransition

Quoted 9 lines
---
 softmmu/runstate.c | 1 +
 1 file changed, 1 insertion(+)
softmmu/runstate.c index renamed from softmmu/runstate.c +0 -0

e0d869b21a..c021c56338 100644

softmmu/runstate.c +0 -0
@@ -127,6 +127,7 @@ static const RunStateTransition

runstate_transitions_def[] = {

Quoted 10 lines
softmmu/runstate.c +1 -1
     { RUN_STATE_RESTORE_VM, RUN_STATE_PRELAUNCH },
 
     { RUN_STATE_COLO, RUN_STATE_RUNNING },
+    { RUN_STATE_COLO, RUN_STATE_PRELAUNCH },
     { RUN_STATE_COLO, RUN_STATE_SHUTDOWN},
 
     { RUN_STATE_RUNNING, RUN_STATE_DEBUG },
--

2.25.1

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#8 lore raw

RE: [PATCH V2 1/4] softmmu/runstate.c: add RunStateTransition support form COLO to PRELAUNCH

Quoted 35 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

On Fri, Apr 1, 2022 at 11:59 AM Zhang Chen <[email protected]>

Quoted 10 lines · wrote:
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

If the checkpoint occurs when the guest finishes restarting but has not started running, the runstate_set() may reject the transition from COLO to PRELAUNCH with the crash log:

{"timestamp": {"seconds": 1593484591, "microseconds":
26605},\
"event": "RESET", "data": {"guest": true, "reason":
"guest-reset"}}
qemu-system-x86_64: invalid runstate transition: 'colo' ->

'prelaunch'

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
Quoted 5 lines

Long-term testing says that it's pretty safe.

I'd expect this to get ack from the relevant maintainers.

The scripts/get_maintainer.pl can't find relevant maintainers for this

patch.

Quoted 10 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Maybe Paolo have time to cover this simple patch related to runstate?

No news for a while, any comments for unmaintained files changes ? Ping...

Adding David and Juan.

This looks OK to me;

Quoted 7 lines

Great.

Quoted 3 lines

it should be fine to merge it along with the pull that takes the other patches.

Yes, I've queued this series.

Hi Jason, did this series get lost in the net queue branch?

Thanks
Chen

Quoted 10 lines

Thanks

Quoted 7 lines

Dave

Quoted 3 lines

Thanks

Quoted 1 line
#9 lore raw

Re: [PATCH V2 1/4] softmmu/runstate.c: add RunStateTransition support form COLO to PRELAUNCH

Quoted 39 lines · Chen
Quoted 39 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On Fri, Apr 1, 2022 at 11:59 AM Zhang Chen <[email protected]>

Quoted 10 lines · wrote:
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

If the checkpoint occurs when the guest finishes restarting but has not started running, the runstate_set() may reject the transition from COLO to PRELAUNCH with the crash log:

{"timestamp": {"seconds": 1593484591, "microseconds":
26605},\
"event": "RESET", "data": {"guest": true, "reason":
"guest-reset"}}
qemu-system-x86_64: invalid runstate transition: 'colo' ->

'prelaunch'

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
Quoted 5 lines

Long-term testing says that it's pretty safe.

I'd expect this to get ack from the relevant maintainers.

The scripts/get_maintainer.pl can't find relevant maintainers for this

patch.

Quoted 10 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Maybe Paolo have time to cover this simple patch related to runstate?

No news for a while, any comments for unmaintained files changes ? Ping...

Adding David and Juan.

This looks OK to me;

Great.

Quoted 1 line
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

it should be fine to merge it along with the pull that takes the other patches.

Yes, I've queued this series.

Hi Jason, did this series get lost in the net queue branch?

Unfortunately, yes.

It will be included in the net pull request.

Sorry.

Quoted 15 lines

Thanks
Chen

Quoted 10 lines

Thanks

Quoted 7 lines

Dave

Quoted 3 lines

Thanks

Quoted 1 line
author
#10 lore raw

PATCH v2 2/4 net/colo: Fix a "double free" crash to clear the conn_list

In reply to Zhang Chen

We notice the QEMU may crash when the guest has too many incoming network connections with the following log:

[email protected]:colo_proxy_main : colo proxy connection hashtable full, clear it free(): invalid pointer
[1] 15195 abort (core dumped) qemu-system-x86_64 ....

This is because we create the s->connection_track_table with g_hash_table_new_full() which is defined as:

GHashTable * g_hash_table_new_full (GHashFunc hash_func,

                       GEqualFunc key_equal_func,
                       GDestroyNotify key_destroy_func,
                       GDestroyNotify value_destroy_func);

The fourth parameter connection_destroy() will be called to free the memory allocated for all 'Connection' values in the hashtable when we call g_hash_table_remove_all() in the connection_hashtable_reset().

But both connection_track_table and conn_list reference to the same conn instance. It will trigger double free in conn_list clear. So this patch remove free action on hash table side to avoid double free the conn.

---
 net/colo-compare.c    | 2 +-
 net/filter-rewriter.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
net/colo-compare.c +1 -1
index 62554b5b3c..ab054cfd21 100644
@@ -1324,7 +1324,7 @@ static void colo_compare_complete(UserCreatable *uc, Error **errp)
     s->connection_track_table = g_hash_table_new_full(connection_key_hash,
                                                       connection_key_equal,
                                                       g_free,
-                                                      connection_destroy);
+                                                      NULL);
 
     colo_compare_iothread(s);
 
net/filter-rewriter.c +1 -1
index bf05023dc3..c18c4c2019 100644
@@ -383,7 +383,7 @@ static void colo_rewriter_setup(NetFilterState *nf, Error **errp)
     s->connection_track_table = g_hash_table_new_full(connection_key_hash,
                                                       connection_key_equal,
                                                       g_free,
-                                                      connection_destroy);
+                                                      NULL);
     s->incoming_queue = qemu_new_net_queue(qemu_netfilter_pass_to_next, nf);
 }
 
Signature · 1 line
2.25.1
author
#11 lore raw

PATCH v2 3/4 net/colo.c: No need to track conn_list for filter-rewriter

In reply to Zhang Chen

Filter-rewriter no need to track connection in conn_list. This patch fix the glib g_queue_is_empty assertion when COLO guest keep a lot of network connection.

---
 net/colo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/colo.c +1 -1
index 1f8162f59f..694f3c93ef 100644
@@ -218,7 +218,7 @@ Connection *connection_get(GHashTable *connection_track_table,
             /*
              * clear the conn_list
              */
-            while (!g_queue_is_empty(conn_list)) {
+            while (conn_list && !g_queue_is_empty(conn_list)) {
                 connection_destroy(g_queue_pop_head(conn_list));
             }
         }
Signature · 1 line
2.25.1
author
#12 lore raw

PATCH v2 4/4 net/colo.c: fix segmentation fault when packet is not parsed correctly

In reply to Zhang Chen

When COLO use only one vnet_hdr_support parameter between filter-redirector and filter-mirror(or colo-compare), COLO will crash with segmentation fault. Back track as follow:

Thread 1 "qemu-system-x86" received signal SIGSEGV, Segmentation fault. 0x0000555555cb200b in eth_get_l2_hdr_length (p=0x0)
at /home/tao/project/COLO/colo-qemu/include/net/eth.h:296
296 uint16_t proto = be16_to_cpu(PKT_GET_ETH_HDR(p)->h_proto);
(gdb) bt
0 0x0000555555cb200b in eth_get_l2_hdr_length (p=0x0)
at /home/tao/project/COLO/colo-qemu/include/net/eth.h:296
1 0x0000555555cb22b4 in parse_packet_early (pkt=0x555556a44840) at net/colo.c:49
2 0x0000555555cb2b91 in is_tcp_packet (pkt=0x555556a44840) at net/filter-rewriter.c:63

So wrong vnet_hdr_len will cause pkt->data become NULL. Add check to raise error and add trace-events to track vnet_hdr_len.

---
 net/colo.c       | 9 ++++++++-
 net/trace-events | 1 +
 2 files changed, 9 insertions(+), 1 deletion(-)
net/colo.c +8 -1
index 694f3c93ef..6b0ff562ad 100644
@@ -46,7 +46,14 @@ int parse_packet_early(Packet *pkt)
     static const uint8_t vlan[] = {0x81, 0x00};
     uint8_t *data = pkt->data + pkt->vnet_hdr_len;
     uint16_t l3_proto;
-    ssize_t l2hdr_len = eth_get_l2_hdr_length(data);
+    ssize_t l2hdr_len;
+
+    if (data == NULL) {
+        trace_colo_proxy_main_vnet_info("This packet is not parsed correctly, "
+                                        "pkt->vnet_hdr_len", pkt->vnet_hdr_len);
+        return 1;
+    }
+    l2hdr_len = eth_get_l2_hdr_length(data);
 
     if (pkt->size < ETH_HLEN + pkt->vnet_hdr_len) {
         trace_colo_proxy_main("pkt->size < ETH_HLEN");
net/trace-events +1 -0
index d7a17256cc..6af927b4b9 100644
@@ -9,6 +9,7 @@ vhost_user_event(const char *chr, int event) "chr: %s got event: %d"
 
 # colo.c
 colo_proxy_main(const char *chr) ": %s"
+colo_proxy_main_vnet_info(const char *sta, int size) ": %s = %d"
 
 # colo-compare.c
 colo_compare_main(const char *chr) ": %s"
Signature · 1 line
2.25.1
#13 lore raw
In reply to Zhang Chen

No update for a while. Ping...

Thanks
Chen

Quoted 29 lines

-----Original Message-----
From: Zhang, Chen <[email protected]>
Sent: Friday, April 1, 2022 11:47 AM
To: Jason Wang <[email protected]>; Li Zhijian <[email protected]>
Cc: Zhang, Chen <[email protected]>; qemu-dev <qemu- [email protected]>
Subject: [PATCH V2 0/4] COLO net and runstate bugfix/optimization

This series fix some COLO related issues in internal stress testing.

- V2:
- Add more comments in patch 2/4 commit log.

Zhang Chen (4):
softmmu/runstate.c: add RunStateTransition support form COLO to
PRELAUNCH
net/colo: Fix a "double free" crash to clear the conn_list net/colo.c: No need to track conn_list for filter-rewriter net/colo.c: fix segmentation fault when packet is not parsed correctly

 net/colo-compare.c    |  2 +-
 net/colo.c            | 11 +++++++++--
 net/filter-rewriter.c |  2 +-
 net/trace-events      |  1 +
 softmmu/runstate.c    |  1 +
 5 files changed, 13 insertions(+), 4 deletions(-)

--
2.25.1

#14 lore raw
Quoted 5 lines · Chen

No update for a while. Ping...

Thanks
Chen

Hi:

It's near to release, I think we can queue this for 7.1?

Thanks

Quoted 31 lines
Quoted 30 lines

-----Original Message-----
From: Zhang, Chen <[email protected]>
Sent: Friday, April 1, 2022 11:47 AM
To: Jason Wang <[email protected]>; Li Zhijian <[email protected]>
Cc: Zhang, Chen <[email protected]>; qemu-dev <qemu- [email protected]>
Subject: [PATCH V2 0/4] COLO net and runstate bugfix/optimization

This series fix some COLO related issues in internal stress testing.

- V2:
- Add more comments in patch 2/4 commit log.

Zhang Chen (4):
softmmu/runstate.c: add RunStateTransition support form COLO to
PRELAUNCH
net/colo: Fix a "double free" crash to clear the conn_list net/colo.c: No need to track conn_list for filter-rewriter net/colo.c: fix segmentation fault when packet is not parsed correctly

 net/colo-compare.c    |  2 +-
 net/colo.c            | 11 +++++++++--
 net/filter-rewriter.c |  2 +-
 net/trace-events      |  1 +
 softmmu/runstate.c    |  1 +
 5 files changed, 13 insertions(+), 4 deletions(-)

--
2.25.1

#15 lore raw
Quoted 13 lines

-----Original Message-----
From: Jason Wang <[email protected]>
Sent: Thursday, April 14, 2022 11:12 AM
To: Zhang, Chen <[email protected]>
Cc: Li Zhijian <[email protected]>; qemu-dev <qemu- [email protected]>
Subject: Re: [PATCH V2 0/4] COLO net and runstate bugfix/optimization

Quoted 1 line · Chen
Quoted 8 lines
Quoted 4 lines

No update for a while. Ping...

Thanks
Chen

Hi:

It's near to release, I think we can queue this for 7.1?

Sure. I forgot to add "for 7.1" tag.

Thanks
Chen

Quoted 36 lines

Thanks

Quoted 33 lines
Quoted 32 lines

-----Original Message-----
From: Zhang, Chen <[email protected]>
Sent: Friday, April 1, 2022 11:47 AM
To: Jason Wang <[email protected]>; Li Zhijian <[email protected]>
Cc: Zhang, Chen <[email protected]>; qemu-dev <qemu- [email protected]>
Subject: [PATCH V2 0/4] COLO net and runstate bugfix/optimization

This series fix some COLO related issues in internal stress testing.

- V2:
- Add more comments in patch 2/4 commit log.

Zhang Chen (4):
softmmu/runstate.c: add RunStateTransition support form COLO to
PRELAUNCH
net/colo: Fix a "double free" crash to clear the conn_list net/colo.c: No need to track conn_list for filter-rewriter net/colo.c: fix segmentation fault when packet is not parsed
correctly

 net/colo-compare.c    |  2 +-
 net/colo.c            | 11 +++++++++--
 net/filter-rewriter.c |  2 +-
 net/trace-events      |  1 +
 softmmu/runstate.c    |  1 +
 5 files changed, 13 insertions(+), 4 deletions(-)

--
2.25.1