|
From: | Zhang Chen |
Subject: | Re: [Qemu-devel] [PATCH V4 06/12] net/colo-compare.c: Add new option to enable vnet support for colo-compare |
Date: | Mon, 15 May 2017 15:55:36 +0800 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 |
On 05/15/2017 12:03 PM, Jason Wang wrote:
On 2017年05月12日 09:41, Zhang Chen wrote:We add the vnet_hdr option for colo-compare, default is disable. If you use virtio-net-pci net driver, please enable it. You can use it for example:-object colo-compare,id=comp0,primary_in=compare0-0,secondary_in=compare1,outdev=compare_out0,vnet_hdr=onSigned-off-by: Zhang Chen <address@hidden> --- net/colo-compare.c | 34 +++++++++++++++++++++++++++++++++- qemu-options.hx | 3 ++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 332f57e..99a6912 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -73,6 +73,7 @@ typedef struct CompareState { CharBackend chr_out; SocketReadState pri_rs; SocketReadState sec_rs; + bool vnet_hdr;/* connection list: the connections belonged to this NIC could be found* in this list.@@ -642,6 +643,28 @@ static void compare_set_outdev(Object *obj, const char *value, Error **errp)s->outdev = g_strdup(value); } +static char *compare_get_vnet_hdr(Object *obj, Error **errp) +{ + CompareState *s = COLO_COMPARE(obj); + + return s->vnet_hdr ? g_strdup("on") : g_strdup("off"); +} + +static void compare_set_vnet_hdr(Object *obj, + const char *value, + Error **errp) +{ + CompareState *s = COLO_COMPARE(obj); + + if (strcmp(value, "on") && strcmp(value, "off")) { + error_setg(errp, "Invalid value for colo-compare vnet_hdr, " + "should be 'on' or 'off'"); + return; + } + + s->vnet_hdr = !strcmp(value, "on"); +} + static void compare_pri_rs_finalize(SocketReadState *pri_rs) { CompareState *s = container_of(pri_rs, CompareState, pri_rs);@@ -667,7 +690,6 @@ static void compare_sec_rs_finalize(SocketReadState *sec_rs)} } -Unnecessary whitespace change.
I will remove it in next version.
/* * Return 0 is success. * Return 1 is failed.@@ -775,6 +797,8 @@ static void colo_compare_class_init(ObjectClass *oc, void *data)static void colo_compare_init(Object *obj) { + CompareState *s = COLO_COMPARE(obj); + object_property_add_str(obj, "primary_in",compare_get_pri_indev, compare_set_pri_indev,NULL); @@ -784,6 +808,14 @@ static void colo_compare_init(Object *obj) object_property_add_str(obj, "outdev", compare_get_outdev, compare_set_outdev, NULL); + /* + * The vnet_hdr is disabled by default, if you want to enable + * this option, you must enable all the option on related modules + * (like other filter or colo-compare). + */ + s->vnet_hdr = false; + object_property_add_str(obj, "vnet_hdr", compare_get_vnet_hdr, + compare_set_vnet_hdr, NULL); } static void colo_compare_finalize(Object *obj) diff --git a/qemu-options.hx b/qemu-options.hx index 0f81c22..115b83f 100644 --- a/qemu-options.hx +++ b/qemu-options.hx@@ -4061,12 +4061,13 @@ The file format is libpcap, so it can be analyzed with tools such as tcpdumpor Wireshark.@item -object colo-compare,address@hidden,address@hidden,address@hidden,address@hidden address@hidden,address@hidden|off}Colo-compare gets packet from address@hidden and address@hidden, than compare primary packet withsecondary packet. If the packets are same, we will output primary packet to address@hidden, else we will notify colo-frame do checkpoint and send primary packet to address@hidden +if vnet_hdr = on, colo compare will send/recv packet with vnet_hdr_len. we must use it with the help of filter-mirror and filter-redirector.Please squash this into its function implementation.
OK. Thanks Zhang Chen
Thanks .
-- Thanks Zhang Chen
[Prev in Thread] | Current Thread | [Next in Thread] |