From: Jason Wang <jasowang@redhat.com>
To: qemu-devel@nongnu.org, peter.maydell@linaro.org
Cc: Zhang Chen <chen.zhang@intel.com>, Jason Wang <jasowang@redhat.com>
Subject: [PULL V2 11/14] net/colo-compare.c: Expose "expired_scan_cycle" to users
Date: Tue, 31 Mar 2020 21:21:36 +0800 [thread overview]
Message-ID: <1585660899-11228-12-git-send-email-jasowang@redhat.com> (raw)
In-Reply-To: <1585660899-11228-1-git-send-email-jasowang@redhat.com>
From: Zhang Chen <chen.zhang@intel.com>
The "expired_scan_cycle" determines period of scanning expired
primary node net packets.
Signed-off-by: Zhang Chen <chen.zhang@intel.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
net/colo-compare.c | 48 +++++++++++++++++++++++++++++++++++++++++++++---
qemu-options.hx | 4 +++-
2 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/net/colo-compare.c b/net/colo-compare.c
index ec09b2a..10c0239 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 9e48e13..16debd0 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -4615,7 +4615,7 @@ SRST
stored. The file format is libpcap, so it can be analyzed with
tools such as tcpdump or Wireshark.
- ``-object colo-compare,id=id,primary_in=chardevid,secondary_in=chardevid,outdev=chardevid,iothread=id[,vnet_hdr_support][,notify_dev=id][,compare_timeout=@var{ms}]``
+ ``-object colo-compare,id=id,primary_in=chardevid,secondary_in=chardevid,outdev=chardevid,iothread=id[,vnet_hdr_support][,notify_dev=id][,compare_timeout=@var{ms}][,expired_scan_cycle=@var{ms}``
Colo-compare gets packet from primary\_inchardevid and
secondary\_inchardevid, than compare primary packet with
secondary packet. If the packets are same, we will output
@@ -4626,6 +4626,8 @@ SRST
vnet\_hdr\_support flag, colo compare will send/recv packet with
vnet\_hdr\_len. Then compare\_timeout=@var{ms} determines the
maximum delay colo-compare wait for the packet.
+ The expired\_scan\_cycle=@var{ms} to set the period of scanning
+ expired primary node network packets.
If you want to use Xen COLO, will need the notify\_dev to
notify Xen colo-frame to do checkpoint.
--
2.5.0
next prev parent reply other threads:[~2020-03-31 13:25 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-31 13:21 [PULL V2 00/14] Net patches Jason Wang
2020-03-31 13:21 ` [PULL V2 01/14] hw/net/i82596: Correct command bitmask (CID 1419392) Jason Wang
2020-03-31 13:21 ` [PULL V2 02/14] hw/net/i82596.c: Avoid reading off end of buffer in i82596_receive() Jason Wang
2020-03-31 13:21 ` [PULL V2 03/14] Fixed integer overflow in e1000e Jason Wang
2020-03-31 13:21 ` [PULL V2 04/14] hw/net/e1000e_core: Let e1000e_can_receive() return a boolean Jason Wang
2020-03-31 13:21 ` [PULL V2 05/14] hw/net/smc91c111: Let smc91c111_can_receive() " Jason Wang
2020-03-31 13:21 ` [PULL V2 06/14] hw/net/rtl8139: Simplify if/else statement Jason Wang
2020-03-31 13:21 ` [PULL V2 07/14] hw/net/rtl8139: Update coding style to make checkpatch.pl happy Jason Wang
2020-03-31 13:21 ` [PULL V2 08/14] hw/net: Make NetCanReceive() return a boolean Jason Wang
2020-03-31 13:21 ` [PULL V2 09/14] hw/net/can: Make CanBusClientInfo::can_receive() " Jason Wang
2020-03-31 13:21 ` [PULL V2 10/14] net/colo-compare.c: Expose "compare_timeout" to users Jason Wang
2020-03-31 13:21 ` Jason Wang [this message]
2020-03-31 13:21 ` [PULL V2 12/14] net: tulip: check frame size and r/w data length Jason Wang
2020-03-31 13:21 ` [PULL V2 13/14] hw/net/allwinner-sun8i-emac.c: Fix REG_ADDR_HIGH/LOW reads Jason Wang
2020-03-31 13:21 ` [PULL V2 14/14] qtest: add tulip test case Jason Wang
2020-03-31 14:36 ` [PULL V2 00/14] Net patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1585660899-11228-12-git-send-email-jasowang@redhat.com \
--to=jasowang@redhat.com \
--cc=chen.zhang@intel.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).