1
The following changes since commit 6632f6ff96f0537fc34cdc00c760656fc62e23c5:
1
The following changes since commit 136c67e07869227b21b3f627316e03679ce7b738:
2
2
3
Merge remote-tracking branch 'remotes/famz/tags/block-and-testing-pull-request' into staging (2017-07-17 11:46:36 +0100)
3
Merge remote-tracking branch 'remotes/bkoppelmann/tags/pull-tricore-2018-03-02' into staging (2018-03-02 16:56:20 +0000)
4
4
5
are available in the git repository at:
5
are available in the git repository at:
6
6
7
https://github.com/jasowang/qemu.git tags/net-pull-request
7
https://github.com/jasowang/qemu.git tags/net-pull-request
8
8
9
for you to fetch changes up to 189ae6bb5ce1f5a322f8691d00fe942ba43dd601:
9
for you to fetch changes up to 46d4d36d0bf2b24b205f2f604f0905db80264eef:
10
10
11
virtio-net: fix offload ctrl endian (2017-07-17 20:13:56 +0800)
11
tap: setting error appropriately when calling net_init_tap_one() (2018-03-05 10:30:16 +0800)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
14
15
- fix virtio-net ctrl offload endian
15
----------------------------------------------------------------
16
- vnet header support for variou COLO netfilters and compare thread
16
Jay Zhou (1):
17
tap: setting error appropriately when calling net_init_tap_one()
17
18
18
----------------------------------------------------------------
19
Thomas Huth (8):
19
Jason Wang (1):
20
net: Move error reporting from net_init_client/netdev to the calling site
20
virtio-net: fix offload ctrl endian
21
net: List available netdevs with "-netdev help"
22
net: Only show vhost-user in the help text if CONFIG_POSIX is defined
23
net: Make net_client_init() static
24
net: Remove the deprecated way of dumping network packets
25
net: Remove the deprecated 'host_net_add' and 'host_net_remove' HMP commands
26
net: Add a new convenience option "--nic" to configure default/on-board NICs
27
hw/net: Remove unnecessary header includes
21
28
22
Michal Privoznik (1):
29
hmp-commands.hx | 30 ------
23
virtion-net: Prefer is_power_of_2()
30
hmp.h | 3 -
24
31
hw/net/e1000.c | 1 -
25
Zhang Chen (12):
32
hw/net/lance.c | 3 -
26
net: Add vnet_hdr_len arguments in NetClientState
33
hw/net/ne2000.c | 2 -
27
net/net.c: Add vnet_hdr support in SocketReadState
34
hw/net/pcnet-pci.c | 1 -
28
net/filter-mirror.c: Introduce parameter for filter_send()
35
hw/net/pcnet.c | 1 -
29
net/filter-mirror.c: Make filter mirror support vnet support.
36
hw/net/rtl8139.c | 2 -
30
net/filter-mirror.c: Add new option to enable vnet support for filter-redirector
37
hw/net/xgmac.c | 1 -
31
net/colo.c: Make vnet_hdr_len as packet property
38
include/net/net.h | 4 +-
32
net/colo-compare.c: Introduce parameter for compare_chr_send()
39
include/net/vhost_net.h | 3 +
33
net/colo-compare.c: Make colo-compare support vnet_hdr_len
40
include/sysemu/sysemu.h | 1 +
34
net/colo.c: Add vnet packet parse feature in colo-proxy
41
monitor.c | 61 ------------
35
net/colo-compare.c: Add vnet packet's tcp/udp/icmp compare
42
net/dump.c | 102 +--------------------
36
net/filter-rewriter.c: Make filter-rewriter support vnet_hdr_len
43
net/net.c | 239 +++++++++++++++++++++++-------------------------
37
docs/colo-proxy.txt: Update colo-proxy usage of net driver with vnet_header
44
net/tap.c | 22 ++++-
38
45
qapi/net.json | 29 ++----
39
docs/colo-proxy.txt | 26 ++++++++++++++++
46
qemu-doc.texi | 16 ----
40
hw/net/virtio-net.c | 4 ++-
47
qemu-options.hx | 48 +++++++---
41
include/net/net.h | 10 ++++--
48
tests/test-hmp.c | 2 -
42
net/colo-compare.c | 84 ++++++++++++++++++++++++++++++++++++++++++---------
49
vl.c | 10 +-
43
net/colo.c | 9 +++---
50
21 files changed, 190 insertions(+), 391 deletions(-)
44
net/colo.h | 4 ++-
45
net/filter-mirror.c | 75 +++++++++++++++++++++++++++++++++++++++++----
46
net/filter-rewriter.c | 37 ++++++++++++++++++++++-
47
net/net.c | 37 ++++++++++++++++++++---
48
net/socket.c | 8 ++---
49
qemu-options.hx | 19 ++++++------
50
11 files changed, 265 insertions(+), 48 deletions(-)
51
51
52
52
diff view generated by jsdifflib
1
From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
1
From: Thomas Huth <thuth@redhat.com>
2
2
3
Add vnet_hdr_len arguments in NetClientState
3
It looks strange that net_init_client() and net_init_netdev() both
4
that make other module get real vnet_hdr_len easily.
4
take an "Error **errp" parameter, but then do the error reporting
5
with "error_report_err(local_err)" on their own. Let's move the
6
error reporting to the calling site instead to simplify this code
7
a little bit.
5
8
6
Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
9
Reviewed-by: Eric Blake <eblake@redhat.com>
10
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
11
Signed-off-by: Thomas Huth <thuth@redhat.com>
7
Signed-off-by: Jason Wang <jasowang@redhat.com>
12
Signed-off-by: Jason Wang <jasowang@redhat.com>
8
---
13
---
9
include/net/net.h | 1 +
14
include/net/net.h | 2 +-
10
net/net.c | 1 +
15
net/net.c | 29 +++++------------------------
11
2 files changed, 2 insertions(+)
16
vl.c | 3 ++-
17
3 files changed, 8 insertions(+), 26 deletions(-)
12
18
13
diff --git a/include/net/net.h b/include/net/net.h
19
diff --git a/include/net/net.h b/include/net/net.h
14
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
15
--- a/include/net/net.h
21
--- a/include/net/net.h
16
+++ b/include/net/net.h
22
+++ b/include/net/net.h
17
@@ -XXX,XX +XXX,XX @@ struct NetClientState {
23
@@ -XXX,XX +XXX,XX @@ extern const char *legacy_bootp_filename;
18
unsigned int queue_index;
24
19
unsigned rxfilter_notify_enabled:1;
25
int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp);
20
int vring_enable;
26
int net_client_parse(QemuOptsList *opts_list, const char *str);
21
+ int vnet_hdr_len;
27
-int net_init_clients(void);
22
QTAILQ_HEAD(NetFilterHead, NetFilterState) filters;
28
+int net_init_clients(Error **errp);
23
};
29
void net_check_clients(void);
24
30
void net_cleanup(void);
31
void hmp_host_net_add(Monitor *mon, const QDict *qdict);
25
diff --git a/net/net.c b/net/net.c
32
diff --git a/net/net.c b/net/net.c
26
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
27
--- a/net/net.c
34
--- a/net/net.c
28
+++ b/net/net.c
35
+++ b/net/net.c
29
@@ -XXX,XX +XXX,XX @@ void qemu_set_vnet_hdr_len(NetClientState *nc, int len)
36
@@ -XXX,XX +XXX,XX @@ void net_check_clients(void)
30
return;
37
38
static int net_init_client(void *dummy, QemuOpts *opts, Error **errp)
39
{
40
- Error *local_err = NULL;
41
-
42
- net_client_init(opts, false, &local_err);
43
- if (local_err) {
44
- error_report_err(local_err);
45
- return -1;
46
- }
47
-
48
- return 0;
49
+ return net_client_init(opts, false, errp);
50
}
51
52
static int net_init_netdev(void *dummy, QemuOpts *opts, Error **errp)
53
{
54
- Error *local_err = NULL;
55
- int ret;
56
-
57
- ret = net_client_init(opts, true, &local_err);
58
- if (local_err) {
59
- error_report_err(local_err);
60
- return -1;
61
- }
62
-
63
- return ret;
64
+ return net_client_init(opts, true, errp);
65
}
66
67
-int net_init_clients(void)
68
+int net_init_clients(Error **errp)
69
{
70
- QemuOptsList *net = qemu_find_opts("net");
71
-
72
net_change_state_entry =
73
qemu_add_vm_change_state_handler(net_vm_change_state_handler, NULL);
74
75
QTAILQ_INIT(&net_clients);
76
77
if (qemu_opts_foreach(qemu_find_opts("netdev"),
78
- net_init_netdev, NULL, NULL)) {
79
+ net_init_netdev, NULL, errp)) {
80
return -1;
31
}
81
}
32
82
33
+ nc->vnet_hdr_len = len;
83
- if (qemu_opts_foreach(net, net_init_client, NULL, NULL)) {
34
nc->info->set_vnet_hdr_len(nc, len);
84
+ if (qemu_opts_foreach(qemu_find_opts("net"), net_init_client, NULL, errp)) {
35
}
85
return -1;
86
}
87
88
diff --git a/vl.c b/vl.c
89
index XXXXXXX..XXXXXXX 100644
90
--- a/vl.c
91
+++ b/vl.c
92
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv, char **envp)
93
94
colo_info_init();
95
96
- if (net_init_clients() < 0) {
97
+ if (net_init_clients(&err) < 0) {
98
+ error_report_err(err);
99
exit(1);
100
}
36
101
37
--
102
--
38
2.7.4
103
2.7.4
39
104
40
105
diff view generated by jsdifflib
1
From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
1
From: Thomas Huth <thuth@redhat.com>
2
2
3
We add the vnet_hdr_support option for colo-compare, default is disabled.
3
Other options like "-chardev" or "-device" feature a nice help text
4
If you use virtio-net-pci or other driver needs vnet_hdr, please enable it.
4
with the available devices when being called with "help" or "?".
5
You can use it for example:
5
Since it is quite useful, especially if you want to see which network
6
-object colo-compare,id=comp0,primary_in=compare0-0,secondary_in=compare1,outdev=compare_out0,vnet_hdr_support
6
backends have been compiled into the QEMU binary, let's provide such
7
a help text for "-netdev", too.
7
8
8
COLO-compare can get vnet header length from filter,
9
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
9
Add vnet_hdr_len to struct packet and output packet with
10
Reviewed-by: Eric Blake <eblake@redhat.com>
10
the vnet_hdr_len.
11
Signed-off-by: Thomas Huth <thuth@redhat.com>
11
12
Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
13
Signed-off-by: Jason Wang <jasowang@redhat.com>
12
Signed-off-by: Jason Wang <jasowang@redhat.com>
14
---
13
---
15
net/colo-compare.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++-------
14
net/net.c | 37 ++++++++++++++++++++++++++++++++++++-
16
qemu-options.hx | 4 ++--
15
1 file changed, 36 insertions(+), 1 deletion(-)
17
2 files changed, 55 insertions(+), 9 deletions(-)
18
16
19
diff --git a/net/colo-compare.c b/net/colo-compare.c
17
diff --git a/net/net.c b/net/net.c
20
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
21
--- a/net/colo-compare.c
19
--- a/net/net.c
22
+++ b/net/colo-compare.c
20
+++ b/net/net.c
23
@@ -XXX,XX +XXX,XX @@ typedef struct CompareState {
21
@@ -XXX,XX +XXX,XX @@ static int net_client_init1(const void *object, bool is_netdev, Error **errp)
24
CharBackend chr_out;
22
return 0;
25
SocketReadState pri_rs;
23
}
26
SocketReadState sec_rs;
24
27
+ bool vnet_hdr;
25
+static void show_netdevs(void)
28
26
+{
29
/* connection list: the connections belonged to this NIC could be found
27
+ int idx;
30
* in this list.
28
+ const char *available_netdevs[] = {
31
@@ -XXX,XX +XXX,XX @@ enum {
29
+ "socket",
32
30
+ "hubport",
33
static int compare_chr_send(CompareState *s,
31
+ "tap",
34
const uint8_t *buf,
32
+#ifdef CONFIG_SLIRP
35
- uint32_t size);
33
+ "user",
36
+ uint32_t size,
34
+#endif
37
+ uint32_t vnet_hdr_len);
35
+#ifdef CONFIG_L2TPV3
38
36
+ "l2tpv3",
39
static gint seq_sorter(Packet *a, Packet *b, gpointer data)
37
+#endif
38
+#ifdef CONFIG_VDE
39
+ "vde",
40
+#endif
41
+#ifdef CONFIG_NET_BRIDGE
42
+ "bridge",
43
+#endif
44
+#ifdef CONFIG_NETMAP
45
+ "netmap",
46
+#endif
47
+#ifdef CONFIG_POSIX
48
+ "vhost-user",
49
+#endif
50
+ };
51
+
52
+ printf("Available netdev backend types:\n");
53
+ for (idx = 0; idx < ARRAY_SIZE(available_netdevs); idx++) {
54
+ puts(available_netdevs[idx]);
55
+ }
56
+}
57
58
int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
40
{
59
{
41
@@ -XXX,XX +XXX,XX @@ static void colo_compare_connection(void *opaque, void *user_data)
60
@@ -XXX,XX +XXX,XX @@ int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
42
}
61
int ret = -1;
43
62
Visitor *v = opts_visitor_new(opts);
44
if (result) {
63
45
- ret = compare_chr_send(s, pkt->data, pkt->size);
64
- {
46
+ ret = compare_chr_send(s,
65
+ if (is_netdev && is_help_option(qemu_opt_get(opts, "type"))) {
47
+ pkt->data,
66
+ show_netdevs();
48
+ pkt->size,
67
+ exit(0);
49
+ pkt->vnet_hdr_len);
68
+ } else {
50
if (ret < 0) {
69
/* Parse convenience option format ip6-net=fec0::0[/64] */
51
error_report("colo_send_primary_packet failed");
70
const char *ip6_net = qemu_opt_get(opts, "ipv6-net");
52
}
53
@@ -XXX,XX +XXX,XX @@ static void colo_compare_connection(void *opaque, void *user_data)
54
55
static int compare_chr_send(CompareState *s,
56
const uint8_t *buf,
57
- uint32_t size)
58
+ uint32_t size,
59
+ uint32_t vnet_hdr_len)
60
{
61
int ret = 0;
62
uint32_t len = htonl(size);
63
@@ -XXX,XX +XXX,XX @@ static int compare_chr_send(CompareState *s,
64
goto err;
65
}
66
67
+ if (s->vnet_hdr) {
68
+ /*
69
+ * We send vnet header len make other module(like filter-redirector)
70
+ * know how to parse net packet correctly.
71
+ */
72
+ len = htonl(vnet_hdr_len);
73
+ ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)&len, sizeof(len));
74
+ if (ret != sizeof(len)) {
75
+ goto err;
76
+ }
77
+ }
78
+
79
ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)buf, size);
80
if (ret != size) {
81
goto err;
82
@@ -XXX,XX +XXX,XX @@ static void compare_set_outdev(Object *obj, const char *value, Error **errp)
83
s->outdev = g_strdup(value);
84
}
85
86
+static bool compare_get_vnet_hdr(Object *obj, Error **errp)
87
+{
88
+ CompareState *s = COLO_COMPARE(obj);
89
+
90
+ return s->vnet_hdr;
91
+}
92
+
93
+static void compare_set_vnet_hdr(Object *obj,
94
+ bool value,
95
+ Error **errp)
96
+{
97
+ CompareState *s = COLO_COMPARE(obj);
98
+
99
+ s->vnet_hdr = value;
100
+}
101
+
102
static void compare_pri_rs_finalize(SocketReadState *pri_rs)
103
{
104
CompareState *s = container_of(pri_rs, CompareState, pri_rs);
105
106
if (packet_enqueue(s, PRIMARY_IN)) {
107
trace_colo_compare_main("primary: unsupported packet in");
108
- compare_chr_send(s, pri_rs->buf, pri_rs->packet_len);
109
+ compare_chr_send(s,
110
+ pri_rs->buf,
111
+ pri_rs->packet_len,
112
+ pri_rs->vnet_hdr_len);
113
} else {
114
/* compare connection */
115
g_queue_foreach(&s->conn_list, colo_compare_connection, s);
116
@@ -XXX,XX +XXX,XX @@ static void colo_compare_complete(UserCreatable *uc, Error **errp)
117
return;
118
}
119
120
- net_socket_rs_init(&s->pri_rs, compare_pri_rs_finalize, false);
121
- net_socket_rs_init(&s->sec_rs, compare_sec_rs_finalize, false);
122
+ net_socket_rs_init(&s->pri_rs, compare_pri_rs_finalize, s->vnet_hdr);
123
+ net_socket_rs_init(&s->sec_rs, compare_sec_rs_finalize, s->vnet_hdr);
124
125
g_queue_init(&s->conn_list);
126
127
@@ -XXX,XX +XXX,XX @@ static void colo_flush_packets(void *opaque, void *user_data)
128
129
while (!g_queue_is_empty(&conn->primary_list)) {
130
pkt = g_queue_pop_head(&conn->primary_list);
131
- compare_chr_send(s, pkt->data, pkt->size);
132
+ compare_chr_send(s,
133
+ pkt->data,
134
+ pkt->size,
135
+ pkt->vnet_hdr_len);
136
packet_destroy(pkt, NULL);
137
}
138
while (!g_queue_is_empty(&conn->secondary_list)) {
139
@@ -XXX,XX +XXX,XX @@ static void colo_compare_class_init(ObjectClass *oc, void *data)
140
141
static void colo_compare_init(Object *obj)
142
{
143
+ CompareState *s = COLO_COMPARE(obj);
144
+
145
object_property_add_str(obj, "primary_in",
146
compare_get_pri_indev, compare_set_pri_indev,
147
NULL);
148
@@ -XXX,XX +XXX,XX @@ static void colo_compare_init(Object *obj)
149
object_property_add_str(obj, "outdev",
150
compare_get_outdev, compare_set_outdev,
151
NULL);
152
+
153
+ s->vnet_hdr = false;
154
+ object_property_add_bool(obj, "vnet_hdr_support", compare_get_vnet_hdr,
155
+ compare_set_vnet_hdr, NULL);
156
}
157
158
static void colo_compare_finalize(Object *obj)
159
diff --git a/qemu-options.hx b/qemu-options.hx
160
index XXXXXXX..XXXXXXX 100644
161
--- a/qemu-options.hx
162
+++ b/qemu-options.hx
163
@@ -XXX,XX +XXX,XX @@ Dump the network traffic on netdev @var{dev} to the file specified by
164
The file format is libpcap, so it can be analyzed with tools such as tcpdump
165
or Wireshark.
166
167
-@item -object colo-compare,id=@var{id},primary_in=@var{chardevid},secondary_in=@var{chardevid},
168
-outdev=@var{chardevid}
169
+@item -object colo-compare,id=@var{id},primary_in=@var{chardevid},secondary_in=@var{chardevid},outdev=@var{chardevid}[,vnet_hdr_support]
170
171
Colo-compare gets packet from primary_in@var{chardevid} and secondary_in@var{chardevid}, than compare primary packet with
172
secondary packet. If the packets are same, we will output primary
173
packet to outdev@var{chardevid}, else we will notify colo-frame
174
do checkpoint and send primary packet to outdev@var{chardevid}.
175
+if it has the vnet_hdr_support flag, colo compare will send/recv packet with vnet_hdr_len.
176
177
we must use it with the help of filter-mirror and filter-redirector.
178
71
179
--
72
--
180
2.7.4
73
2.7.4
181
74
182
75
diff view generated by jsdifflib
1
From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
1
From: Thomas Huth <thuth@redhat.com>
2
2
3
We add the vnet_hdr_support option for filter-redirector, default is disabled.
3
According to net/Makefile.objs we only link in the vhost-user code
4
If you use virtio-net-pci net driver or other driver needs vnet_hdr, please enable it.
4
if CONFIG_POSIX has been set. So the help screen should also only
5
Because colo-compare or other modules needs the vnet_hdr_len to parse
5
show this information if CONFIG_POSIX has been defined.
6
packet, we add this new option send the len to others.
7
You can use it for example:
8
-object filter-redirector,id=r0,netdev=hn0,queue=tx,outdev=red0,vnet_hdr_support
9
6
10
Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
7
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
8
Signed-off-by: Thomas Huth <thuth@redhat.com>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
9
Signed-off-by: Jason Wang <jasowang@redhat.com>
12
---
10
---
13
net/filter-mirror.c | 23 +++++++++++++++++++++++
11
qemu-options.hx | 2 ++
14
qemu-options.hx | 6 +++---
12
1 file changed, 2 insertions(+)
15
2 files changed, 26 insertions(+), 3 deletions(-)
16
13
17
diff --git a/net/filter-mirror.c b/net/filter-mirror.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/net/filter-mirror.c
20
+++ b/net/filter-mirror.c
21
@@ -XXX,XX +XXX,XX @@ static void filter_redirector_set_outdev(Object *obj,
22
s->outdev = g_strdup(value);
23
}
24
25
+static bool filter_redirector_get_vnet_hdr(Object *obj, Error **errp)
26
+{
27
+ MirrorState *s = FILTER_REDIRECTOR(obj);
28
+
29
+ return s->vnet_hdr;
30
+}
31
+
32
+static void filter_redirector_set_vnet_hdr(Object *obj,
33
+ bool value,
34
+ Error **errp)
35
+{
36
+ MirrorState *s = FILTER_REDIRECTOR(obj);
37
+
38
+ s->vnet_hdr = value;
39
+}
40
+
41
static void filter_mirror_init(Object *obj)
42
{
43
MirrorState *s = FILTER_MIRROR(obj);
44
@@ -XXX,XX +XXX,XX @@ static void filter_mirror_init(Object *obj)
45
46
static void filter_redirector_init(Object *obj)
47
{
48
+ MirrorState *s = FILTER_REDIRECTOR(obj);
49
+
50
object_property_add_str(obj, "indev", filter_redirector_get_indev,
51
filter_redirector_set_indev, NULL);
52
object_property_add_str(obj, "outdev", filter_redirector_get_outdev,
53
filter_redirector_set_outdev, NULL);
54
+
55
+ s->vnet_hdr = false;
56
+ object_property_add_bool(obj, "vnet_hdr_support",
57
+ filter_redirector_get_vnet_hdr,
58
+ filter_redirector_set_vnet_hdr, NULL);
59
}
60
61
static void filter_mirror_fini(Object *obj)
62
diff --git a/qemu-options.hx b/qemu-options.hx
14
diff --git a/qemu-options.hx b/qemu-options.hx
63
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
64
--- a/qemu-options.hx
16
--- a/qemu-options.hx
65
+++ b/qemu-options.hx
17
+++ b/qemu-options.hx
66
@@ -XXX,XX +XXX,XX @@ queue @var{all|rx|tx} is an option that can be applied to any netfilter.
18
@@ -XXX,XX +XXX,XX @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,
67
19
" VALE port (created on the fly) called 'name' ('nmname' is name of the \n"
68
filter-mirror on netdev @var{netdevid},mirror net packet to chardev@var{chardevid}, if it has the vnet_hdr_support flag, filter-mirror will mirror packet with vnet_hdr_len.
20
" netmap device, defaults to '/dev/netmap')\n"
69
21
#endif
70
-@item -object filter-redirector,id=@var{id},netdev=@var{netdevid},indev=@var{chardevid},
22
+#ifdef CONFIG_POSIX
71
-outdev=@var{chardevid}[,queue=@var{all|rx|tx}]
23
"-netdev vhost-user,id=str,chardev=dev[,vhostforce=on|off]\n"
72
+@item -object filter-redirector,id=@var{id},netdev=@var{netdevid},indev=@var{chardevid},outdev=@var{chardevid},queue=@var{all|rx|tx}[,vnet_hdr_support]
24
" configure a vhost-user network, backed by a chardev 'dev'\n"
73
25
+#endif
74
filter-redirector on netdev @var{netdevid},redirect filter's net packet to chardev
26
"-netdev hubport,id=str,hubid=n[,netdev=nd]\n"
75
-@var{chardevid},and redirect indev's packet to filter.
27
" configure a hub port on QEMU VLAN 'n'\n", QEMU_ARCH_ALL)
76
+@var{chardevid},and redirect indev's packet to filter.if it has the vnet_hdr_support flag,
28
DEF("net", HAS_ARG, QEMU_OPTION_net,
77
+filter-redirector will redirect packet with vnet_hdr_len.
78
Create a filter-redirector we need to differ outdev id from indev id, id can not
79
be the same. we can just use indev or outdev, but at least one of indev or outdev
80
need to be specified.
81
--
29
--
82
2.7.4
30
2.7.4
83
31
84
32
diff view generated by jsdifflib
1
From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
1
From: Thomas Huth <thuth@redhat.com>
2
2
3
We add a flag to decide whether net_fill_rstate() need read
3
The function is only used within net.c, so there's no need that
4
the vnet_hdr_len or not.
4
this is a global function.
5
5
6
Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
6
While we're at it, also remove the unused prototype compute_mcast_idx()
7
Suggested-by: Jason Wang <jasowang@redhat.com>
7
(the function has been removed in commit d9caeb09b107e91122d10ba4a08a).
8
9
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
10
Signed-off-by: Thomas Huth <thuth@redhat.com>
8
Signed-off-by: Jason Wang <jasowang@redhat.com>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
9
---
12
---
10
include/net/net.h | 9 +++++++--
13
include/net/net.h | 2 --
11
net/colo-compare.c | 4 ++--
14
net/net.c | 2 +-
12
net/filter-mirror.c | 2 +-
15
2 files changed, 1 insertion(+), 3 deletions(-)
13
net/net.c | 36 ++++++++++++++++++++++++++++++++----
14
net/socket.c | 8 ++++----
15
5 files changed, 46 insertions(+), 13 deletions(-)
16
16
17
diff --git a/include/net/net.h b/include/net/net.h
17
diff --git a/include/net/net.h b/include/net/net.h
18
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
19
--- a/include/net/net.h
19
--- a/include/net/net.h
20
+++ b/include/net/net.h
20
+++ b/include/net/net.h
21
@@ -XXX,XX +XXX,XX @@ typedef struct NICState {
21
@@ -XXX,XX +XXX,XX @@ extern const char *host_net_devices[];
22
} NICState;
22
extern const char *legacy_tftp_prefix;
23
23
extern const char *legacy_bootp_filename;
24
struct SocketReadState {
24
25
- int state; /* 0 = getting length, 1 = getting data */
25
-int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp);
26
+ /* 0 = getting length, 1 = getting vnet header length, 2 = getting data */
26
int net_client_parse(QemuOptsList *opts_list, const char *str);
27
+ int state;
27
int net_init_clients(Error **errp);
28
+ /* This flag decide whether to read the vnet_hdr_len field */
28
void net_check_clients(void);
29
+ bool vnet_hdr;
29
@@ -XXX,XX +XXX,XX @@ void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd);
30
uint32_t index;
30
#define POLYNOMIAL_LE 0xedb88320
31
uint32_t packet_len;
31
uint32_t net_crc32(const uint8_t *p, int len);
32
+ uint32_t vnet_hdr_len;
32
uint32_t net_crc32_le(const uint8_t *p, int len);
33
uint8_t buf[NET_BUFSIZE];
33
-unsigned compute_mcast_idx(const uint8_t *ep);
34
SocketReadStateFinalize *finalize;
34
35
};
35
#define vmstate_offset_macaddr(_state, _field) \
36
@@ -XXX,XX +XXX,XX @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender,
36
vmstate_offset_array(_state, _field.a, uint8_t, \
37
void print_net_client(Monitor *mon, NetClientState *nc);
38
void hmp_info_network(Monitor *mon, const QDict *qdict);
39
void net_socket_rs_init(SocketReadState *rs,
40
- SocketReadStateFinalize *finalize);
41
+ SocketReadStateFinalize *finalize,
42
+ bool vnet_hdr);
43
44
/* NIC info */
45
46
diff --git a/net/colo-compare.c b/net/colo-compare.c
47
index XXXXXXX..XXXXXXX 100644
48
--- a/net/colo-compare.c
49
+++ b/net/colo-compare.c
50
@@ -XXX,XX +XXX,XX @@ static void colo_compare_complete(UserCreatable *uc, Error **errp)
51
return;
52
}
53
54
- net_socket_rs_init(&s->pri_rs, compare_pri_rs_finalize);
55
- net_socket_rs_init(&s->sec_rs, compare_sec_rs_finalize);
56
+ net_socket_rs_init(&s->pri_rs, compare_pri_rs_finalize, false);
57
+ net_socket_rs_init(&s->sec_rs, compare_sec_rs_finalize, false);
58
59
g_queue_init(&s->conn_list);
60
61
diff --git a/net/filter-mirror.c b/net/filter-mirror.c
62
index XXXXXXX..XXXXXXX 100644
63
--- a/net/filter-mirror.c
64
+++ b/net/filter-mirror.c
65
@@ -XXX,XX +XXX,XX @@ static void filter_redirector_setup(NetFilterState *nf, Error **errp)
66
}
67
}
68
69
- net_socket_rs_init(&s->rs, redirector_rs_finalize);
70
+ net_socket_rs_init(&s->rs, redirector_rs_finalize, false);
71
72
if (s->indev) {
73
chr = qemu_chr_find(s->indev);
74
diff --git a/net/net.c b/net/net.c
37
diff --git a/net/net.c b/net/net.c
75
index XXXXXXX..XXXXXXX 100644
38
index XXXXXXX..XXXXXXX 100644
76
--- a/net/net.c
39
--- a/net/net.c
77
+++ b/net/net.c
40
+++ b/net/net.c
78
@@ -XXX,XX +XXX,XX @@ QemuOptsList qemu_net_opts = {
41
@@ -XXX,XX +XXX,XX @@ static void show_netdevs(void)
79
};
42
}
80
43
}
81
void net_socket_rs_init(SocketReadState *rs,
44
82
- SocketReadStateFinalize *finalize)
45
-int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
83
+ SocketReadStateFinalize *finalize,
46
+static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
84
+ bool vnet_hdr)
85
{
47
{
86
rs->state = 0;
48
void *object = NULL;
87
+ rs->vnet_hdr = vnet_hdr;
49
Error *err = NULL;
88
rs->index = 0;
89
rs->packet_len = 0;
90
+ rs->vnet_hdr_len = 0;
91
memset(rs->buf, 0, sizeof(rs->buf));
92
rs->finalize = finalize;
93
}
94
@@ -XXX,XX +XXX,XX @@ int net_fill_rstate(SocketReadState *rs, const uint8_t *buf, int size)
95
unsigned int l;
96
97
while (size > 0) {
98
- /* reassemble a packet from the network */
99
- switch (rs->state) { /* 0 = getting length, 1 = getting data */
100
+ /* Reassemble a packet from the network.
101
+ * 0 = getting length.
102
+ * 1 = getting vnet header length.
103
+ * 2 = getting data.
104
+ */
105
+ switch (rs->state) {
106
case 0:
107
l = 4 - rs->index;
108
if (l > size) {
109
@@ -XXX,XX +XXX,XX @@ int net_fill_rstate(SocketReadState *rs, const uint8_t *buf, int size)
110
/* got length */
111
rs->packet_len = ntohl(*(uint32_t *)rs->buf);
112
rs->index = 0;
113
- rs->state = 1;
114
+ if (rs->vnet_hdr) {
115
+ rs->state = 1;
116
+ } else {
117
+ rs->state = 2;
118
+ rs->vnet_hdr_len = 0;
119
+ }
120
}
121
break;
122
case 1:
123
+ l = 4 - rs->index;
124
+ if (l > size) {
125
+ l = size;
126
+ }
127
+ memcpy(rs->buf + rs->index, buf, l);
128
+ buf += l;
129
+ size -= l;
130
+ rs->index += l;
131
+ if (rs->index == 4) {
132
+ /* got vnet header length */
133
+ rs->vnet_hdr_len = ntohl(*(uint32_t *)rs->buf);
134
+ rs->index = 0;
135
+ rs->state = 2;
136
+ }
137
+ break;
138
+ case 2:
139
l = rs->packet_len - rs->index;
140
if (l > size) {
141
l = size;
142
diff --git a/net/socket.c b/net/socket.c
143
index XXXXXXX..XXXXXXX 100644
144
--- a/net/socket.c
145
+++ b/net/socket.c
146
@@ -XXX,XX +XXX,XX @@ static void net_socket_send(void *opaque)
147
closesocket(s->fd);
148
149
s->fd = -1;
150
- net_socket_rs_init(&s->rs, net_socket_rs_finalize);
151
+ net_socket_rs_init(&s->rs, net_socket_rs_finalize, false);
152
s->nc.link_down = true;
153
memset(s->nc.info_str, 0, sizeof(s->nc.info_str));
154
155
@@ -XXX,XX +XXX,XX @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer,
156
s->fd = fd;
157
s->listen_fd = -1;
158
s->send_fn = net_socket_send_dgram;
159
- net_socket_rs_init(&s->rs, net_socket_rs_finalize);
160
+ net_socket_rs_init(&s->rs, net_socket_rs_finalize, false);
161
net_socket_read_poll(s, true);
162
163
/* mcast: save bound address as dst */
164
@@ -XXX,XX +XXX,XX @@ static NetSocketState *net_socket_fd_init_stream(NetClientState *peer,
165
166
s->fd = fd;
167
s->listen_fd = -1;
168
- net_socket_rs_init(&s->rs, net_socket_rs_finalize);
169
+ net_socket_rs_init(&s->rs, net_socket_rs_finalize, false);
170
171
/* Disable Nagle algorithm on TCP sockets to reduce latency */
172
socket_set_nodelay(fd);
173
@@ -XXX,XX +XXX,XX @@ static int net_socket_listen_init(NetClientState *peer,
174
s->fd = -1;
175
s->listen_fd = fd;
176
s->nc.link_down = true;
177
- net_socket_rs_init(&s->rs, net_socket_rs_finalize);
178
+ net_socket_rs_init(&s->rs, net_socket_rs_finalize, false);
179
180
qemu_set_fd_handler(s->listen_fd, net_socket_accept, NULL, s);
181
return 0;
182
--
50
--
183
2.7.4
51
2.7.4
184
52
185
53
diff view generated by jsdifflib
Deleted patch
1
From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
2
1
3
This patch change the filter_send() parameter from CharBackend to MirrorState,
4
we can get more information like vnet_hdr(We use it to support packet with vnet_header).
5
6
Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
7
Signed-off-by: Jason Wang <jasowang@redhat.com>
8
---
9
net/filter-mirror.c | 10 +++++-----
10
1 file changed, 5 insertions(+), 5 deletions(-)
11
12
diff --git a/net/filter-mirror.c b/net/filter-mirror.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/net/filter-mirror.c
15
+++ b/net/filter-mirror.c
16
@@ -XXX,XX +XXX,XX @@ typedef struct MirrorState {
17
SocketReadState rs;
18
} MirrorState;
19
20
-static int filter_send(CharBackend *chr_out,
21
+static int filter_send(MirrorState *s,
22
const struct iovec *iov,
23
int iovcnt)
24
{
25
@@ -XXX,XX +XXX,XX @@ static int filter_send(CharBackend *chr_out,
26
}
27
28
len = htonl(size);
29
- ret = qemu_chr_fe_write_all(chr_out, (uint8_t *)&len, sizeof(len));
30
+ ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)&len, sizeof(len));
31
if (ret != sizeof(len)) {
32
goto err;
33
}
34
35
buf = g_malloc(size);
36
iov_to_buf(iov, iovcnt, 0, buf, size);
37
- ret = qemu_chr_fe_write_all(chr_out, (uint8_t *)buf, size);
38
+ ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)buf, size);
39
g_free(buf);
40
if (ret != size) {
41
goto err;
42
@@ -XXX,XX +XXX,XX @@ static ssize_t filter_mirror_receive_iov(NetFilterState *nf,
43
MirrorState *s = FILTER_MIRROR(nf);
44
int ret;
45
46
- ret = filter_send(&s->chr_out, iov, iovcnt);
47
+ ret = filter_send(s, iov, iovcnt);
48
if (ret) {
49
error_report("filter mirror send failed(%s)", strerror(-ret));
50
}
51
@@ -XXX,XX +XXX,XX @@ static ssize_t filter_redirector_receive_iov(NetFilterState *nf,
52
int ret;
53
54
if (qemu_chr_fe_backend_connected(&s->chr_out)) {
55
- ret = filter_send(&s->chr_out, iov, iovcnt);
56
+ ret = filter_send(s, iov, iovcnt);
57
if (ret) {
58
error_report("filter redirector send failed(%s)", strerror(-ret));
59
}
60
--
61
2.7.4
62
63
diff view generated by jsdifflib
1
From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
1
From: Thomas Huth <thuth@redhat.com>
2
2
3
We add the vnet_hdr_support option for filter-mirror, default is disabled.
3
"-net dump" has been marked as deprecated since QEMU v2.10, since it
4
If you use virtio-net-pci or other driver needs vnet_hdr, please enable it.
4
only works with the deprecated 'vlan' parameter (or hubs). Network
5
You can use it for example:
5
dumping should be done with "-object filter-dump" nowadays instead.
6
-object filter-mirror,id=m0,netdev=hn0,queue=tx,outdev=mirror0,vnet_hdr_support
6
Since nobody complained so far about the deprecation message, let's
7
7
finally get rid of "-net dump" now.
8
If it has vnet_hdr_support flag, we will change the sending packet format from
8
9
struct {int size; const uint8_t buf[];} to {int size; int vnet_hdr_len; const uint8_t buf[];}.
9
Signed-off-by: Thomas Huth <thuth@redhat.com>
10
make other module(like colo-compare) know how to parse net packet correctly.
11
12
Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
13
Signed-off-by: Jason Wang <jasowang@redhat.com>
10
Signed-off-by: Jason Wang <jasowang@redhat.com>
14
---
11
---
15
net/filter-mirror.c | 42 +++++++++++++++++++++++++++++++++++++++++-
12
net/dump.c | 102 ++------------------------------------------------------
16
qemu-options.hx | 5 ++---
13
net/net.c | 9 +----
17
2 files changed, 43 insertions(+), 4 deletions(-)
14
qapi/net.json | 29 ++++------------
18
15
qemu-doc.texi | 6 ----
19
diff --git a/net/filter-mirror.c b/net/filter-mirror.c
16
qemu-options.hx | 8 -----
20
index XXXXXXX..XXXXXXX 100644
17
5 files changed, 9 insertions(+), 145 deletions(-)
21
--- a/net/filter-mirror.c
18
22
+++ b/net/filter-mirror.c
19
diff --git a/net/dump.c b/net/dump.c
23
@@ -XXX,XX +XXX,XX @@ typedef struct MirrorState {
20
index XXXXXXX..XXXXXXX 100644
24
CharBackend chr_in;
21
--- a/net/dump.c
25
CharBackend chr_out;
22
+++ b/net/dump.c
26
SocketReadState rs;
23
@@ -XXX,XX +XXX,XX @@ static int net_dump_state_init(DumpState *s, const char *filename,
27
+ bool vnet_hdr;
24
28
} MirrorState;
25
fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0644);
29
26
if (fd < 0) {
30
static int filter_send(MirrorState *s,
27
- error_setg_errno(errp, errno, "-net dump: can't open %s", filename);
31
const struct iovec *iov,
28
+ error_setg_errno(errp, errno, "net dump: can't open %s", filename);
32
int iovcnt)
29
return -1;
33
{
34
+ NetFilterState *nf = NETFILTER(s);
35
int ret = 0;
36
ssize_t size = 0;
37
uint32_t len = 0;
38
@@ -XXX,XX +XXX,XX @@ static int filter_send(MirrorState *s,
39
goto err;
40
}
30
}
41
31
42
+ if (s->vnet_hdr) {
32
@@ -XXX,XX +XXX,XX @@ static int net_dump_state_init(DumpState *s, const char *filename,
43
+ /*
33
hdr.linktype = 1;
44
+ * If vnet_hdr = on, we send vnet header len to make other
34
45
+ * module(like colo-compare) know how to parse net
35
if (write(fd, &hdr, sizeof(hdr)) < sizeof(hdr)) {
46
+ * packet correctly.
36
- error_setg_errno(errp, errno, "-net dump write error");
47
+ */
37
+ error_setg_errno(errp, errno, "net dump write error");
48
+ ssize_t vnet_hdr_len;
38
close(fd);
49
+
39
return -1;
50
+ vnet_hdr_len = nf->netdev->vnet_hdr_len;
51
+
52
+ len = htonl(vnet_hdr_len);
53
+ ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)&len, sizeof(len));
54
+ if (ret != sizeof(len)) {
55
+ goto err;
56
+ }
57
+ }
58
+
59
buf = g_malloc(size);
60
iov_to_buf(iov, iovcnt, 0, buf, size);
61
ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)buf, size);
62
@@ -XXX,XX +XXX,XX @@ static void filter_redirector_setup(NetFilterState *nf, Error **errp)
63
}
64
}
40
}
65
41
@@ -XXX,XX +XXX,XX @@ static int net_dump_state_init(DumpState *s, const char *filename,
66
- net_socket_rs_init(&s->rs, redirector_rs_finalize, false);
42
return 0;
67
+ net_socket_rs_init(&s->rs, redirector_rs_finalize, s->vnet_hdr);
68
69
if (s->indev) {
70
chr = qemu_chr_find(s->indev);
71
@@ -XXX,XX +XXX,XX @@ static void filter_mirror_set_outdev(Object *obj,
72
}
73
}
43
}
74
44
75
+static bool filter_mirror_get_vnet_hdr(Object *obj, Error **errp)
45
-/* Dumping via VLAN netclient */
76
+{
46
-
77
+ MirrorState *s = FILTER_MIRROR(obj);
47
-struct DumpNetClient {
78
+
48
- NetClientState nc;
79
+ return s->vnet_hdr;
49
- DumpState ds;
80
+}
50
-};
81
+
51
-typedef struct DumpNetClient DumpNetClient;
82
+static void filter_mirror_set_vnet_hdr(Object *obj, bool value, Error **errp)
52
-
83
+{
53
-static ssize_t dumpclient_receive(NetClientState *nc, const uint8_t *buf,
84
+ MirrorState *s = FILTER_MIRROR(obj);
54
- size_t size)
85
+
55
-{
86
+ s->vnet_hdr = value;
56
- DumpNetClient *dc = DO_UPCAST(DumpNetClient, nc, nc);
87
+}
57
- struct iovec iov = {
88
+
58
- .iov_base = (void *)buf,
89
static char *filter_redirector_get_outdev(Object *obj, Error **errp)
59
- .iov_len = size
90
{
60
- };
91
MirrorState *s = FILTER_REDIRECTOR(obj);
61
-
92
@@ -XXX,XX +XXX,XX @@ static void filter_redirector_set_outdev(Object *obj,
62
- return dump_receive_iov(&dc->ds, &iov, 1);
93
63
-}
94
static void filter_mirror_init(Object *obj)
64
-
95
{
65
-static ssize_t dumpclient_receive_iov(NetClientState *nc,
96
+ MirrorState *s = FILTER_MIRROR(obj);
66
- const struct iovec *iov, int cnt)
97
+
67
-{
98
object_property_add_str(obj, "outdev", filter_mirror_get_outdev,
68
- DumpNetClient *dc = DO_UPCAST(DumpNetClient, nc, nc);
99
filter_mirror_set_outdev, NULL);
69
-
100
+
70
- return dump_receive_iov(&dc->ds, iov, cnt);
101
+ s->vnet_hdr = false;
71
-}
102
+ object_property_add_bool(obj, "vnet_hdr_support",
72
-
103
+ filter_mirror_get_vnet_hdr,
73
-static void dumpclient_cleanup(NetClientState *nc)
104
+ filter_mirror_set_vnet_hdr, NULL);
74
-{
105
}
75
- DumpNetClient *dc = DO_UPCAST(DumpNetClient, nc, nc);
106
76
-
107
static void filter_redirector_init(Object *obj)
77
- dump_cleanup(&dc->ds);
78
-}
79
-
80
-static NetClientInfo net_dump_info = {
81
- .type = NET_CLIENT_DRIVER_DUMP,
82
- .size = sizeof(DumpNetClient),
83
- .receive = dumpclient_receive,
84
- .receive_iov = dumpclient_receive_iov,
85
- .cleanup = dumpclient_cleanup,
86
-};
87
-
88
-int net_init_dump(const Netdev *netdev, const char *name,
89
- NetClientState *peer, Error **errp)
90
-{
91
- int len, rc;
92
- const char *file;
93
- char def_file[128];
94
- const NetdevDumpOptions *dump;
95
- NetClientState *nc;
96
- DumpNetClient *dnc;
97
-
98
- assert(netdev->type == NET_CLIENT_DRIVER_DUMP);
99
- dump = &netdev->u.dump;
100
-
101
- assert(peer);
102
-
103
- error_report("'-net dump' is deprecated. "
104
- "Please use '-object filter-dump' instead.");
105
-
106
- if (dump->has_file) {
107
- file = dump->file;
108
- } else {
109
- int id;
110
- int ret;
111
-
112
- ret = net_hub_id_for_client(peer, &id);
113
- assert(ret == 0); /* peer must be on a hub */
114
-
115
- snprintf(def_file, sizeof(def_file), "qemu-vlan%d.pcap", id);
116
- file = def_file;
117
- }
118
-
119
- if (dump->has_len) {
120
- if (dump->len > INT_MAX) {
121
- error_setg(errp, "invalid length: %"PRIu64, dump->len);
122
- return -1;
123
- }
124
- len = dump->len;
125
- } else {
126
- len = 65536;
127
- }
128
-
129
- nc = qemu_new_net_client(&net_dump_info, peer, "dump", name);
130
- snprintf(nc->info_str, sizeof(nc->info_str),
131
- "dump to %s (len=%d)", file, len);
132
-
133
- dnc = DO_UPCAST(DumpNetClient, nc, nc);
134
- rc = net_dump_state_init(&dnc->ds, file, len, errp);
135
- if (rc) {
136
- qemu_del_net_client(nc);
137
- }
138
- return rc;
139
-}
140
-
141
-/* Dumping via filter */
142
-
143
#define TYPE_FILTER_DUMP "filter-dump"
144
145
#define FILTER_DUMP(obj) \
146
diff --git a/net/net.c b/net/net.c
147
index XXXXXXX..XXXXXXX 100644
148
--- a/net/net.c
149
+++ b/net/net.c
150
@@ -XXX,XX +XXX,XX @@ static QTAILQ_HEAD(, NetClientState) net_clients;
151
const char *host_net_devices[] = {
152
"tap",
153
"socket",
154
- "dump",
155
#ifdef CONFIG_NET_BRIDGE
156
"bridge",
157
#endif
158
@@ -XXX,XX +XXX,XX @@ static int (* const net_client_init_fun[NET_CLIENT_DRIVER__MAX])(
159
#ifdef CONFIG_NETMAP
160
[NET_CLIENT_DRIVER_NETMAP] = net_init_netmap,
161
#endif
162
- [NET_CLIENT_DRIVER_DUMP] = net_init_dump,
163
#ifdef CONFIG_NET_BRIDGE
164
[NET_CLIENT_DRIVER_BRIDGE] = net_init_bridge,
165
#endif
166
@@ -XXX,XX +XXX,XX @@ static int net_client_init1(const void *object, bool is_netdev, Error **errp)
167
netdev = object;
168
name = netdev->id;
169
170
- if (netdev->type == NET_CLIENT_DRIVER_DUMP ||
171
- netdev->type == NET_CLIENT_DRIVER_NIC ||
172
+ if (netdev->type == NET_CLIENT_DRIVER_NIC ||
173
!net_client_init_fun[netdev->type]) {
174
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type",
175
"a netdev backend type");
176
@@ -XXX,XX +XXX,XX @@ static int net_client_init1(const void *object, bool is_netdev, Error **errp)
177
legacy.type = NET_CLIENT_DRIVER_VDE;
178
legacy.u.vde = opts->u.vde;
179
break;
180
- case NET_LEGACY_OPTIONS_TYPE_DUMP:
181
- legacy.type = NET_CLIENT_DRIVER_DUMP;
182
- legacy.u.dump = opts->u.dump;
183
- break;
184
case NET_LEGACY_OPTIONS_TYPE_BRIDGE:
185
legacy.type = NET_CLIENT_DRIVER_BRIDGE;
186
legacy.u.bridge = opts->u.bridge;
187
diff --git a/qapi/net.json b/qapi/net.json
188
index XXXXXXX..XXXXXXX 100644
189
--- a/qapi/net.json
190
+++ b/qapi/net.json
191
@@ -XXX,XX +XXX,XX @@
192
#
193
# Add a network backend.
194
#
195
-# @type: the type of network backend. Current valid values are 'user', 'tap',
196
-# 'vde', 'socket', 'dump' and 'bridge'
197
+# @type: the type of network backend. Possible values are listed in
198
+# NetClientDriver (excluding 'none' and 'nic')
199
#
200
# @id: the name of the new network backend
201
#
202
@@ -XXX,XX +XXX,XX @@
203
'*mode': 'uint16' } }
204
205
##
206
-# @NetdevDumpOptions:
207
-#
208
-# Dump VLAN network traffic to a file.
209
-#
210
-# @len: per-packet size limit (64k default). Understands [TGMKkb]
211
-# suffixes.
212
-#
213
-# @file: dump file path (default is qemu-vlan0.pcap)
214
-#
215
-# Since: 1.2
216
-##
217
-{ 'struct': 'NetdevDumpOptions',
218
- 'data': {
219
- '*len': 'size',
220
- '*file': 'str' } }
221
-
222
-##
223
# @NetdevBridgeOptions:
224
#
225
# Connect a host TAP network interface to a host bridge device.
226
@@ -XXX,XX +XXX,XX @@
227
# Available netdev drivers.
228
#
229
# Since: 2.7
230
+#
231
+# 'dump' - removed with 2.12
232
##
233
{ 'enum': 'NetClientDriver',
234
- 'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde', 'dump',
235
+ 'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde',
236
'bridge', 'hubport', 'netmap', 'vhost-user' ] }
237
238
##
239
@@ -XXX,XX +XXX,XX @@
240
'l2tpv3': 'NetdevL2TPv3Options',
241
'socket': 'NetdevSocketOptions',
242
'vde': 'NetdevVdeOptions',
243
- 'dump': 'NetdevDumpOptions',
244
'bridge': 'NetdevBridgeOptions',
245
'hubport': 'NetdevHubPortOptions',
246
'netmap': 'NetdevNetmapOptions',
247
@@ -XXX,XX +XXX,XX @@
248
##
249
{ 'enum': 'NetLegacyOptionsType',
250
'data': ['none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde',
251
- 'dump', 'bridge', 'netmap', 'vhost-user'] }
252
+ 'bridge', 'netmap', 'vhost-user'] }
253
254
##
255
# @NetLegacyOptions:
256
@@ -XXX,XX +XXX,XX @@
257
'l2tpv3': 'NetdevL2TPv3Options',
258
'socket': 'NetdevSocketOptions',
259
'vde': 'NetdevVdeOptions',
260
- 'dump': 'NetdevDumpOptions',
261
'bridge': 'NetdevBridgeOptions',
262
'netmap': 'NetdevNetmapOptions',
263
'vhost-user': 'NetdevVhostUserOptions' } }
264
diff --git a/qemu-doc.texi b/qemu-doc.texi
265
index XXXXXXX..XXXXXXX 100644
266
--- a/qemu-doc.texi
267
+++ b/qemu-doc.texi
268
@@ -XXX,XX +XXX,XX @@ that can be specified with the ``-device'' parameter.
269
The drive addr argument is replaced by the the addr argument
270
that can be specified with the ``-device'' parameter.
271
272
-@subsection -net dump (since 2.10.0)
273
-
274
-The ``--net dump'' argument is now replaced with the
275
-``-object filter-dump'' argument which works in combination
276
-with the modern ``-netdev`` backends instead.
277
-
278
@subsection -usbdevice (since 2.10.0)
279
280
The ``-usbdevice DEV'' argument is now a synonym for setting
108
diff --git a/qemu-options.hx b/qemu-options.hx
281
diff --git a/qemu-options.hx b/qemu-options.hx
109
index XXXXXXX..XXXXXXX 100644
282
index XXXXXXX..XXXXXXX 100644
110
--- a/qemu-options.hx
283
--- a/qemu-options.hx
111
+++ b/qemu-options.hx
284
+++ b/qemu-options.hx
112
@@ -XXX,XX +XXX,XX @@ queue @var{all|rx|tx} is an option that can be applied to any netfilter.
285
@@ -XXX,XX +XXX,XX @@ DEF("net", HAS_ARG, QEMU_OPTION_net,
113
@option{tx}: the filter is attached to the transmit queue of the netdev,
286
" configure or create an on-board (or machine default) NIC and\n"
114
where it will receive packets sent by the netdev.
287
" connect it either to VLAN 'n' or the netdev 'nd' (for pluggable\n"
115
288
" NICs please use '-device devtype,netdev=nd' instead)\n"
116
-@item -object filter-mirror,id=@var{id},netdev=@var{netdevid},outdev=@var{chardevid}[,queue=@var{all|rx|tx}]
289
- "-net dump[,vlan=n][,file=f][,len=n]\n"
117
+@item -object filter-mirror,id=@var{id},netdev=@var{netdevid},outdev=@var{chardevid},queue=@var{all|rx|tx}[,vnet_hdr_support]
290
- " dump traffic on vlan 'n' to file 'f' (max n bytes per packet)\n"
118
291
"-net none use it alone to have zero network devices. If no -net option\n"
119
-filter-mirror on netdev @var{netdevid},mirror net packet to chardev
292
" is provided, the default is '-net nic -net user'\n"
120
-@var{chardevid}
293
"-net ["
121
+filter-mirror on netdev @var{netdevid},mirror net packet to chardev@var{chardevid}, if it has the vnet_hdr_support flag, filter-mirror will mirror packet with vnet_hdr_len.
294
@@ -XXX,XX +XXX,XX @@ qemu -m 512 -object memory-backend-file,id=mem,size=512M,mem-path=/hugetlbfs,sha
122
295
-device virtio-net-pci,netdev=net0
123
@item -object filter-redirector,id=@var{id},netdev=@var{netdevid},indev=@var{chardevid},
296
@end example
124
outdev=@var{chardevid}[,queue=@var{all|rx|tx}]
297
298
-@item -net dump[,vlan=@var{n}][,file=@var{file}][,len=@var{len}]
299
-Dump network traffic on VLAN @var{n} to file @var{file} (@file{qemu-vlan0.pcap} by default).
300
-At most @var{len} bytes (64k by default) per packet are stored. The file format is
301
-libpcap, so it can be analyzed with tools such as tcpdump or Wireshark.
302
-Note: For devices created with '-netdev', use '-object filter-dump,...' instead.
303
-
304
@item -net none
305
Indicate that no network devices should be configured. It is used to
306
override the default configuration (@option{-net nic -net user}) which
125
--
307
--
126
2.7.4
308
2.7.4
127
309
128
310
diff view generated by jsdifflib
Deleted patch
1
From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
2
1
3
We can use this property flush and send packet with vnet_hdr_len.
4
5
Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
6
Signed-off-by: Jason Wang <jasowang@redhat.com>
7
---
8
net/colo-compare.c | 8 ++++++--
9
net/colo.c | 3 ++-
10
net/colo.h | 4 +++-
11
net/filter-rewriter.c | 2 +-
12
4 files changed, 12 insertions(+), 5 deletions(-)
13
14
diff --git a/net/colo-compare.c b/net/colo-compare.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/net/colo-compare.c
17
+++ b/net/colo-compare.c
18
@@ -XXX,XX +XXX,XX @@ static int packet_enqueue(CompareState *s, int mode)
19
Connection *conn;
20
21
if (mode == PRIMARY_IN) {
22
- pkt = packet_new(s->pri_rs.buf, s->pri_rs.packet_len);
23
+ pkt = packet_new(s->pri_rs.buf,
24
+ s->pri_rs.packet_len,
25
+ s->pri_rs.vnet_hdr_len);
26
} else {
27
- pkt = packet_new(s->sec_rs.buf, s->sec_rs.packet_len);
28
+ pkt = packet_new(s->sec_rs.buf,
29
+ s->sec_rs.packet_len,
30
+ s->sec_rs.vnet_hdr_len);
31
}
32
33
if (parse_packet_early(pkt)) {
34
diff --git a/net/colo.c b/net/colo.c
35
index XXXXXXX..XXXXXXX 100644
36
--- a/net/colo.c
37
+++ b/net/colo.c
38
@@ -XXX,XX +XXX,XX @@ void connection_destroy(void *opaque)
39
g_slice_free(Connection, conn);
40
}
41
42
-Packet *packet_new(const void *data, int size)
43
+Packet *packet_new(const void *data, int size, int vnet_hdr_len)
44
{
45
Packet *pkt = g_slice_new(Packet);
46
47
pkt->data = g_memdup(data, size);
48
pkt->size = size;
49
pkt->creation_ms = qemu_clock_get_ms(QEMU_CLOCK_HOST);
50
+ pkt->vnet_hdr_len = vnet_hdr_len;
51
52
return pkt;
53
}
54
diff --git a/net/colo.h b/net/colo.h
55
index XXXXXXX..XXXXXXX 100644
56
--- a/net/colo.h
57
+++ b/net/colo.h
58
@@ -XXX,XX +XXX,XX @@ typedef struct Packet {
59
int size;
60
/* Time of packet creation, in wall clock ms */
61
int64_t creation_ms;
62
+ /* Get vnet_hdr_len from filter */
63
+ uint32_t vnet_hdr_len;
64
} Packet;
65
66
typedef struct ConnectionKey {
67
@@ -XXX,XX +XXX,XX @@ Connection *connection_get(GHashTable *connection_track_table,
68
ConnectionKey *key,
69
GQueue *conn_list);
70
void connection_hashtable_reset(GHashTable *connection_track_table);
71
-Packet *packet_new(const void *data, int size);
72
+Packet *packet_new(const void *data, int size, int vnet_hdr_len);
73
void packet_destroy(void *opaque, void *user_data);
74
75
#endif /* QEMU_COLO_PROXY_H */
76
diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c
77
index XXXXXXX..XXXXXXX 100644
78
--- a/net/filter-rewriter.c
79
+++ b/net/filter-rewriter.c
80
@@ -XXX,XX +XXX,XX @@ static ssize_t colo_rewriter_receive_iov(NetFilterState *nf,
81
char *buf = g_malloc0(size);
82
83
iov_to_buf(iov, iovcnt, 0, buf, size);
84
- pkt = packet_new(buf, size);
85
+ pkt = packet_new(buf, size, 0);
86
g_free(buf);
87
88
/*
89
--
90
2.7.4
91
92
diff view generated by jsdifflib
1
From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
1
From: Thomas Huth <thuth@redhat.com>
2
2
3
This patch change the compare_chr_send() parameter from CharBackend to CompareState,
3
They are deprecated since QEMU v2.10, and so far nobody complained that
4
we can get more information like vnet_hdr(We use it to support packet with vnet_header).
4
these commands are still necessary for any reason - and since you can use
5
5
'netdev_add' and 'netdev_remove' instead, there also should not be any
6
Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
6
real reason. Since they are also standing in the way for the upcoming
7
'vlan' clean-up, it's now time to remove them.
8
9
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
10
Signed-off-by: Thomas Huth <thuth@redhat.com>
7
Signed-off-by: Jason Wang <jasowang@redhat.com>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
8
---
12
---
9
net/colo-compare.c | 14 +++++++-------
13
hmp-commands.hx | 30 ------------------
10
1 file changed, 7 insertions(+), 7 deletions(-)
14
hmp.h | 3 --
11
15
monitor.c | 61 ------------------------------------
12
diff --git a/net/colo-compare.c b/net/colo-compare.c
16
net/net.c | 94 --------------------------------------------------------
13
index XXXXXXX..XXXXXXX 100644
17
qemu-doc.texi | 10 ------
14
--- a/net/colo-compare.c
18
tests/test-hmp.c | 2 --
15
+++ b/net/colo-compare.c
19
6 files changed, 200 deletions(-)
16
@@ -XXX,XX +XXX,XX @@ enum {
20
17
SECONDARY_IN,
21
diff --git a/hmp-commands.hx b/hmp-commands.hx
18
};
22
index XXXXXXX..XXXXXXX 100644
19
23
--- a/hmp-commands.hx
20
-static int compare_chr_send(CharBackend *out,
24
+++ b/hmp-commands.hx
21
+static int compare_chr_send(CompareState *s,
25
@@ -XXX,XX +XXX,XX @@ Inject PCIe AER error
22
const uint8_t *buf,
26
ETEXI
23
uint32_t size);
27
24
28
{
25
@@ -XXX,XX +XXX,XX @@ static void colo_compare_connection(void *opaque, void *user_data)
29
- .name = "host_net_add",
26
}
30
- .args_type = "device:s,opts:s?",
27
31
- .params = "tap|user|socket|vde|netmap|bridge|vhost-user|dump [options]",
28
if (result) {
32
- .help = "add host VLAN client (deprecated, use netdev_add instead)",
29
- ret = compare_chr_send(&s->chr_out, pkt->data, pkt->size);
33
- .cmd = hmp_host_net_add,
30
+ ret = compare_chr_send(s, pkt->data, pkt->size);
34
- .command_completion = host_net_add_completion,
31
if (ret < 0) {
35
- },
32
error_report("colo_send_primary_packet failed");
36
-
33
}
37
-STEXI
34
@@ -XXX,XX +XXX,XX @@ static void colo_compare_connection(void *opaque, void *user_data)
38
-@item host_net_add
39
-@findex host_net_add
40
-Add host VLAN client. Deprecated, please use @code{netdev_add} instead.
41
-ETEXI
42
-
43
- {
44
- .name = "host_net_remove",
45
- .args_type = "vlan_id:i,device:s",
46
- .params = "vlan_id name",
47
- .help = "remove host VLAN client (deprecated, use netdev_del instead)",
48
- .cmd = hmp_host_net_remove,
49
- .command_completion = host_net_remove_completion,
50
- },
51
-
52
-STEXI
53
-@item host_net_remove
54
-@findex host_net_remove
55
-Remove host VLAN client. Deprecated, please use @code{netdev_del} instead.
56
-ETEXI
57
-
58
- {
59
.name = "netdev_add",
60
.args_type = "netdev:O",
61
.params = "[user|tap|socket|vde|bridge|hubport|netmap|vhost-user],id=str[,prop=value][,...]",
62
diff --git a/hmp.h b/hmp.h
63
index XXXXXXX..XXXXXXX 100644
64
--- a/hmp.h
65
+++ b/hmp.h
66
@@ -XXX,XX +XXX,XX @@ void migrate_set_capability_completion(ReadLineState *rs, int nb_args,
67
const char *str);
68
void migrate_set_parameter_completion(ReadLineState *rs, int nb_args,
69
const char *str);
70
-void host_net_add_completion(ReadLineState *rs, int nb_args, const char *str);
71
-void host_net_remove_completion(ReadLineState *rs, int nb_args,
72
- const char *str);
73
void delvm_completion(ReadLineState *rs, int nb_args, const char *str);
74
void loadvm_completion(ReadLineState *rs, int nb_args, const char *str);
75
void hmp_rocker(Monitor *mon, const QDict *qdict);
76
diff --git a/monitor.c b/monitor.c
77
index XXXXXXX..XXXXXXX 100644
78
--- a/monitor.c
79
+++ b/monitor.c
80
@@ -XXX,XX +XXX,XX @@ void migrate_set_parameter_completion(ReadLineState *rs, int nb_args,
35
}
81
}
36
}
82
}
37
83
38
-static int compare_chr_send(CharBackend *out,
84
-void host_net_add_completion(ReadLineState *rs, int nb_args, const char *str)
39
+static int compare_chr_send(CompareState *s,
85
-{
40
const uint8_t *buf,
86
- int i;
41
uint32_t size)
87
- size_t len;
88
- if (nb_args != 2) {
89
- return;
90
- }
91
- len = strlen(str);
92
- readline_set_completion_index(rs, len);
93
- for (i = 0; host_net_devices[i]; i++) {
94
- if (!strncmp(host_net_devices[i], str, len)) {
95
- readline_add_completion(rs, host_net_devices[i]);
96
- }
97
- }
98
-}
99
-
100
-void host_net_remove_completion(ReadLineState *rs, int nb_args, const char *str)
101
-{
102
- NetClientState *ncs[MAX_QUEUE_NUM];
103
- int count, i, len;
104
-
105
- len = strlen(str);
106
- readline_set_completion_index(rs, len);
107
- if (nb_args == 2) {
108
- count = qemu_find_net_clients_except(NULL, ncs,
109
- NET_CLIENT_DRIVER_NONE,
110
- MAX_QUEUE_NUM);
111
- for (i = 0; i < MIN(count, MAX_QUEUE_NUM); i++) {
112
- int id;
113
- char name[16];
114
-
115
- if (net_hub_id_for_client(ncs[i], &id)) {
116
- continue;
117
- }
118
- snprintf(name, sizeof(name), "%d", id);
119
- if (!strncmp(str, name, len)) {
120
- readline_add_completion(rs, name);
121
- }
122
- }
123
- return;
124
- } else if (nb_args == 3) {
125
- count = qemu_find_net_clients_except(NULL, ncs,
126
- NET_CLIENT_DRIVER_NIC,
127
- MAX_QUEUE_NUM);
128
- for (i = 0; i < MIN(count, MAX_QUEUE_NUM); i++) {
129
- int id;
130
- const char *name;
131
-
132
- if (ncs[i]->info->type == NET_CLIENT_DRIVER_HUBPORT ||
133
- net_hub_id_for_client(ncs[i], &id)) {
134
- continue;
135
- }
136
- name = ncs[i]->name;
137
- if (!strncmp(str, name, len)) {
138
- readline_add_completion(rs, name);
139
- }
140
- }
141
- return;
142
- }
143
-}
144
-
145
static void vm_completion(ReadLineState *rs, const char *str)
42
{
146
{
43
@@ -XXX,XX +XXX,XX @@ static int compare_chr_send(CharBackend *out,
147
size_t len;
44
return 0;
148
diff --git a/net/net.c b/net/net.c
45
}
149
index XXXXXXX..XXXXXXX 100644
46
150
--- a/net/net.c
47
- ret = qemu_chr_fe_write_all(out, (uint8_t *)&len, sizeof(len));
151
+++ b/net/net.c
48
+ ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)&len, sizeof(len));
152
@@ -XXX,XX +XXX,XX @@
49
if (ret != sizeof(len)) {
153
static VMChangeStateEntry *net_change_state_entry;
50
goto err;
154
static QTAILQ_HEAD(, NetClientState) net_clients;
51
}
155
52
156
-const char *host_net_devices[] = {
53
- ret = qemu_chr_fe_write_all(out, (uint8_t *)buf, size);
157
- "tap",
54
+ ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)buf, size);
158
- "socket",
55
if (ret != size) {
159
-#ifdef CONFIG_NET_BRIDGE
56
goto err;
160
- "bridge",
57
}
161
-#endif
58
@@ -XXX,XX +XXX,XX @@ static void compare_pri_rs_finalize(SocketReadState *pri_rs)
162
-#ifdef CONFIG_NETMAP
59
163
- "netmap",
60
if (packet_enqueue(s, PRIMARY_IN)) {
164
-#endif
61
trace_colo_compare_main("primary: unsupported packet in");
165
-#ifdef CONFIG_SLIRP
62
- compare_chr_send(&s->chr_out, pri_rs->buf, pri_rs->packet_len);
166
- "user",
63
+ compare_chr_send(s, pri_rs->buf, pri_rs->packet_len);
167
-#endif
64
} else {
168
-#ifdef CONFIG_VDE
65
/* compare connection */
169
- "vde",
66
g_queue_foreach(&s->conn_list, colo_compare_connection, s);
170
-#endif
67
@@ -XXX,XX +XXX,XX @@ static void colo_flush_packets(void *opaque, void *user_data)
171
- "vhost-user",
68
172
- NULL,
69
while (!g_queue_is_empty(&conn->primary_list)) {
173
-};
70
pkt = g_queue_pop_head(&conn->primary_list);
174
-
71
- compare_chr_send(&s->chr_out, pkt->data, pkt->size);
175
/***********************************************************/
72
+ compare_chr_send(s, pkt->data, pkt->size);
176
/* network device redirectors */
73
packet_destroy(pkt, NULL);
177
74
}
178
@@ -XXX,XX +XXX,XX @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
75
while (!g_queue_is_empty(&conn->secondary_list)) {
179
return ret;
180
}
181
182
-
183
-static int net_host_check_device(const char *device)
184
-{
185
- int i;
186
- for (i = 0; host_net_devices[i]; i++) {
187
- if (!strncmp(host_net_devices[i], device,
188
- strlen(host_net_devices[i]))) {
189
- return 1;
190
- }
191
- }
192
-
193
- return 0;
194
-}
195
-
196
-void hmp_host_net_add(Monitor *mon, const QDict *qdict)
197
-{
198
- const char *device = qdict_get_str(qdict, "device");
199
- const char *opts_str = qdict_get_try_str(qdict, "opts");
200
- Error *local_err = NULL;
201
- QemuOpts *opts;
202
- static bool warned;
203
-
204
- if (!warned && !qtest_enabled()) {
205
- error_report("host_net_add is deprecated, use netdev_add instead");
206
- warned = true;
207
- }
208
-
209
- if (!net_host_check_device(device)) {
210
- monitor_printf(mon, "invalid host network device %s\n", device);
211
- return;
212
- }
213
-
214
- opts = qemu_opts_parse_noisily(qemu_find_opts("net"),
215
- opts_str ? opts_str : "", false);
216
- if (!opts) {
217
- return;
218
- }
219
-
220
- qemu_opt_set(opts, "type", device, &error_abort);
221
-
222
- net_client_init(opts, false, &local_err);
223
- if (local_err) {
224
- error_report_err(local_err);
225
- monitor_printf(mon, "adding host network device %s failed\n", device);
226
- }
227
-}
228
-
229
-void hmp_host_net_remove(Monitor *mon, const QDict *qdict)
230
-{
231
- NetClientState *nc;
232
- int vlan_id = qdict_get_int(qdict, "vlan_id");
233
- const char *device = qdict_get_str(qdict, "device");
234
- static bool warned;
235
-
236
- if (!warned && !qtest_enabled()) {
237
- error_report("host_net_remove is deprecated, use netdev_del instead");
238
- warned = true;
239
- }
240
-
241
- nc = net_hub_find_client_by_name(vlan_id, device);
242
- if (!nc) {
243
- error_report("Host network device '%s' on hub '%d' not found",
244
- device, vlan_id);
245
- return;
246
- }
247
- if (nc->info->type == NET_CLIENT_DRIVER_NIC) {
248
- error_report("invalid host network device '%s'", device);
249
- return;
250
- }
251
-
252
- qemu_del_net_client(nc->peer);
253
- qemu_del_net_client(nc);
254
- qemu_opts_del(qemu_opts_find(qemu_find_opts("net"), device));
255
-}
256
-
257
void netdev_add(QemuOpts *opts, Error **errp)
258
{
259
net_client_init(opts, true, errp);
260
diff --git a/qemu-doc.texi b/qemu-doc.texi
261
index XXXXXXX..XXXXXXX 100644
262
--- a/qemu-doc.texi
263
+++ b/qemu-doc.texi
264
@@ -XXX,XX +XXX,XX @@ from qcow2 images.
265
266
The ``query-cpus'' command is replaced by the ``query-cpus-fast'' command.
267
268
-@section System emulator human monitor commands
269
-
270
-@subsection host_net_add (since 2.10.0)
271
-
272
-The ``host_net_add'' command is replaced by the ``netdev_add'' command.
273
-
274
-@subsection host_net_remove (since 2.10.0)
275
-
276
-The ``host_net_remove'' command is replaced by the ``netdev_del'' command.
277
-
278
@section System emulator devices
279
280
@subsection ivshmem (since 2.6.0)
281
diff --git a/tests/test-hmp.c b/tests/test-hmp.c
282
index XXXXXXX..XXXXXXX 100644
283
--- a/tests/test-hmp.c
284
+++ b/tests/test-hmp.c
285
@@ -XXX,XX +XXX,XX @@ static const char *hmp_cmds[] = {
286
"dump-guest-memory /dev/null 0 4096",
287
"dump-guest-memory /dev/null",
288
"gdbserver",
289
- "host_net_add user id=net0",
290
"hostfwd_add tcp::43210-:43210",
291
"hostfwd_remove tcp::43210-:43210",
292
- "host_net_remove 0 net0",
293
"i /w 0",
294
"log all",
295
"log none",
76
--
296
--
77
2.7.4
297
2.7.4
78
298
79
299
diff view generated by jsdifflib
Deleted patch
1
From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
2
1
3
Make colo-compare and filter-rewriter can parse vnet packet.
4
5
Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
6
Signed-off-by: Jason Wang <jasowang@redhat.com>
7
---
8
net/colo.c | 6 +++---
9
1 file changed, 3 insertions(+), 3 deletions(-)
10
11
diff --git a/net/colo.c b/net/colo.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/net/colo.c
14
+++ b/net/colo.c
15
@@ -XXX,XX +XXX,XX @@ int parse_packet_early(Packet *pkt)
16
{
17
int network_length;
18
static const uint8_t vlan[] = {0x81, 0x00};
19
- uint8_t *data = pkt->data;
20
+ uint8_t *data = pkt->data + pkt->vnet_hdr_len;
21
uint16_t l3_proto;
22
ssize_t l2hdr_len = eth_get_l2_hdr_length(data);
23
24
- if (pkt->size < ETH_HLEN) {
25
+ if (pkt->size < ETH_HLEN + pkt->vnet_hdr_len) {
26
trace_colo_proxy_main("pkt->size < ETH_HLEN");
27
return 1;
28
}
29
@@ -XXX,XX +XXX,XX @@ int parse_packet_early(Packet *pkt)
30
}
31
32
network_length = pkt->ip->ip_hl * 4;
33
- if (pkt->size < l2hdr_len + network_length) {
34
+ if (pkt->size < l2hdr_len + network_length + pkt->vnet_hdr_len) {
35
trace_colo_proxy_main("pkt->size < network_header + network_length");
36
return 1;
37
}
38
--
39
2.7.4
40
41
diff view generated by jsdifflib
Deleted patch
1
From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
2
1
3
COLO-Proxy just focus on packet payload, so we skip vnet header.
4
5
Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
6
Signed-off-by: Jason Wang <jasowang@redhat.com>
7
---
8
net/colo-compare.c | 8 ++++++--
9
1 file changed, 6 insertions(+), 2 deletions(-)
10
11
diff --git a/net/colo-compare.c b/net/colo-compare.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/net/colo-compare.c
14
+++ b/net/colo-compare.c
15
@@ -XXX,XX +XXX,XX @@ static int colo_packet_compare_common(Packet *ppkt, Packet *spkt, int offset)
16
sec_ip_src, sec_ip_dst);
17
}
18
19
+ offset = ppkt->vnet_hdr_len + offset;
20
+
21
if (ppkt->size == spkt->size) {
22
- return memcmp(ppkt->data + offset, spkt->data + offset,
23
+ return memcmp(ppkt->data + offset,
24
+ spkt->data + offset,
25
spkt->size - offset);
26
} else {
27
trace_colo_compare_main("Net packet size are not the same");
28
@@ -XXX,XX +XXX,XX @@ static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt)
29
*/
30
if (ptcp->th_off > 5) {
31
ptrdiff_t tcp_offset;
32
+
33
tcp_offset = ppkt->transport_header - (uint8_t *)ppkt->data
34
- + (ptcp->th_off * 4);
35
+ + (ptcp->th_off * 4) - ppkt->vnet_hdr_len;
36
res = colo_packet_compare_common(ppkt, spkt, tcp_offset);
37
} else if (ptcp->th_sum == stcp->th_sum) {
38
res = colo_packet_compare_common(ppkt, spkt, ETH_HLEN);
39
--
40
2.7.4
41
42
diff view generated by jsdifflib
1
From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
1
From: Thomas Huth <thuth@redhat.com>
2
2
3
We add the vnet_hdr_support option for filter-rewriter, default is disabled.
3
The legacy "-net" option can be quite confusing for the users since most
4
If you use virtio-net-pci or other driver needs vnet_hdr, please enable it.
4
people do not expect to get a "vlan" hub between their emulated guest
5
You can use it for example:
5
hardware and the host backend. But so far, we are also not able to get
6
-object filter-rewriter,id=rew0,netdev=hn0,queue=all,vnet_hdr_support
6
rid of "-net" completely, since it is the only way to configure on-board
7
7
NICs that can not be instantiated via "-device" yet. It's also a little
8
We get the vnet_hdr_len from NetClientState that make us
8
bit shorter to type "-net nic -net tap" instead of "-device xyz,netdev=n1
9
parse net packet correctly.
9
-netdev tap,id=n1".
10
10
11
Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
11
So what we need is a new convenience option that is shorter to type than
12
the full -device + -netdev stuff, and which can be used to configure the
13
on-board NICs that can not be handled via -device yet. Thus this patch now
14
provides such a new option "--nic": It adds an entry in the nd_table to
15
configure a on-board / default NIC, creates a host backend and connects
16
the two directly, without a confusing "vlan" hub inbetween.
17
18
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
19
Signed-off-by: Thomas Huth <thuth@redhat.com>
12
Signed-off-by: Jason Wang <jasowang@redhat.com>
20
Signed-off-by: Jason Wang <jasowang@redhat.com>
13
---
21
---
14
net/filter-rewriter.c | 37 ++++++++++++++++++++++++++++++++++++-
22
include/sysemu/sysemu.h | 1 +
15
qemu-options.hx | 4 ++--
23
net/net.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++
16
2 files changed, 38 insertions(+), 3 deletions(-)
24
qemu-options.hx | 40 +++++++++++++++++++++----
17
25
vl.c | 7 +++++
18
diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c
26
4 files changed, 120 insertions(+), 6 deletions(-)
19
index XXXXXXX..XXXXXXX 100644
27
20
--- a/net/filter-rewriter.c
28
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
21
+++ b/net/filter-rewriter.c
29
index XXXXXXX..XXXXXXX 100644
22
@@ -XXX,XX +XXX,XX @@
30
--- a/include/sysemu/sysemu.h
23
#include "qemu-common.h"
31
+++ b/include/sysemu/sysemu.h
24
#include "qapi/error.h"
32
@@ -XXX,XX +XXX,XX @@ extern QemuOptsList bdrv_runtime_opts;
25
#include "qapi/qmp/qerror.h"
33
extern QemuOptsList qemu_chardev_opts;
26
+#include "qemu/error-report.h"
34
extern QemuOptsList qemu_device_opts;
27
#include "qapi-visit.h"
35
extern QemuOptsList qemu_netdev_opts;
28
#include "qom/object.h"
36
+extern QemuOptsList qemu_nic_opts;
29
#include "qemu/main-loop.h"
37
extern QemuOptsList qemu_net_opts;
30
@@ -XXX,XX +XXX,XX @@ typedef struct RewriterState {
38
extern QemuOptsList qemu_global_opts;
31
NetQueue *incoming_queue;
39
extern QemuOptsList qemu_mon_opts;
32
/* hashtable to save connection */
40
diff --git a/net/net.c b/net/net.c
33
GHashTable *connection_track_table;
41
index XXXXXXX..XXXXXXX 100644
34
+ bool vnet_hdr;
42
--- a/net/net.c
35
} RewriterState;
43
+++ b/net/net.c
36
44
@@ -XXX,XX +XXX,XX @@ static int net_init_netdev(void *dummy, QemuOpts *opts, Error **errp)
37
static void filter_rewriter_flush(NetFilterState *nf)
45
return net_client_init(opts, true, errp);
38
@@ -XXX,XX +XXX,XX @@ static ssize_t colo_rewriter_receive_iov(NetFilterState *nf,
39
ConnectionKey key;
40
Packet *pkt;
41
ssize_t size = iov_size(iov, iovcnt);
42
+ ssize_t vnet_hdr_len = 0;
43
char *buf = g_malloc0(size);
44
45
iov_to_buf(iov, iovcnt, 0, buf, size);
46
- pkt = packet_new(buf, size, 0);
47
+
48
+ if (s->vnet_hdr) {
49
+ vnet_hdr_len = nf->netdev->vnet_hdr_len;
50
+ }
51
+
52
+ pkt = packet_new(buf, size, vnet_hdr_len);
53
g_free(buf);
54
55
/*
56
@@ -XXX,XX +XXX,XX @@ static void colo_rewriter_setup(NetFilterState *nf, Error **errp)
57
s->incoming_queue = qemu_new_net_queue(qemu_netfilter_pass_to_next, nf);
58
}
46
}
59
47
60
+static bool filter_rewriter_get_vnet_hdr(Object *obj, Error **errp)
48
+/* For the convenience "--nic" parameter */
49
+static int net_param_nic(void *dummy, QemuOpts *opts, Error **errp)
61
+{
50
+{
62
+ RewriterState *s = FILTER_COLO_REWRITER(obj);
51
+ char *mac, *nd_id;
63
+
52
+ int idx, ret;
64
+ return s->vnet_hdr;
53
+ NICInfo *ni;
54
+ const char *type;
55
+
56
+ type = qemu_opt_get(opts, "type");
57
+ if (type && g_str_equal(type, "none")) {
58
+ return 0; /* Nothing to do, default_net is cleared in vl.c */
59
+ }
60
+
61
+ idx = nic_get_free_idx();
62
+ if (idx == -1 || nb_nics >= MAX_NICS) {
63
+ error_setg(errp, "no more on-board/default NIC slots available");
64
+ return -1;
65
+ }
66
+
67
+ if (!type) {
68
+ qemu_opt_set(opts, "type", "user", &error_abort);
69
+ }
70
+
71
+ ni = &nd_table[idx];
72
+ memset(ni, 0, sizeof(*ni));
73
+ ni->model = qemu_opt_get_del(opts, "model");
74
+
75
+ /* Create an ID if the user did not specify one */
76
+ nd_id = g_strdup(qemu_opts_id(opts));
77
+ if (!nd_id) {
78
+ nd_id = g_strdup_printf("__org.qemu.nic%i\n", idx);
79
+ qemu_opts_set_id(opts, nd_id);
80
+ }
81
+
82
+ /* Handle MAC address */
83
+ mac = qemu_opt_get_del(opts, "mac");
84
+ if (mac) {
85
+ ret = net_parse_macaddr(ni->macaddr.a, mac);
86
+ g_free(mac);
87
+ if (ret) {
88
+ error_setg(errp, "invalid syntax for ethernet address");
89
+ return -1;
90
+ }
91
+ if (is_multicast_ether_addr(ni->macaddr.a)) {
92
+ error_setg(errp, "NIC cannot have multicast MAC address");
93
+ return -1;
94
+ }
95
+ }
96
+ qemu_macaddr_default_if_unset(&ni->macaddr);
97
+
98
+ ret = net_client_init(opts, true, errp);
99
+ if (ret == 0) {
100
+ ni->netdev = qemu_find_netdev(nd_id);
101
+ ni->used = true;
102
+ nb_nics++;
103
+ }
104
+
105
+ g_free(nd_id);
106
+ return ret;
65
+}
107
+}
66
+
108
+
67
+static void filter_rewriter_set_vnet_hdr(Object *obj,
109
int net_init_clients(Error **errp)
68
+ bool value,
69
+ Error **errp)
70
+{
71
+ RewriterState *s = FILTER_COLO_REWRITER(obj);
72
+
73
+ s->vnet_hdr = value;
74
+}
75
+
76
+static void filter_rewriter_init(Object *obj)
77
+{
78
+ RewriterState *s = FILTER_COLO_REWRITER(obj);
79
+
80
+ s->vnet_hdr = false;
81
+ object_property_add_bool(obj, "vnet_hdr_support",
82
+ filter_rewriter_get_vnet_hdr,
83
+ filter_rewriter_set_vnet_hdr, NULL);
84
+}
85
+
86
static void colo_rewriter_class_init(ObjectClass *oc, void *data)
87
{
110
{
88
NetFilterClass *nfc = NETFILTER_CLASS(oc);
111
net_change_state_entry =
89
@@ -XXX,XX +XXX,XX @@ static const TypeInfo colo_rewriter_info = {
112
@@ -XXX,XX +XXX,XX @@ int net_init_clients(Error **errp)
90
.name = TYPE_FILTER_REWRITER,
113
return -1;
91
.parent = TYPE_NETFILTER,
114
}
92
.class_init = colo_rewriter_class_init,
115
93
+ .instance_init = filter_rewriter_init,
116
+ if (qemu_opts_foreach(qemu_find_opts("nic"), net_param_nic, NULL, errp)) {
94
.instance_size = sizeof(RewriterState),
117
+ return -1;
118
+ }
119
+
120
if (qemu_opts_foreach(qemu_find_opts("net"), net_init_client, NULL, errp)) {
121
return -1;
122
}
123
@@ -XXX,XX +XXX,XX @@ QemuOptsList qemu_netdev_opts = {
124
},
95
};
125
};
96
126
127
+QemuOptsList qemu_nic_opts = {
128
+ .name = "nic",
129
+ .implied_opt_name = "type",
130
+ .head = QTAILQ_HEAD_INITIALIZER(qemu_nic_opts.head),
131
+ .desc = {
132
+ /*
133
+ * no elements => accept any params
134
+ * validation will happen later
135
+ */
136
+ { /* end of list */ }
137
+ },
138
+};
139
+
140
QemuOptsList qemu_net_opts = {
141
.name = "net",
142
.implied_opt_name = "type",
97
diff --git a/qemu-options.hx b/qemu-options.hx
143
diff --git a/qemu-options.hx b/qemu-options.hx
98
index XXXXXXX..XXXXXXX 100644
144
index XXXXXXX..XXXXXXX 100644
99
--- a/qemu-options.hx
145
--- a/qemu-options.hx
100
+++ b/qemu-options.hx
146
+++ b/qemu-options.hx
101
@@ -XXX,XX +XXX,XX @@ Create a filter-redirector we need to differ outdev id from indev id, id can not
147
@@ -XXX,XX +XXX,XX @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,
102
be the same. we can just use indev or outdev, but at least one of indev or outdev
148
#endif
103
need to be specified.
149
"-netdev hubport,id=str,hubid=n[,netdev=nd]\n"
104
150
" configure a hub port on QEMU VLAN 'n'\n", QEMU_ARCH_ALL)
105
-@item -object filter-rewriter,id=@var{id},netdev=@var{netdevid}[,queue=@var{all|rx|tx}]
151
+DEF("nic", HAS_ARG, QEMU_OPTION_nic,
106
+@item -object filter-rewriter,id=@var{id},netdev=@var{netdevid},queue=@var{all|rx|tx},[vnet_hdr_support]
152
+ "--nic [tap|bridge|"
107
153
+#ifdef CONFIG_SLIRP
108
Filter-rewriter is a part of COLO project.It will rewrite tcp packet to
154
+ "user|"
109
secondary from primary to keep secondary tcp connection,and rewrite
155
+#endif
110
tcp packet to primary from secondary make tcp packet can be handled by
156
+#ifdef __linux__
111
-client.
157
+ "l2tpv3|"
112
+client.if it has the vnet_hdr_support flag, we can parse packet with vnet header.
158
+#endif
113
159
+#ifdef CONFIG_VDE
114
usage:
160
+ "vde|"
115
colo secondary:
161
+#endif
162
+#ifdef CONFIG_NETMAP
163
+ "netmap|"
164
+#endif
165
+#ifdef CONFIG_POSIX
166
+ "vhost-user|"
167
+#endif
168
+ "socket][,option][,...][mac=macaddr]\n"
169
+ " initialize an on-board / default host NIC (using MAC address\n"
170
+ " macaddr) and connect it to the given host network backend\n"
171
+ "--nic none use it alone to have zero network devices (the default is to\n"
172
+ " provided a 'user' network connection)\n",
173
+ QEMU_ARCH_ALL)
174
DEF("net", HAS_ARG, QEMU_OPTION_net,
175
"-net nic[,vlan=n][,netdev=nd][,macaddr=mac][,model=type][,name=str][,addr=str][,vectors=v]\n"
176
" configure or create an on-board (or machine default) NIC and\n"
177
" connect it either to VLAN 'n' or the netdev 'nd' (for pluggable\n"
178
" NICs please use '-device devtype,netdev=nd' instead)\n"
179
- "-net none use it alone to have zero network devices. If no -net option\n"
180
- " is provided, the default is '-net nic -net user'\n"
181
"-net ["
182
#ifdef CONFIG_SLIRP
183
"user|"
184
@@ -XXX,XX +XXX,XX @@ qemu -m 512 -object memory-backend-file,id=mem,size=512M,mem-path=/hugetlbfs,sha
185
-device virtio-net-pci,netdev=net0
186
@end example
187
188
-@item -net none
189
-Indicate that no network devices should be configured. It is used to
190
-override the default configuration (@option{-net nic -net user}) which
191
-is activated if no @option{-net} options are provided.
192
+@item --nic [tap|bridge|user|l2tpv3|vde|netmap|vhost-user|socket][,...][,mac=macaddr]
193
+
194
+This option is a shortcut for setting both, the on-board (default) guest NIC
195
+hardware and the host network backend in one go. The host backend options are
196
+the same as with the corresponding @option{--netdev} option. The guest NIC
197
+hardware MAC address can be set with @option{mac=@var{macaddr}}.
198
+
199
+@item --nic none
200
+Indicate that no network devices should be configured. It is used to override
201
+the default configuration (default NIC with @option{--net user} backend) which
202
+is activated if no other networking options are provided.
203
ETEXI
204
205
STEXI
206
diff --git a/vl.c b/vl.c
207
index XXXXXXX..XXXXXXX 100644
208
--- a/vl.c
209
+++ b/vl.c
210
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv, char **envp)
211
qemu_add_opts(&qemu_chardev_opts);
212
qemu_add_opts(&qemu_device_opts);
213
qemu_add_opts(&qemu_netdev_opts);
214
+ qemu_add_opts(&qemu_nic_opts);
215
qemu_add_opts(&qemu_net_opts);
216
qemu_add_opts(&qemu_rtc_opts);
217
qemu_add_opts(&qemu_global_opts);
218
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv, char **envp)
219
exit(1);
220
}
221
break;
222
+ case QEMU_OPTION_nic:
223
+ default_net = 0;
224
+ if (net_client_parse(qemu_find_opts("nic"), optarg) == -1) {
225
+ exit(1);
226
+ }
227
+ break;
228
case QEMU_OPTION_net:
229
default_net = 0;
230
if (net_client_parse(qemu_find_opts("net"), optarg) == -1) {
116
--
231
--
117
2.7.4
232
2.7.4
118
233
119
234
diff view generated by jsdifflib
Deleted patch
1
From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
2
1
3
Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
4
Signed-off-by: Jason Wang <jasowang@redhat.com>
5
---
6
docs/colo-proxy.txt | 26 ++++++++++++++++++++++++++
7
1 file changed, 26 insertions(+)
8
9
diff --git a/docs/colo-proxy.txt b/docs/colo-proxy.txt
10
index XXXXXXX..XXXXXXX 100644
11
--- a/docs/colo-proxy.txt
12
+++ b/docs/colo-proxy.txt
13
@@ -XXX,XX +XXX,XX @@ Secondary(ip:3.3.3.8):
14
-chardev socket,id=red1,host=3.3.3.3,port=9004
15
-object filter-redirector,id=f1,netdev=hn0,queue=tx,indev=red0
16
-object filter-redirector,id=f2,netdev=hn0,queue=rx,outdev=red1
17
+-object filter-rewriter,id=f3,netdev=hn0,queue=all
18
+
19
+If you want to use virtio-net-pci or other driver with vnet_header:
20
+
21
+Primary(ip:3.3.3.3):
22
+-netdev tap,id=hn0,vhost=off,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown
23
+-device e1000,id=e0,netdev=hn0,mac=52:a4:00:12:78:66
24
+-chardev socket,id=mirror0,host=3.3.3.3,port=9003,server,nowait
25
+-chardev socket,id=compare1,host=3.3.3.3,port=9004,server,nowait
26
+-chardev socket,id=compare0,host=3.3.3.3,port=9001,server,nowait
27
+-chardev socket,id=compare0-0,host=3.3.3.3,port=9001
28
+-chardev socket,id=compare_out,host=3.3.3.3,port=9005,server,nowait
29
+-chardev socket,id=compare_out0,host=3.3.3.3,port=9005
30
+-object filter-mirror,id=m0,netdev=hn0,queue=tx,outdev=mirror0,vnet_hdr_support
31
+-object filter-redirector,netdev=hn0,id=redire0,queue=rx,indev=compare_out,vnet_hdr_support
32
+-object filter-redirector,netdev=hn0,id=redire1,queue=rx,outdev=compare0,vnet_hdr_support
33
+-object colo-compare,id=comp0,primary_in=compare0-0,secondary_in=compare1,outdev=compare_out0,vnet_hdr_support
34
+
35
+Secondary(ip:3.3.3.8):
36
+-netdev tap,id=hn0,vhost=off,script=/etc/qemu-ifup,down script=/etc/qemu-ifdown
37
+-device e1000,netdev=hn0,mac=52:a4:00:12:78:66
38
+-chardev socket,id=red0,host=3.3.3.3,port=9003
39
+-chardev socket,id=red1,host=3.3.3.3,port=9004
40
+-object filter-redirector,id=f1,netdev=hn0,queue=tx,indev=red0,vnet_hdr_support
41
+-object filter-redirector,id=f2,netdev=hn0,queue=rx,outdev=red1,vnet_hdr_support
42
+-object filter-rewriter,id=f3,netdev=hn0,queue=all,vnet_hdr_support
43
44
Note:
45
a.COLO-proxy must work with COLO-frame and Block-replication.
46
--
47
2.7.4
48
49
diff view generated by jsdifflib
1
Spec said offloads should be le64, so use virtio_ldq_p() to guarantee
1
From: Thomas Huth <thuth@redhat.com>
2
valid endian.
3
2
4
Fixes: 644c98587d4c ("virtio-net: dynamic network offloads configuration")
3
Headers like "hw/loader.h" and "qemu/sockets.h" are not needed in
5
Cc: qemu-stable@nongnu.org
4
the hw/net/*.c files. And Some other headers are included via other
6
Cc: Dmitry Fleytman <dfleytma@redhat.com>
5
headers already, so we can drop them, too.
6
7
Signed-off-by: Thomas Huth <thuth@redhat.com>
7
Signed-off-by: Jason Wang <jasowang@redhat.com>
8
Signed-off-by: Jason Wang <jasowang@redhat.com>
8
---
9
---
9
hw/net/virtio-net.c | 2 ++
10
hw/net/e1000.c | 1 -
10
1 file changed, 2 insertions(+)
11
hw/net/lance.c | 3 ---
12
hw/net/ne2000.c | 2 --
13
hw/net/pcnet-pci.c | 1 -
14
hw/net/pcnet.c | 1 -
15
hw/net/rtl8139.c | 2 --
16
hw/net/xgmac.c | 1 -
17
7 files changed, 11 deletions(-)
11
18
12
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
19
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
13
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/net/virtio-net.c
21
--- a/hw/net/e1000.c
15
+++ b/hw/net/virtio-net.c
22
+++ b/hw/net/e1000.c
16
@@ -XXX,XX +XXX,XX @@ static int virtio_net_handle_offloads(VirtIONet *n, uint8_t cmd,
23
@@ -XXX,XX +XXX,XX @@
17
if (cmd == VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET) {
24
#include "hw/pci/pci.h"
18
uint64_t supported_offloads;
25
#include "net/net.h"
19
26
#include "net/checksum.h"
20
+ offloads = virtio_ldq_p(vdev, &offloads);
27
-#include "hw/loader.h"
21
+
28
#include "sysemu/sysemu.h"
22
if (!n->has_vnet_hdr) {
29
#include "sysemu/dma.h"
23
return VIRTIO_NET_ERR;
30
#include "qemu/iov.h"
24
}
31
diff --git a/hw/net/lance.c b/hw/net/lance.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/net/lance.c
34
+++ b/hw/net/lance.c
35
@@ -XXX,XX +XXX,XX @@
36
*/
37
38
#include "qemu/osdep.h"
39
-#include "hw/sysbus.h"
40
-#include "net/net.h"
41
#include "qemu/timer.h"
42
-#include "qemu/sockets.h"
43
#include "hw/sparc/sparc32_dma.h"
44
#include "hw/net/lance.h"
45
#include "trace.h"
46
diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c
47
index XXXXXXX..XXXXXXX 100644
48
--- a/hw/net/ne2000.c
49
+++ b/hw/net/ne2000.c
50
@@ -XXX,XX +XXX,XX @@
51
*/
52
#include "qemu/osdep.h"
53
#include "hw/pci/pci.h"
54
-#include "net/net.h"
55
#include "net/eth.h"
56
#include "ne2000.h"
57
-#include "hw/loader.h"
58
#include "sysemu/sysemu.h"
59
60
/* debug NE2000 card */
61
diff --git a/hw/net/pcnet-pci.c b/hw/net/pcnet-pci.c
62
index XXXXXXX..XXXXXXX 100644
63
--- a/hw/net/pcnet-pci.c
64
+++ b/hw/net/pcnet-pci.c
65
@@ -XXX,XX +XXX,XX @@
66
#include "qemu/osdep.h"
67
#include "hw/pci/pci.h"
68
#include "net/net.h"
69
-#include "hw/loader.h"
70
#include "qemu/timer.h"
71
#include "sysemu/dma.h"
72
#include "sysemu/sysemu.h"
73
diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c
74
index XXXXXXX..XXXXXXX 100644
75
--- a/hw/net/pcnet.c
76
+++ b/hw/net/pcnet.c
77
@@ -XXX,XX +XXX,XX @@
78
#include "net/net.h"
79
#include "net/eth.h"
80
#include "qemu/timer.h"
81
-#include "qemu/sockets.h"
82
#include "sysemu/sysemu.h"
83
#include "trace.h"
84
85
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
86
index XXXXXXX..XXXXXXX 100644
87
--- a/hw/net/rtl8139.c
88
+++ b/hw/net/rtl8139.c
89
@@ -XXX,XX +XXX,XX @@
90
#include "qemu/timer.h"
91
#include "net/net.h"
92
#include "net/eth.h"
93
-#include "hw/loader.h"
94
#include "sysemu/sysemu.h"
95
-#include "qemu/iov.h"
96
97
/* debug RTL8139 card */
98
//#define DEBUG_RTL8139 1
99
diff --git a/hw/net/xgmac.c b/hw/net/xgmac.c
100
index XXXXXXX..XXXXXXX 100644
101
--- a/hw/net/xgmac.c
102
+++ b/hw/net/xgmac.c
103
@@ -XXX,XX +XXX,XX @@
104
#include "hw/sysbus.h"
105
#include "qemu/log.h"
106
#include "net/net.h"
107
-#include "net/checksum.h"
108
109
#ifdef DEBUG_XGMAC
110
#define DEBUGF_BRK(message, args...) do { \
25
--
111
--
26
2.7.4
112
2.7.4
27
113
28
114
diff view generated by jsdifflib
1
From: Michal Privoznik <mprivozn@redhat.com>
1
From: Jay Zhou <jianjay.zhou@huawei.com>
2
2
3
We have a function that checks if given number is power of two.
3
If netdev_add tap,id=net0,...,vhost=on failed in net_init_tap_one(),
4
We should prefer it instead of expanding the check on our own.
4
the followed up device_add virtio-net-pci,netdev=net0 will fail
5
too, prints:
5
6
6
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7
TUNSETOFFLOAD ioctl() failed: Bad file descriptor TUNSETOFFLOAD
8
ioctl() failed: Bad file descriptor
9
10
The reason is that the fd of tap is closed when error occured after
11
calling net_init_tap_one().
12
13
The fd should be closed when calling net_init_tap_one failed:
14
- if tap_set_sndbuf() failed
15
- if tap_set_sndbuf() succeeded but vhost failed to open or
16
initialize with vhostforce flag on
17
- with wrong vhost command line parameter
18
The fd should not be closed just because vhost failed to open or
19
initialize but without vhostforce flag. So the followed up
20
device_add can fall back to userspace virtio successfully.
21
22
Suggested-by: Michael S. Tsirkin <mst@redhat.com>
23
Suggested-by: Igor Mammedov <imammedo@redhat.com>
24
Suggested-by: Jason Wang <jasowang@redhat.com>
25
Signed-off-by: Jay Zhou <jianjay.zhou@huawei.com>
7
Signed-off-by: Jason Wang <jasowang@redhat.com>
26
Signed-off-by: Jason Wang <jasowang@redhat.com>
8
---
27
---
9
hw/net/virtio-net.c | 2 +-
28
include/net/vhost_net.h | 3 +++
10
1 file changed, 1 insertion(+), 1 deletion(-)
29
net/tap.c | 22 +++++++++++++++++-----
30
2 files changed, 20 insertions(+), 5 deletions(-)
11
31
12
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
32
diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h
13
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/net/virtio-net.c
34
--- a/include/net/vhost_net.h
15
+++ b/hw/net/virtio-net.c
35
+++ b/include/net/vhost_net.h
16
@@ -XXX,XX +XXX,XX @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
36
@@ -XXX,XX +XXX,XX @@
17
*/
37
#include "net/net.h"
18
if (n->net_conf.rx_queue_size < VIRTIO_NET_RX_QUEUE_MIN_SIZE ||
38
#include "hw/virtio/vhost-backend.h"
19
n->net_conf.rx_queue_size > VIRTQUEUE_MAX_SIZE ||
39
20
- (n->net_conf.rx_queue_size & (n->net_conf.rx_queue_size - 1))) {
40
+#define VHOST_NET_INIT_FAILED \
21
+ !is_power_of_2(n->net_conf.rx_queue_size)) {
41
+ "vhost-net requested but could not be initialized"
22
error_setg(errp, "Invalid rx_queue_size (= %" PRIu16 "), "
42
+
23
"must be a power of 2 between %d and %d.",
43
struct vhost_net;
24
n->net_conf.rx_queue_size, VIRTIO_NET_RX_QUEUE_MIN_SIZE,
44
typedef struct vhost_net VHostNetState;
45
46
diff --git a/net/tap.c b/net/tap.c
47
index XXXXXXX..XXXXXXX 100644
48
--- a/net/tap.c
49
+++ b/net/tap.c
50
@@ -XXX,XX +XXX,XX @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
51
if (vhostfdname) {
52
vhostfd = monitor_fd_param(cur_mon, vhostfdname, &err);
53
if (vhostfd == -1) {
54
- error_propagate(errp, err);
55
+ if (tap->has_vhostforce && tap->vhostforce) {
56
+ error_propagate(errp, err);
57
+ } else {
58
+ warn_report_err(err);
59
+ }
60
return;
61
}
62
} else {
63
vhostfd = open("/dev/vhost-net", O_RDWR);
64
if (vhostfd < 0) {
65
- error_setg_errno(errp, errno,
66
- "tap: open vhost char device failed");
67
+ if (tap->has_vhostforce && tap->vhostforce) {
68
+ error_setg_errno(errp, errno,
69
+ "tap: open vhost char device failed");
70
+ } else {
71
+ warn_report("tap: open vhost char device failed: %s",
72
+ strerror(errno));
73
+ }
74
return;
75
}
76
fcntl(vhostfd, F_SETFL, O_NONBLOCK);
77
@@ -XXX,XX +XXX,XX @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
78
79
s->vhost_net = vhost_net_init(&options);
80
if (!s->vhost_net) {
81
- error_setg(errp,
82
- "vhost-net requested but could not be initialized");
83
+ if (tap->has_vhostforce && tap->vhostforce) {
84
+ error_setg(errp, VHOST_NET_INIT_FAILED);
85
+ } else {
86
+ warn_report(VHOST_NET_INIT_FAILED);
87
+ }
88
return;
89
}
90
} else if (vhostfdname) {
25
--
91
--
26
2.7.4
92
2.7.4
27
93
28
94
diff view generated by jsdifflib