All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] net/colo-compare.c: Expose more COLO internal
@ 2020-02-23 20:58 Zhang Chen
  2020-02-23 20:58 ` [PATCH 1/2] net/colo-compare.c: Expose "compare_timeout" to user Zhang Chen
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Zhang Chen @ 2020-02-23 20:58 UTC (permalink / raw)
  To: Jason Wang, qemu-dev
  Cc: Daniel Cho, Zhang Chen, Dr . David Alan Gilbert, Zhang Chen

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

Make a way to config COLO parameter detailed according to user cases
and environment.

Zhang Chen (2):
  net/colo-compare.c: Expose "compare_timeout" to user
  net/colo-compare.c: Expose "expired_scan_cycle" to user

 net/colo-compare.c | 95 +++++++++++++++++++++++++++++++++++++++++++---
 qemu-options.hx    |  6 ++-
 2 files changed, 94 insertions(+), 7 deletions(-)

-- 
2.17.1



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

* [PATCH 1/2] net/colo-compare.c: Expose "compare_timeout" to user
  2020-02-23 20:58 [PATCH 0/2] net/colo-compare.c: Expose more COLO internal Zhang Chen
@ 2020-02-23 20:58 ` Zhang Chen
  2020-02-23 20:58 ` [PATCH 2/2] net/colo-compare.c: Expose "expired_scan_cycle" " Zhang Chen
  2020-03-04  7:59 ` [PATCH 0/2] net/colo-compare.c: Expose more COLO internal Zhang, Chen
  2 siblings, 0 replies; 7+ messages in thread
From: Zhang Chen @ 2020-02-23 20:58 UTC (permalink / raw)
  To: Jason Wang, qemu-dev
  Cc: Daniel Cho, Zhang Chen, Dr . David Alan Gilbert, Zhang Chen

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

The "compare_timeout" determines the max time to hold the primary net packet.
This patch expose the "compare_timeout", make user can
adjest this value according to the specific application scenario.

QMP command demo:
    { "execute": "qom-get",
         "arguments": { "path": "/objects/comp0",
                        "property": "compare_timeout" } }

    { "execute": "qom-set",
         "arguments": { "path": "/objects/comp0",
                        "property": "compare_timeout",
                        "value": 5000} }

Signed-off-by: Zhang Chen <chen.zhang@intel.com>
---
 net/colo-compare.c | 47 ++++++++++++++++++++++++++++++++++++++++++++--
 qemu-options.hx    |  5 +++--
 2 files changed, 48 insertions(+), 4 deletions(-)

diff --git a/net/colo-compare.c b/net/colo-compare.c
index 7ee17f2cf8..ec09b2a524 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -50,6 +50,7 @@ static NotifierList colo_compare_notifiers =
 
 /* TODO: Should be configurable */
 #define REGULAR_PACKET_CHECK_MS 3000
+#define DEFAULT_TIME_OUT_MS 3000
 
 static QemuMutex event_mtx;
 static QemuCond event_complete_cond;
@@ -92,6 +93,7 @@ typedef struct CompareState {
     SocketReadState sec_rs;
     SocketReadState notify_rs;
     bool vnet_hdr;
+    uint32_t compare_timeout;
 
     /*
      * Record the connection that through the NIC
@@ -607,10 +609,9 @@ static int colo_old_packet_check_one_conn(Connection *conn,
                                           CompareState *s)
 {
     GList *result = NULL;
-    int64_t check_time = REGULAR_PACKET_CHECK_MS;
 
     result = g_queue_find_custom(&conn->primary_list,
-                                 &check_time,
+                                 &s->compare_timeout,
                                  (GCompareFunc)colo_old_packet_check_one);
 
     if (result) {
@@ -984,6 +985,39 @@ static void compare_set_notify_dev(Object *obj, const char *value, Error **errp)
     s->notify_dev = g_strdup(value);
 }
 
+static void compare_get_timeout(Object *obj, Visitor *v,
+                                const char *name, void *opaque,
+                                Error **errp)
+{
+    CompareState *s = COLO_COMPARE(obj);
+    uint32_t value = s->compare_timeout;
+
+    visit_type_uint32(v, name, &value, errp);
+}
+
+static void compare_set_timeout(Object *obj, Visitor *v,
+                                const char *name, void *opaque,
+                                Error **errp)
+{
+    CompareState *s = COLO_COMPARE(obj);
+    Error *local_err = NULL;
+    uint32_t value;
+
+    visit_type_uint32(v, name, &value, &local_err);
+    if (local_err) {
+        goto out;
+    }
+    if (!value) {
+        error_setg(&local_err, "Property '%s.%s' requires a positive value",
+                   object_get_typename(obj), name);
+        goto out;
+    }
+    s->compare_timeout = value;
+
+out:
+    error_propagate(errp, local_err);
+}
+
 static void compare_pri_rs_finalize(SocketReadState *pri_rs)
 {
     CompareState *s = container_of(pri_rs, CompareState, pri_rs);
@@ -1090,6 +1124,11 @@ static void colo_compare_complete(UserCreatable *uc, Error **errp)
         return;
     }
 
+    if (!s->compare_timeout) {
+        /* Set default value to 3000 MS */
+        s->compare_timeout = DEFAULT_TIME_OUT_MS;
+    }
+
     if (find_and_check_chardev(&chr, s->pri_indev, errp) ||
         !qemu_chr_fe_init(&s->chr_pri_in, chr, errp)) {
         return;
@@ -1185,6 +1224,10 @@ static void colo_compare_init(Object *obj)
                             compare_get_notify_dev, compare_set_notify_dev,
                             NULL);
 
+    object_property_add(obj, "compare_timeout", "uint32",
+                        compare_get_timeout,
+                        compare_set_timeout, NULL, NULL, NULL);
+
     s->vnet_hdr = false;
     object_property_add_bool(obj, "vnet_hdr_support", compare_get_vnet_hdr,
                              compare_set_vnet_hdr, NULL);
diff --git a/qemu-options.hx b/qemu-options.hx
index ac315c1ac4..3832d0ae8a 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -4598,7 +4598,7 @@ Dump the network traffic on netdev @var{dev} to the file specified by
 The file format is libpcap, so it can be analyzed with tools such as tcpdump
 or Wireshark.
 
-@item -object colo-compare,id=@var{id},primary_in=@var{chardevid},secondary_in=@var{chardevid},outdev=@var{chardevid},iothread=@var{id}[,vnet_hdr_support][,notify_dev=@var{id}]
+@item -object colo-compare,id=@var{id},primary_in=@var{chardevid},secondary_in=@var{chardevid},outdev=@var{chardevid},iothread=@var{id}[,vnet_hdr_support][,notify_dev=@var{id}][,compare_timeout=@var{ms}]
 
 Colo-compare gets packet from primary_in@var{chardevid} and secondary_in@var{chardevid}, than compare primary packet with
 secondary packet. If the packets are same, we will output primary
@@ -4606,7 +4606,8 @@ packet to outdev@var{chardevid}, else we will notify colo-frame
 do checkpoint and send primary packet to outdev@var{chardevid}.
 In order to improve efficiency, we need to put the task of comparison
 in another thread. If it has the vnet_hdr_support flag, colo compare
-will send/recv packet with vnet_hdr_len.
+will send/recv packet with vnet_hdr_len. The compare_timeout=@var{ms}
+determines the maximum time colo-compare wait for primary packet.
 If you want to use Xen COLO, will need the notify_dev to notify Xen
 colo-frame to do checkpoint.
 
-- 
2.17.1



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

* [PATCH 2/2] net/colo-compare.c: Expose "expired_scan_cycle" to user
  2020-02-23 20:58 [PATCH 0/2] net/colo-compare.c: Expose more COLO internal Zhang Chen
  2020-02-23 20:58 ` [PATCH 1/2] net/colo-compare.c: Expose "compare_timeout" to user Zhang Chen
@ 2020-02-23 20:58 ` Zhang Chen
  2020-03-04  7:59 ` [PATCH 0/2] net/colo-compare.c: Expose more COLO internal Zhang, Chen
  2 siblings, 0 replies; 7+ messages in thread
From: Zhang Chen @ 2020-02-23 20:58 UTC (permalink / raw)
  To: Jason Wang, qemu-dev
  Cc: Daniel Cho, Zhang Chen, Dr . David Alan Gilbert, Zhang Chen

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

The "expired_scan_cycle" determines colo-compare scan expired
net packet cycle.

Signed-off-by: Zhang Chen <chen.zhang@intel.com>
---
 net/colo-compare.c | 48 +++++++++++++++++++++++++++++++++++++++++++---
 qemu-options.hx    |  3 ++-
 2 files changed, 47 insertions(+), 4 deletions(-)

diff --git a/net/colo-compare.c b/net/colo-compare.c
index ec09b2a524..10c0239f9d 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -48,7 +48,6 @@ static NotifierList colo_compare_notifiers =
 #define COLO_COMPARE_FREE_PRIMARY     0x01
 #define COLO_COMPARE_FREE_SECONDARY   0x02
 
-/* TODO: Should be configurable */
 #define REGULAR_PACKET_CHECK_MS 3000
 #define DEFAULT_TIME_OUT_MS 3000
 
@@ -94,6 +93,7 @@ typedef struct CompareState {
     SocketReadState notify_rs;
     bool vnet_hdr;
     uint32_t compare_timeout;
+    uint32_t expired_scan_cycle;
 
     /*
      * Record the connection that through the NIC
@@ -823,7 +823,7 @@ static void check_old_packet_regular(void *opaque)
     /* if have old packet we will notify checkpoint */
     colo_old_packet_check(s);
     timer_mod(s->packet_check_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) +
-                REGULAR_PACKET_CHECK_MS);
+              s->expired_scan_cycle);
 }
 
 /* Public API, Used for COLO frame to notify compare event */
@@ -853,7 +853,7 @@ static void colo_compare_timer_init(CompareState *s)
                                 SCALE_MS, check_old_packet_regular,
                                 s);
     timer_mod(s->packet_check_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) +
-                    REGULAR_PACKET_CHECK_MS);
+              s->expired_scan_cycle);
 }
 
 static void colo_compare_timer_del(CompareState *s)
@@ -1018,6 +1018,39 @@ out:
     error_propagate(errp, local_err);
 }
 
+static void compare_get_expired_scan_cycle(Object *obj, Visitor *v,
+                                           const char *name, void *opaque,
+                                           Error **errp)
+{
+    CompareState *s = COLO_COMPARE(obj);
+    uint32_t value = s->expired_scan_cycle;
+
+    visit_type_uint32(v, name, &value, errp);
+}
+
+static void compare_set_expired_scan_cycle(Object *obj, Visitor *v,
+                                           const char *name, void *opaque,
+                                           Error **errp)
+{
+    CompareState *s = COLO_COMPARE(obj);
+    Error *local_err = NULL;
+    uint32_t value;
+
+    visit_type_uint32(v, name, &value, &local_err);
+    if (local_err) {
+        goto out;
+    }
+    if (!value) {
+        error_setg(&local_err, "Property '%s.%s' requires a positive value",
+                   object_get_typename(obj), name);
+        goto out;
+    }
+    s->expired_scan_cycle = value;
+
+out:
+    error_propagate(errp, local_err);
+}
+
 static void compare_pri_rs_finalize(SocketReadState *pri_rs)
 {
     CompareState *s = container_of(pri_rs, CompareState, pri_rs);
@@ -1129,6 +1162,11 @@ static void colo_compare_complete(UserCreatable *uc, Error **errp)
         s->compare_timeout = DEFAULT_TIME_OUT_MS;
     }
 
+    if (!s->expired_scan_cycle) {
+        /* Set default value to 3000 MS */
+        s->expired_scan_cycle = REGULAR_PACKET_CHECK_MS;
+    }
+
     if (find_and_check_chardev(&chr, s->pri_indev, errp) ||
         !qemu_chr_fe_init(&s->chr_pri_in, chr, errp)) {
         return;
@@ -1228,6 +1266,10 @@ static void colo_compare_init(Object *obj)
                         compare_get_timeout,
                         compare_set_timeout, NULL, NULL, NULL);
 
+    object_property_add(obj, "expired_scan_cycle", "uint32",
+                        compare_get_expired_scan_cycle,
+                        compare_set_expired_scan_cycle, NULL, NULL, NULL);
+
     s->vnet_hdr = false;
     object_property_add_bool(obj, "vnet_hdr_support", compare_get_vnet_hdr,
                              compare_set_vnet_hdr, NULL);
diff --git a/qemu-options.hx b/qemu-options.hx
index 3832d0ae8a..8069428c73 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -4598,7 +4598,7 @@ Dump the network traffic on netdev @var{dev} to the file specified by
 The file format is libpcap, so it can be analyzed with tools such as tcpdump
 or Wireshark.
 
-@item -object colo-compare,id=@var{id},primary_in=@var{chardevid},secondary_in=@var{chardevid},outdev=@var{chardevid},iothread=@var{id}[,vnet_hdr_support][,notify_dev=@var{id}][,compare_timeout=@var{ms}]
+@item -object colo-compare,id=@var{id},primary_in=@var{chardevid},secondary_in=@var{chardevid},outdev=@var{chardevid},iothread=@var{id}[,vnet_hdr_support][,notify_dev=@var{id}][,compare_timeout=@var{ms}][,expired_scan_cycle=@var{ms}]
 
 Colo-compare gets packet from primary_in@var{chardevid} and secondary_in@var{chardevid}, than compare primary packet with
 secondary packet. If the packets are same, we will output primary
@@ -4608,6 +4608,7 @@ In order to improve efficiency, we need to put the task of comparison
 in another thread. If it has the vnet_hdr_support flag, colo compare
 will send/recv packet with vnet_hdr_len. The compare_timeout=@var{ms}
 determines the maximum time colo-compare wait for primary packet.
+The expired_scan_cycle=@var{ms} to set the expired packet scan cycle.
 If you want to use Xen COLO, will need the notify_dev to notify Xen
 colo-frame to do checkpoint.
 
-- 
2.17.1



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

* RE: [PATCH 0/2] net/colo-compare.c: Expose more COLO internal
  2020-02-23 20:58 [PATCH 0/2] net/colo-compare.c: Expose more COLO internal Zhang Chen
  2020-02-23 20:58 ` [PATCH 1/2] net/colo-compare.c: Expose "compare_timeout" to user Zhang Chen
  2020-02-23 20:58 ` [PATCH 2/2] net/colo-compare.c: Expose "expired_scan_cycle" " Zhang Chen
@ 2020-03-04  7:59 ` Zhang, Chen
  2020-03-17  8:25   ` Zhang, Chen
  2 siblings, 1 reply; 7+ messages in thread
From: Zhang, Chen @ 2020-03-04  7:59 UTC (permalink / raw)
  To: Jason Wang, qemu-dev; +Cc: Daniel Cho, Dr . David Alan Gilbert, Zhang Chen

Hi all,

Please give me some comments, this patch need by users(QNAP...).

Thanks
Zhang Chen

> -----Original Message-----
> From: Zhang, Chen <chen.zhang@intel.com>
> Sent: Monday, February 24, 2020 4:58 AM
> To: Jason Wang <jasowang@redhat.com>; qemu-dev <qemu-
> devel@nongnu.org>
> Cc: Zhang Chen <zhangckid@gmail.com>; Dr . David Alan Gilbert
> <dgilbert@redhat.com>; Daniel Cho <danielcho@qnap.com>; Zhang, Chen
> <chen.zhang@intel.com>
> Subject: [PATCH 0/2] net/colo-compare.c: Expose more COLO internal
> 
> From: Zhang Chen <chen.zhang@intel.com>
> 
> Make a way to config COLO parameter detailed according to user cases and
> environment.
> 
> Zhang Chen (2):
>   net/colo-compare.c: Expose "compare_timeout" to user
>   net/colo-compare.c: Expose "expired_scan_cycle" to user
> 
>  net/colo-compare.c | 95
> +++++++++++++++++++++++++++++++++++++++++++---
>  qemu-options.hx    |  6 ++-
>  2 files changed, 94 insertions(+), 7 deletions(-)
> 
> --
> 2.17.1



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

* RE: [PATCH 0/2] net/colo-compare.c: Expose more COLO internal
  2020-03-04  7:59 ` [PATCH 0/2] net/colo-compare.c: Expose more COLO internal Zhang, Chen
@ 2020-03-17  8:25   ` Zhang, Chen
  2020-03-18  2:47     ` Jason Wang
  0 siblings, 1 reply; 7+ messages in thread
From: Zhang, Chen @ 2020-03-17  8:25 UTC (permalink / raw)
  To: Zhang, Chen, Jason Wang, qemu-dev
  Cc: Daniel Cho, Dr . David Alan Gilbert, Zhang Chen

Hi Jason,

No news for a while.
Please review this series when you have time.

Thanks
Zhang Chen 

> -----Original Message-----
> From: Qemu-devel <qemu-devel-
> bounces+chen.zhang=intel.com@nongnu.org> On Behalf Of Zhang, Chen
> Sent: Wednesday, March 4, 2020 4:00 PM
> To: Jason Wang <jasowang@redhat.com>; qemu-dev <qemu-
> devel@nongnu.org>
> Cc: Daniel Cho <danielcho@qnap.com>; Dr . David Alan Gilbert
> <dgilbert@redhat.com>; Zhang Chen <zhangckid@gmail.com>
> Subject: RE: [PATCH 0/2] net/colo-compare.c: Expose more COLO internal
> 
> Hi all,
> 
> Please give me some comments, this patch need by users(QNAP...).
> 
> Thanks
> Zhang Chen
> 
> > -----Original Message-----
> > From: Zhang, Chen <chen.zhang@intel.com>
> > Sent: Monday, February 24, 2020 4:58 AM
> > To: Jason Wang <jasowang@redhat.com>; qemu-dev <qemu-
> > devel@nongnu.org>
> > Cc: Zhang Chen <zhangckid@gmail.com>; Dr . David Alan Gilbert
> > <dgilbert@redhat.com>; Daniel Cho <danielcho@qnap.com>; Zhang, Chen
> > <chen.zhang@intel.com>
> > Subject: [PATCH 0/2] net/colo-compare.c: Expose more COLO internal
> >
> > From: Zhang Chen <chen.zhang@intel.com>
> >
> > Make a way to config COLO parameter detailed according to user cases
> > and environment.
> >
> > Zhang Chen (2):
> >   net/colo-compare.c: Expose "compare_timeout" to user
> >   net/colo-compare.c: Expose "expired_scan_cycle" to user
> >
> >  net/colo-compare.c | 95
> > +++++++++++++++++++++++++++++++++++++++++++---
> >  qemu-options.hx    |  6 ++-
> >  2 files changed, 94 insertions(+), 7 deletions(-)
> >
> > --
> > 2.17.1
> 



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

* Re: [PATCH 0/2] net/colo-compare.c: Expose more COLO internal
  2020-03-17  8:25   ` Zhang, Chen
@ 2020-03-18  2:47     ` Jason Wang
  2020-03-18  7:00       ` Zhang, Chen
  0 siblings, 1 reply; 7+ messages in thread
From: Jason Wang @ 2020-03-18  2:47 UTC (permalink / raw)
  To: Zhang, Chen, qemu-dev; +Cc: Daniel Cho, Dr . David Alan Gilbert, Zhang Chen


On 2020/3/17 下午4:25, Zhang, Chen wrote:
> Hi Jason,
>
> No news for a while.
> Please review this series when you have time.
>
> Thanks
> Zhang Chen


Sorry for the delay.

Patch looks good to me.

But it can not be applied cleanly on master.

Please rebase and send V2 (btw, I notice some typos in the commit log, 
please try to fix them as well).

Thanks



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

* RE: [PATCH 0/2] net/colo-compare.c: Expose more COLO internal
  2020-03-18  2:47     ` Jason Wang
@ 2020-03-18  7:00       ` Zhang, Chen
  0 siblings, 0 replies; 7+ messages in thread
From: Zhang, Chen @ 2020-03-18  7:00 UTC (permalink / raw)
  To: Jason Wang, qemu-dev; +Cc: Daniel Cho, Dr . David Alan Gilbert, Zhang Chen



> -----Original Message-----
> From: Jason Wang <jasowang@redhat.com>
> Sent: Wednesday, March 18, 2020 10:48 AM
> To: Zhang, Chen <chen.zhang@intel.com>; qemu-dev <qemu-
> devel@nongnu.org>
> Cc: Daniel Cho <danielcho@qnap.com>; Dr . David Alan Gilbert
> <dgilbert@redhat.com>; Zhang Chen <zhangckid@gmail.com>
> Subject: Re: [PATCH 0/2] net/colo-compare.c: Expose more COLO internal
> 
> 
> On 2020/3/17 下午4:25, Zhang, Chen wrote:
> > Hi Jason,
> >
> > No news for a while.
> > Please review this series when you have time.
> >
> > Thanks
> > Zhang Chen
> 
> 
> Sorry for the delay.
> 
> Patch looks good to me.
> 
> But it can not be applied cleanly on master.
> 
> Please rebase and send V2 (btw, I notice some typos in the commit log,
> please try to fix them as well).

Sure.

Thanks
Zhang Chen

> 
> Thanks


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

end of thread, other threads:[~2020-03-18  7:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-23 20:58 [PATCH 0/2] net/colo-compare.c: Expose more COLO internal Zhang Chen
2020-02-23 20:58 ` [PATCH 1/2] net/colo-compare.c: Expose "compare_timeout" to user Zhang Chen
2020-02-23 20:58 ` [PATCH 2/2] net/colo-compare.c: Expose "expired_scan_cycle" " Zhang Chen
2020-03-04  7:59 ` [PATCH 0/2] net/colo-compare.c: Expose more COLO internal Zhang, Chen
2020-03-17  8:25   ` Zhang, Chen
2020-03-18  2:47     ` Jason Wang
2020-03-18  7:00       ` Zhang, Chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.