From: Zhang Chen <chen.zhang@intel.com >
To: Jason Wang <jasowang@redhat.com>, qemu-dev <qemu-devel@nongnu.org>
Cc: Zhang Chen <chen.zhang@intel.com>, Zhang Chen <zhangckid@gmail.com>
Subject: [PATCH 1/2] net/colo-compare.c: Expose compare "max_queue_size" to users
Date: Sat, 11 Apr 2020 11:38:23 +0800 [thread overview]
Message-ID: <20200411033824.19389-2-chen.zhang@intel.com> (raw)
In-Reply-To: <20200411033824.19389-1-chen.zhang@intel.com>
From: Zhang Chen <chen.zhang@intel.com>
This patch allow users to set the "max_queue_size" according
to their environment.
Signed-off-by: Zhang Chen <chen.zhang@intel.com>
---
net/colo-compare.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
qemu-options.hx | 5 +++--
2 files changed, 45 insertions(+), 3 deletions(-)
diff --git a/net/colo-compare.c b/net/colo-compare.c
index 10c0239f9d..def60ff2ea 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -54,6 +54,7 @@ static NotifierList colo_compare_notifiers =
static QemuMutex event_mtx;
static QemuCond event_complete_cond;
static int event_unhandled_count;
+static uint32_t max_queue_size;
/*
* + CompareState ++
@@ -193,7 +194,7 @@ static void fill_pkt_tcp_info(void *data, uint32_t *max_ack)
*/
static int colo_insert_packet(GQueue *queue, Packet *pkt, uint32_t *max_ack)
{
- if (g_queue_get_length(queue) <= MAX_QUEUE_SIZE) {
+ if (g_queue_get_length(queue) <= max_queue_size) {
if (pkt->ip->ip_p == IPPROTO_TCP) {
fill_pkt_tcp_info(pkt, max_ack);
g_queue_insert_sorted(queue,
@@ -1051,6 +1052,37 @@ out:
error_propagate(errp, local_err);
}
+static void get_max_queue_size(Object *obj, Visitor *v,
+ const char *name, void *opaque,
+ Error **errp)
+{
+ uint32_t value = max_queue_size;
+
+ visit_type_uint32(v, name, &value, errp);
+}
+
+static void set_max_queue_size(Object *obj, Visitor *v,
+ const char *name, void *opaque,
+ Error **errp)
+{
+ 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;
+ }
+ max_queue_size = 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);
@@ -1167,6 +1199,11 @@ static void colo_compare_complete(UserCreatable *uc, Error **errp)
s->expired_scan_cycle = REGULAR_PACKET_CHECK_MS;
}
+ if (!max_queue_size) {
+ /* Set default queue size to 1024 */
+ max_queue_size = MAX_QUEUE_SIZE;
+ }
+
if (find_and_check_chardev(&chr, s->pri_indev, errp) ||
!qemu_chr_fe_init(&s->chr_pri_in, chr, errp)) {
return;
@@ -1270,6 +1307,10 @@ static void colo_compare_init(Object *obj)
compare_get_expired_scan_cycle,
compare_set_expired_scan_cycle, NULL, NULL, NULL);
+ object_property_add(obj, "max_queue_size", "uint32",
+ get_max_queue_size,
+ set_max_queue_size, 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 16debd03cb..107ff3e71b 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}][,expired_scan_cycle=@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}][,max_queue_size=@var{size}]``
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
@@ -4627,7 +4627,8 @@ SRST
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.
+ expired primary node network packets. The max\_queue\_size=@var{size}
+ is to set the max compare queue size depend on user environment.
If you want to use Xen COLO, will need the notify\_dev to
notify Xen colo-frame to do checkpoint.
--
2.17.1
next prev parent reply other threads:[~2020-04-11 3:48 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-11 3:38 [PATCH 0/2] net/colo-compare.c: Expose "max_queue_size" to users and clean up Zhang Chen
2020-04-11 3:38 ` Zhang Chen [this message]
2020-04-11 3:38 ` [PATCH 2/2] qemu-options.hx: Clean up and fix typo for colo-compare Zhang Chen
2020-04-23 7:31 ` [PATCH 0/2] net/colo-compare.c: Expose "max_queue_size" to users and clean up Zhang, Chen
2020-04-23 8:54 ` Jason Wang
2020-04-23 8:59 ` Zhang, Chen
2020-04-23 9:07 ` Jason Wang
2020-04-24 1:26 ` Zhang, Chen
2020-04-24 2:19 ` Jason Wang
2020-06-19 17:46 ` Lukas Straub
2020-06-23 1:47 ` Zhang, Chen
2020-06-23 5:53 ` Jason Wang
2020-06-24 3:13 ` Zhang, Chen
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=20200411033824.19389-2-chen.zhang@intel.com \
--to=chen.zhang@intel.com \
--cc=jasowang@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=zhangckid@gmail.com \
/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).