qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] net/colo-compare.c: Fix memory leak and code style issue.
@ 2019-07-03  1:38 Zhang Chen
  2019-07-03  6:06 ` no-reply
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Zhang Chen @ 2019-07-03  1:38 UTC (permalink / raw)
  To: Li Zhijian, Peter Maydell, Jason Wang, qemu-dev; +Cc: Zhang Chen, Zhang Chen

From: Zhang Chen <chen.zhang@intel.com>

Address Peter's comments in patch "COLO-compare:Add colo-compare
remote notify support".

Signed-off-by: Zhang Chen <chen.zhang@intel.com>
---
 net/colo-compare.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/net/colo-compare.c b/net/colo-compare.c
index 909dd6c6eb..363b1edd11 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -1008,21 +1008,20 @@ static void compare_notify_rs_finalize(SocketReadState *notify_rs)
 {
     CompareState *s = container_of(notify_rs, CompareState, notify_rs);
 
-    /* Get Xen colo-frame's notify and handle the message */
-    char *data = g_memdup(notify_rs->buf, notify_rs->packet_len);
-    char msg[] = "COLO_COMPARE_GET_XEN_INIT";
+    const char msg[] = "COLO_COMPARE_GET_XEN_INIT";
     int ret;
 
-    if (!strcmp(data, "COLO_USERSPACE_PROXY_INIT")) {
+    if (!strcmp((char *)notify_rs->buf, "COLO_USERSPACE_PROXY_INIT")) {
         ret = compare_chr_send(s, (uint8_t *)msg, strlen(msg), 0, true);
         if (ret < 0) {
             error_report("Notify Xen COLO-frame INIT failed");
         }
-    }
-
-    if (!strcmp(data, "COLO_CHECKPOINT")) {
+    } else if (!strcmp((char *)notify_rs->buf, "COLO_CHECKPOINT")) {
         /* colo-compare do checkpoint, flush pri packet and remove sec packet */
         g_queue_foreach(&s->conn_list, colo_flush_packets, s);
+    } else {
+        error_report("COLO compare got unsupported instruction '%s'",
+                     (char *)notify_rs->buf);
     }
 }
 
-- 
2.17.GIT



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-07-04  8:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-03  1:38 [Qemu-devel] [PATCH] net/colo-compare.c: Fix memory leak and code style issue Zhang Chen
2019-07-03  6:06 ` no-reply
2019-07-03  8:56 ` Philippe Mathieu-Daudé
2019-07-04  3:44   ` Zhang, Chen
2019-07-03 10:15 ` no-reply
2019-07-03 10:30 ` Peter Maydell
2019-07-04  8:30   ` Zhang, Chen

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).