1
The following changes since commit 5dae13cd71f0755a1395b5a4cde635b8a6ee3f58:
1
The following changes since commit cda4a338c4243fa3bff4498b935340ac7121cc76:
2
2
3
Merge remote-tracking branch 'remotes/rth/tags/pull-or-20170214' into staging (2017-02-14 09:55:48 +0000)
3
tcg/tci: Add TCG_TARGET_DEFAULT_MO (2017-09-07 18:57:34 +0100)
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 4154c7e03fa55b4cf52509a83d50d6c09d743b77:
9
for you to fetch changes up to 861d51e62bb197b43606f888dbefbabebaf0d854:
10
10
11
net: e1000e: fix an infinite loop issue (2017-02-15 11:18:57 +0800)
11
colo-compare: Update the COLO document to add the IOThread configuration (2017-09-08 09:34:40 +0800)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
14
15
----------------------------------------------------------------
15
----------------------------------------------------------------
16
Li Qiang (1):
16
Kamil Rytarowski (1):
17
net: e1000e: fix an infinite loop issue
17
e1000: Rename the SEC symbol to SEQEC
18
18
19
Paolo Bonzini (1):
19
Mao Zhongyi (8):
20
net: e1000e: fix dead code in e1000e_write_packet_to_guest
20
net/rocker: Remove the dead error handling
21
net/rocker: Plug memory leak in pci_rocker_init()
22
net/rocker: Convert to realize()
23
net/rocker: Fix the unusual macro name
24
net/socket: Don't treat odd socket type as SOCK_STREAM
25
net/socket: Convert several helper functions to Error
26
net/net: Convert parse_host_port() to Error
27
net/socket: Improve -net socket error reporting
21
28
22
Prasad J Pandit (1):
29
Matt Parker (1):
23
net: imx: limit buffer descriptor count
30
net: rtl8139: do not use old_mmio accesses
24
31
25
Thomas Huth (1):
32
Wang Yong (3):
26
net: Mark 'vlan' parameter as deprecated
33
qemu-iothread: IOThread supports the GMainContext event loop
34
colo-compare: Use IOThread to Check old packet regularly and Process pactkets of the primary
35
colo-compare: Update the COLO document to add the IOThread configuration
27
36
28
Zhang Chen (1):
37
Zhang Chen (5):
29
colo-compare: sort TCP packet queue by sequence number
38
net/filter-rewriter.c: Fix rewirter checksum bug when use virtio-net
39
MAINTAINERS: Update mail address for COLO Proxy
40
net/colo-compare.c: Optimize unpredictable tcp options comparison
41
net/colo-compare.c: Adjust net queue pop order for performance
42
net/colo-compare.c: Fix comments and scheme
30
43
31
hw/net/e1000e_core.c | 9 +++++++--
44
MAINTAINERS | 2 +-
32
hw/net/imx_fec.c | 10 ++++++----
45
docs/colo-proxy.txt | 3 +-
33
net/colo-compare.c | 19 +++++++++++++++++++
46
hw/net/e1000.c | 4 +-
34
net/net.c | 6 ++++++
47
hw/net/e1000_regs.h | 2 +-
35
4 files changed, 38 insertions(+), 6 deletions(-)
48
hw/net/e1000e_core.c | 2 +-
49
hw/net/e1000x_common.h | 2 +-
50
hw/net/rocker/rocker.c | 94 ++++++----------------
51
hw/net/rocker/rocker_desc.c | 10 ---
52
hw/net/rocker/rocker_fp.c | 4 -
53
hw/net/rocker/rocker_of_dpa.c | 20 -----
54
hw/net/rocker/rocker_world.c | 12 ++-
55
hw/net/rtl8139.c | 53 +-----------
56
include/qemu/sockets.h | 3 +-
57
include/sysemu/iothread.h | 4 +
58
iothread.c | 45 +++++++++++
59
net/colo-compare.c | 183 ++++++++++++++++++++++++------------------
60
net/filter-rewriter.c | 6 +-
61
net/net.c | 22 +++--
62
net/socket.c | 156 +++++++++++++++++++----------------
63
19 files changed, 304 insertions(+), 323 deletions(-)
36
64
37
65
diff view generated by jsdifflib
New patch
1
From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
1
2
3
Because vnet_hdr have a offset to net packet, we must add it when use
4
virtio-net.
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-rewriter.c | 6 ++++--
10
1 file changed, 4 insertions(+), 2 deletions(-)
11
12
diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/net/filter-rewriter.c
15
+++ b/net/filter-rewriter.c
16
@@ -XXX,XX +XXX,XX @@ static int handle_primary_tcp_pkt(NetFilterState *nf,
17
/* handle packets to the secondary from the primary */
18
tcp_pkt->th_ack = htonl(ntohl(tcp_pkt->th_ack) + conn->offset);
19
20
- net_checksum_calculate((uint8_t *)pkt->data, pkt->size);
21
+ net_checksum_calculate((uint8_t *)pkt->data + pkt->vnet_hdr_len,
22
+ pkt->size - pkt->vnet_hdr_len);
23
}
24
}
25
26
@@ -XXX,XX +XXX,XX @@ static int handle_secondary_tcp_pkt(NetFilterState *nf,
27
/* handle packets to the primary from the secondary*/
28
tcp_pkt->th_seq = htonl(ntohl(tcp_pkt->th_seq) - conn->offset);
29
30
- net_checksum_calculate((uint8_t *)pkt->data, pkt->size);
31
+ net_checksum_calculate((uint8_t *)pkt->data + pkt->vnet_hdr_len,
32
+ pkt->size - pkt->vnet_hdr_len);
33
}
34
}
35
36
--
37
2.7.4
38
39
diff view generated by jsdifflib
New patch
1
1
From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
2
3
Memory allocation functions like world_alloc, desc_ring_alloc etc,
4
they are all wrappers around g_malloc, g_new etc. But g_malloc and
5
similar functions doesn't return null. Because they ignore the fact
6
that g_malloc() of 0 bytes returns null. So error checks for these
7
allocation failure are superfluous. Now, remove them entirely.
8
9
Cc: jasowang@redhat.com
10
Cc: jiri@resnulli.us
11
Cc: armbru@redhat.com
12
Cc: f4bug@amsat.org
13
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
14
Reviewed-by: Markus Armbruster <armbru@redhat.com>
15
Signed-off-by: Jason Wang <jasowang@redhat.com>
16
---
17
hw/net/rocker/rocker.c | 47 +------------------------------------------
18
hw/net/rocker/rocker_desc.c | 10 ---------
19
hw/net/rocker/rocker_fp.c | 4 ----
20
hw/net/rocker/rocker_of_dpa.c | 20 ------------------
21
hw/net/rocker/rocker_world.c | 12 +++++------
22
5 files changed, 6 insertions(+), 87 deletions(-)
23
24
diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c
25
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/net/rocker/rocker.c
27
+++ b/hw/net/rocker/rocker.c
28
@@ -XXX,XX +XXX,XX @@ static int tx_consume(Rocker *r, DescInfo *info)
29
}
30
iov[iovcnt].iov_len = frag_len;
31
iov[iovcnt].iov_base = g_malloc(frag_len);
32
- if (!iov[iovcnt].iov_base) {
33
- err = -ROCKER_ENOMEM;
34
- goto err_no_mem;
35
- }
36
37
pci_dma_read(dev, frag_addr, iov[iovcnt].iov_base,
38
iov[iovcnt].iov_len);
39
@@ -XXX,XX +XXX,XX @@ static int tx_consume(Rocker *r, DescInfo *info)
40
err = fp_port_eg(r->fp_port[port], iov, iovcnt);
41
42
err_too_many_frags:
43
-err_no_mem:
44
err_bad_attr:
45
for (i = 0; i < ROCKER_TX_FRAGS_MAX; i++) {
46
g_free(iov[i].iov_base);
47
@@ -XXX,XX +XXX,XX @@ int rx_produce(World *world, uint32_t pport,
48
*/
49
50
data = g_malloc(data_size);
51
- if (!data) {
52
- err = -ROCKER_ENOMEM;
53
- goto out;
54
- }
55
+
56
iov_to_buf(iov, iovcnt, 0, data, data_size);
57
pci_dma_write(dev, frag_addr, data, data_size);
58
g_free(data);
59
@@ -XXX,XX +XXX,XX @@ static void rocker_test_dma_ctrl(Rocker *r, uint32_t val)
60
61
buf = g_malloc(r->test_dma_size);
62
63
- if (!buf) {
64
- DPRINTF("test dma buffer alloc failed");
65
- return;
66
- }
67
-
68
switch (val) {
69
case ROCKER_TEST_DMA_CTRL_CLEAR:
70
memset(buf, 0, r->test_dma_size);
71
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
72
73
r->worlds[ROCKER_WORLD_TYPE_OF_DPA] = of_dpa_world_alloc(r);
74
75
- for (i = 0; i < ROCKER_WORLD_TYPE_MAX; i++) {
76
- if (!r->worlds[i]) {
77
- err = -ENOMEM;
78
- goto err_world_alloc;
79
- }
80
- }
81
-
82
if (!r->world_name) {
83
r->world_name = g_strdup(world_name(r->worlds[ROCKER_WORLD_TYPE_OF_DPA]));
84
}
85
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
86
}
87
88
r->rings = g_new(DescRing *, rocker_pci_ring_count(r));
89
- if (!r->rings) {
90
- goto err_rings_alloc;
91
- }
92
93
/* Rings are ordered like this:
94
* - command ring
95
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
96
* .....
97
*/
98
99
- err = -ENOMEM;
100
for (i = 0; i < rocker_pci_ring_count(r); i++) {
101
DescRing *ring = desc_ring_alloc(r, i);
102
103
- if (!ring) {
104
- goto err_ring_alloc;
105
- }
106
-
107
if (i == ROCKER_RING_CMD) {
108
desc_ring_set_consume(ring, cmd_consume, ROCKER_MSIX_VEC_CMD);
109
} else if (i == ROCKER_RING_EVENT) {
110
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
111
fp_port_alloc(r, r->name, &r->fp_start_macaddr,
112
i, &r->fp_ports_peers[i]);
113
114
- if (!port) {
115
- goto err_port_alloc;
116
- }
117
-
118
r->fp_port[i] = port;
119
fp_port_set_world(port, r->world_dflt);
120
}
121
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
122
123
return 0;
124
125
-err_port_alloc:
126
- for (--i; i >= 0; i--) {
127
- FpPort *port = r->fp_port[i];
128
- fp_port_free(port);
129
- }
130
- i = rocker_pci_ring_count(r);
131
-err_ring_alloc:
132
- for (--i; i >= 0; i--) {
133
- desc_ring_free(r->rings[i]);
134
- }
135
- g_free(r->rings);
136
-err_rings_alloc:
137
err_duplicate:
138
rocker_msix_uninit(r);
139
err_msix_init:
140
object_unparent(OBJECT(&r->msix_bar));
141
object_unparent(OBJECT(&r->mmio));
142
err_world_type_by_name:
143
-err_world_alloc:
144
for (i = 0; i < ROCKER_WORLD_TYPE_MAX; i++) {
145
if (r->worlds[i]) {
146
world_free(r->worlds[i]);
147
diff --git a/hw/net/rocker/rocker_desc.c b/hw/net/rocker/rocker_desc.c
148
index XXXXXXX..XXXXXXX 100644
149
--- a/hw/net/rocker/rocker_desc.c
150
+++ b/hw/net/rocker/rocker_desc.c
151
@@ -XXX,XX +XXX,XX @@ char *desc_get_buf(DescInfo *info, bool read_only)
152
info->buf_size = size;
153
}
154
155
- if (!info->buf) {
156
- return NULL;
157
- }
158
-
159
pci_dma_read(dev, le64_to_cpu(info->desc.buf_addr), info->buf, size);
160
161
return info->buf;
162
@@ -XXX,XX +XXX,XX @@ bool desc_ring_set_size(DescRing *ring, uint32_t size)
163
ring->head = ring->tail = 0;
164
165
ring->info = g_renew(DescInfo, ring->info, size);
166
- if (!ring->info) {
167
- return false;
168
- }
169
170
memset(ring->info, 0, size * sizeof(DescInfo));
171
172
@@ -XXX,XX +XXX,XX @@ DescRing *desc_ring_alloc(Rocker *r, int index)
173
DescRing *ring;
174
175
ring = g_new0(DescRing, 1);
176
- if (!ring) {
177
- return NULL;
178
- }
179
180
ring->r = r;
181
ring->index = index;
182
diff --git a/hw/net/rocker/rocker_fp.c b/hw/net/rocker/rocker_fp.c
183
index XXXXXXX..XXXXXXX 100644
184
--- a/hw/net/rocker/rocker_fp.c
185
+++ b/hw/net/rocker/rocker_fp.c
186
@@ -XXX,XX +XXX,XX @@ FpPort *fp_port_alloc(Rocker *r, char *sw_name,
187
{
188
FpPort *port = g_new0(FpPort, 1);
189
190
- if (!port) {
191
- return NULL;
192
- }
193
-
194
port->r = r;
195
port->index = index;
196
port->pport = index + 1;
197
diff --git a/hw/net/rocker/rocker_of_dpa.c b/hw/net/rocker/rocker_of_dpa.c
198
index XXXXXXX..XXXXXXX 100644
199
--- a/hw/net/rocker/rocker_of_dpa.c
200
+++ b/hw/net/rocker/rocker_of_dpa.c
201
@@ -XXX,XX +XXX,XX @@ static OfDpaFlow *of_dpa_flow_alloc(uint64_t cookie)
202
int64_t now = qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) / 1000;
203
204
flow = g_new0(OfDpaFlow, 1);
205
- if (!flow) {
206
- return NULL;
207
- }
208
209
flow->cookie = cookie;
210
flow->mask.tbl_id = 0xffffffff;
211
@@ -XXX,XX +XXX,XX @@ static OfDpaGroup *of_dpa_group_alloc(uint32_t id)
212
{
213
OfDpaGroup *group = g_new0(OfDpaGroup, 1);
214
215
- if (!group) {
216
- return NULL;
217
- }
218
-
219
group->id = id;
220
221
return group;
222
@@ -XXX,XX +XXX,XX @@ static int of_dpa_cmd_flow_add(OfDpa *of_dpa, uint64_t cookie,
223
}
224
225
flow = of_dpa_flow_alloc(cookie);
226
- if (!flow) {
227
- return -ROCKER_ENOMEM;
228
- }
229
230
err = of_dpa_cmd_flow_add_mod(of_dpa, flow, flow_tlvs);
231
if (err) {
232
@@ -XXX,XX +XXX,XX @@ static int of_dpa_cmd_add_l2_flood(OfDpa *of_dpa, OfDpaGroup *group,
233
rocker_tlv_get_le16(group_tlvs[ROCKER_TLV_OF_DPA_GROUP_COUNT]);
234
235
tlvs = g_new0(RockerTlv *, group->l2_flood.group_count + 1);
236
- if (!tlvs) {
237
- return -ROCKER_ENOMEM;
238
- }
239
240
g_free(group->l2_flood.group_ids);
241
group->l2_flood.group_ids =
242
g_new0(uint32_t, group->l2_flood.group_count);
243
- if (!group->l2_flood.group_ids) {
244
- err = -ROCKER_ENOMEM;
245
- goto err_out;
246
- }
247
248
rocker_tlv_parse_nested(tlvs, group->l2_flood.group_count,
249
group_tlvs[ROCKER_TLV_OF_DPA_GROUP_IDS]);
250
@@ -XXX,XX +XXX,XX @@ static int of_dpa_cmd_group_add(OfDpa *of_dpa, uint32_t group_id,
251
}
252
253
group = of_dpa_group_alloc(group_id);
254
- if (!group) {
255
- return -ROCKER_ENOMEM;
256
- }
257
258
err = of_dpa_cmd_group_do(of_dpa, group_id, group, group_tlvs);
259
if (err) {
260
diff --git a/hw/net/rocker/rocker_world.c b/hw/net/rocker/rocker_world.c
261
index XXXXXXX..XXXXXXX 100644
262
--- a/hw/net/rocker/rocker_world.c
263
+++ b/hw/net/rocker/rocker_world.c
264
@@ -XXX,XX +XXX,XX @@ World *world_alloc(Rocker *r, size_t sizeof_private,
265
{
266
World *w = g_malloc0(sizeof(World) + sizeof_private);
267
268
- if (w) {
269
- w->r = r;
270
- w->type = type;
271
- w->ops = ops;
272
- if (w->ops->init) {
273
- w->ops->init(w);
274
- }
275
+ w->r = r;
276
+ w->type = type;
277
+ w->ops = ops;
278
+ if (w->ops->init) {
279
+ w->ops->init(w);
280
}
281
282
return w;
283
--
284
2.7.4
285
286
diff view generated by jsdifflib
New patch
1
From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
1
2
3
pci_rocker_init() leaks a World when the name more than 9 chars,
4
then return a negative value directly, doesn't make a correct
5
cleanup. So add a new goto label to fix it.
6
7
Cc: jasowang@redhat.com
8
Cc: jiri@resnulli.us
9
Cc: armbru@redhat.com
10
Cc: f4bug@amsat.org
11
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
12
Reviewed-by: Markus Armbruster <armbru@redhat.com>
13
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
Signed-off-by: Jason Wang <jasowang@redhat.com>
15
---
16
hw/net/rocker/rocker.c | 4 +++-
17
1 file changed, 3 insertions(+), 1 deletion(-)
18
19
diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/net/rocker/rocker.c
22
+++ b/hw/net/rocker/rocker.c
23
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
24
fprintf(stderr,
25
"rocker: name too long; please shorten to at most %d chars\n",
26
MAX_ROCKER_NAME_LEN);
27
- return -EINVAL;
28
+ err = -EINVAL;
29
+ goto err_name_too_long;
30
}
31
32
if (memcmp(&r->fp_start_macaddr, &zero, sizeof(zero)) == 0) {
33
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
34
35
return 0;
36
37
+err_name_too_long:
38
err_duplicate:
39
rocker_msix_uninit(r);
40
err_msix_init:
41
--
42
2.7.4
43
44
diff view generated by jsdifflib
New patch
1
From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
1
2
3
The rocker device still implements the old PCIDeviceClass .init()
4
instead of the new .realize(). All devices need to be converted to
5
.realize().
6
7
.init() reports errors with fprintf() and return 0 on success, negative
8
number on failure. Meanwhile, when -device rocker fails, it first report
9
a specific error, then a generic one, like this:
10
11
$ x86_64-softmmu/qemu-system-x86_64 -device rocker,name=qemu-rocker
12
rocker: name too long; please shorten to at most 9 chars
13
qemu-system-x86_64: -device rocker,name=qemu-rocker: Device initialization failed
14
15
Now, convert it to .realize() that passes errors to its callers via its
16
errp argument. Also avoid the superfluous second error message. After
17
the patch, effect like this:
18
19
$ x86_64-softmmu/qemu-system-x86_64 -device rocker,name=qemu-rocker
20
qemu-system-x86_64: -device rocker,name=qemu-rocker: name too long; please shorten to at most 9 chars
21
22
Cc: jasowang@redhat.com
23
Cc: jiri@resnulli.us
24
Cc: armbru@redhat.com
25
Cc: f4bug@amsat.org
26
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
27
Reviewed-by: Markus Armbruster <armbru@redhat.com>
28
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
29
Signed-off-by: Jason Wang <jasowang@redhat.com>
30
---
31
hw/net/rocker/rocker.c | 27 +++++++++++----------------
32
1 file changed, 11 insertions(+), 16 deletions(-)
33
34
diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c
35
index XXXXXXX..XXXXXXX 100644
36
--- a/hw/net/rocker/rocker.c
37
+++ b/hw/net/rocker/rocker.c
38
@@ -XXX,XX +XXX,XX @@ rollback:
39
return err;
40
}
41
42
-static int rocker_msix_init(Rocker *r)
43
+static int rocker_msix_init(Rocker *r, Error **errp)
44
{
45
PCIDevice *dev = PCI_DEVICE(r);
46
int err;
47
- Error *local_err = NULL;
48
49
err = msix_init(dev, ROCKER_MSIX_VEC_COUNT(r->fp_ports),
50
&r->msix_bar,
51
ROCKER_PCI_MSIX_BAR_IDX, ROCKER_PCI_MSIX_TABLE_OFFSET,
52
&r->msix_bar,
53
ROCKER_PCI_MSIX_BAR_IDX, ROCKER_PCI_MSIX_PBA_OFFSET,
54
- 0, &local_err);
55
+ 0, errp);
56
if (err) {
57
- error_report_err(local_err);
58
return err;
59
}
60
61
@@ -XXX,XX +XXX,XX @@ static World *rocker_world_type_by_name(Rocker *r, const char *name)
62
return NULL;
63
}
64
65
-static int pci_rocker_init(PCIDevice *dev)
66
+static void pci_rocker_realize(PCIDevice *dev, Error **errp)
67
{
68
Rocker *r = to_rocker(dev);
69
const MACAddr zero = { .a = { 0, 0, 0, 0, 0, 0 } };
70
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
71
72
r->world_dflt = rocker_world_type_by_name(r, r->world_name);
73
if (!r->world_dflt) {
74
- fprintf(stderr,
75
- "rocker: requested world \"%s\" does not exist\n",
76
+ error_setg(errp,
77
+ "invalid argument requested world %s does not exist",
78
r->world_name);
79
- err = -EINVAL;
80
goto err_world_type_by_name;
81
}
82
83
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
84
85
/* MSI-X init */
86
87
- err = rocker_msix_init(r);
88
+ err = rocker_msix_init(r, errp);
89
if (err) {
90
goto err_msix_init;
91
}
92
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
93
}
94
95
if (rocker_find(r->name)) {
96
- err = -EEXIST;
97
+ error_setg(errp, "%s already exists", r->name);
98
goto err_duplicate;
99
}
100
101
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
102
#define ROCKER_IFNAMSIZ 16
103
#define MAX_ROCKER_NAME_LEN (ROCKER_IFNAMSIZ - 1 - 3 - 3)
104
if (strlen(r->name) > MAX_ROCKER_NAME_LEN) {
105
- fprintf(stderr,
106
- "rocker: name too long; please shorten to at most %d chars\n",
107
+ error_setg(errp,
108
+ "name too long; please shorten to at most %d chars",
109
MAX_ROCKER_NAME_LEN);
110
- err = -EINVAL;
111
goto err_name_too_long;
112
}
113
114
@@ -XXX,XX +XXX,XX @@ static int pci_rocker_init(PCIDevice *dev)
115
116
QLIST_INSERT_HEAD(&rockers, r, next);
117
118
- return 0;
119
+ return;
120
121
err_name_too_long:
122
err_duplicate:
123
@@ -XXX,XX +XXX,XX @@ err_world_type_by_name:
124
world_free(r->worlds[i]);
125
}
126
}
127
- return err;
128
}
129
130
static void pci_rocker_uninit(PCIDevice *dev)
131
@@ -XXX,XX +XXX,XX @@ static void rocker_class_init(ObjectClass *klass, void *data)
132
DeviceClass *dc = DEVICE_CLASS(klass);
133
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
134
135
- k->init = pci_rocker_init;
136
+ k->realize = pci_rocker_realize;
137
k->exit = pci_rocker_uninit;
138
k->vendor_id = PCI_VENDOR_ID_REDHAT;
139
k->device_id = PCI_DEVICE_ID_REDHAT_ROCKER;
140
--
141
2.7.4
142
143
diff view generated by jsdifflib
New patch
1
From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
1
2
3
Cc: jasowang@redhat.com
4
Cc: jiri@resnulli.us
5
Cc: armbru@redhat.com
6
Cc: f4bug@amsat.org
7
Suggested-by: Markus Armbruster <armbru@redhat.com>
8
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
9
Reviewed-by: Markus Armbruster <armbru@redhat.com>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
12
---
13
hw/net/rocker/rocker.c | 18 +++++++++---------
14
1 file changed, 9 insertions(+), 9 deletions(-)
15
16
diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/net/rocker/rocker.c
19
+++ b/hw/net/rocker/rocker.c
20
@@ -XXX,XX +XXX,XX @@ struct rocker {
21
QLIST_ENTRY(rocker) next;
22
};
23
24
-#define ROCKER "rocker"
25
+#define TYPE_ROCKER "rocker"
26
27
-#define to_rocker(obj) \
28
- OBJECT_CHECK(Rocker, (obj), ROCKER)
29
+#define ROCKER(obj) \
30
+ OBJECT_CHECK(Rocker, (obj), TYPE_ROCKER)
31
32
static QLIST_HEAD(, rocker) rockers;
33
34
@@ -XXX,XX +XXX,XX @@ static World *rocker_world_type_by_name(Rocker *r, const char *name)
35
36
static void pci_rocker_realize(PCIDevice *dev, Error **errp)
37
{
38
- Rocker *r = to_rocker(dev);
39
+ Rocker *r = ROCKER(dev);
40
const MACAddr zero = { .a = { 0, 0, 0, 0, 0, 0 } };
41
const MACAddr dflt = { .a = { 0x52, 0x54, 0x00, 0x12, 0x35, 0x01 } };
42
static int sw_index;
43
@@ -XXX,XX +XXX,XX @@ static void pci_rocker_realize(PCIDevice *dev, Error **errp)
44
/* validate switch properties */
45
46
if (!r->name) {
47
- r->name = g_strdup(ROCKER);
48
+ r->name = g_strdup(TYPE_ROCKER);
49
}
50
51
if (rocker_find(r->name)) {
52
@@ -XXX,XX +XXX,XX @@ err_world_type_by_name:
53
54
static void pci_rocker_uninit(PCIDevice *dev)
55
{
56
- Rocker *r = to_rocker(dev);
57
+ Rocker *r = ROCKER(dev);
58
int i;
59
60
QLIST_REMOVE(r, next);
61
@@ -XXX,XX +XXX,XX @@ static void pci_rocker_uninit(PCIDevice *dev)
62
63
static void rocker_reset(DeviceState *dev)
64
{
65
- Rocker *r = to_rocker(dev);
66
+ Rocker *r = ROCKER(dev);
67
int i;
68
69
for (i = 0; i < ROCKER_WORLD_TYPE_MAX; i++) {
70
@@ -XXX,XX +XXX,XX @@ static Property rocker_properties[] = {
71
};
72
73
static const VMStateDescription rocker_vmsd = {
74
- .name = ROCKER,
75
+ .name = TYPE_ROCKER,
76
.unmigratable = 1,
77
};
78
79
@@ -XXX,XX +XXX,XX @@ static void rocker_class_init(ObjectClass *klass, void *data)
80
}
81
82
static const TypeInfo rocker_info = {
83
- .name = ROCKER,
84
+ .name = TYPE_ROCKER,
85
.parent = TYPE_PCI_DEVICE,
86
.instance_size = sizeof(Rocker),
87
.class_init = rocker_class_init,
88
--
89
2.7.4
90
91
diff view generated by jsdifflib
New patch
1
From: Matt Parker <mtparkr@gmail.com>
1
2
3
Both io and memory use the same mmio functions in the rtl8139 device.
4
This patch removes the separate MemoryRegionOps and old_mmio accessors
5
for memory, and replaces it with an alias to the io memory region.
6
7
Signed-off-by: Matt Parker <mtparkr@gmail.com>
8
Signed-off-by: Jason Wang <jasowang@redhat.com>
9
---
10
hw/net/rtl8139.c | 53 +++--------------------------------------------------
11
1 file changed, 3 insertions(+), 50 deletions(-)
12
13
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/net/rtl8139.c
16
+++ b/hw/net/rtl8139.c
17
@@ -XXX,XX +XXX,XX @@ static uint32_t rtl8139_io_readl(void *opaque, uint8_t addr)
18
19
/* */
20
21
-static void rtl8139_mmio_writeb(void *opaque, hwaddr addr, uint32_t val)
22
-{
23
- rtl8139_io_writeb(opaque, addr & 0xFF, val);
24
-}
25
-
26
-static void rtl8139_mmio_writew(void *opaque, hwaddr addr, uint32_t val)
27
-{
28
- rtl8139_io_writew(opaque, addr & 0xFF, val);
29
-}
30
-
31
-static void rtl8139_mmio_writel(void *opaque, hwaddr addr, uint32_t val)
32
-{
33
- rtl8139_io_writel(opaque, addr & 0xFF, val);
34
-}
35
-
36
-static uint32_t rtl8139_mmio_readb(void *opaque, hwaddr addr)
37
-{
38
- return rtl8139_io_readb(opaque, addr & 0xFF);
39
-}
40
-
41
-static uint32_t rtl8139_mmio_readw(void *opaque, hwaddr addr)
42
-{
43
- uint32_t val = rtl8139_io_readw(opaque, addr & 0xFF);
44
- return val;
45
-}
46
-
47
-static uint32_t rtl8139_mmio_readl(void *opaque, hwaddr addr)
48
-{
49
- uint32_t val = rtl8139_io_readl(opaque, addr & 0xFF);
50
- return val;
51
-}
52
-
53
static int rtl8139_post_load(void *opaque, int version_id)
54
{
55
RTL8139State* s = opaque;
56
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps rtl8139_io_ops = {
57
.endianness = DEVICE_LITTLE_ENDIAN,
58
};
59
60
-static const MemoryRegionOps rtl8139_mmio_ops = {
61
- .old_mmio = {
62
- .read = {
63
- rtl8139_mmio_readb,
64
- rtl8139_mmio_readw,
65
- rtl8139_mmio_readl,
66
- },
67
- .write = {
68
- rtl8139_mmio_writeb,
69
- rtl8139_mmio_writew,
70
- rtl8139_mmio_writel,
71
- },
72
- },
73
- .endianness = DEVICE_LITTLE_ENDIAN,
74
-};
75
-
76
static void rtl8139_timer(void *opaque)
77
{
78
RTL8139State *s = opaque;
79
@@ -XXX,XX +XXX,XX @@ static void pci_rtl8139_realize(PCIDevice *dev, Error **errp)
80
81
memory_region_init_io(&s->bar_io, OBJECT(s), &rtl8139_io_ops, s,
82
"rtl8139", 0x100);
83
- memory_region_init_io(&s->bar_mem, OBJECT(s), &rtl8139_mmio_ops, s,
84
- "rtl8139", 0x100);
85
+ memory_region_init_alias(&s->bar_mem, OBJECT(s), "rtl8139-mem", &s->bar_io,
86
+ 0, 0x100);
87
+
88
pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->bar_io);
89
pci_register_bar(dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->bar_mem);
90
91
--
92
2.7.4
93
94
diff view generated by jsdifflib
New patch
1
From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
1
2
3
My Fujitsu mail account will be disabled soon, update the mail info
4
to my private mail.
5
6
Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
7
Signed-off-by: Jason Wang <jasowang@redhat.com>
8
---
9
MAINTAINERS | 2 +-
10
1 file changed, 1 insertion(+), 1 deletion(-)
11
12
diff --git a/MAINTAINERS b/MAINTAINERS
13
index XXXXXXX..XXXXXXX 100644
14
--- a/MAINTAINERS
15
+++ b/MAINTAINERS
16
@@ -XXX,XX +XXX,XX @@ F: include/migration/failover.h
17
F: docs/COLO-FT.txt
18
19
COLO Proxy
20
-M: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
21
+M: Zhang Chen <zhangckid@gmail.com>
22
M: Li Zhijian <lizhijian@cn.fujitsu.com>
23
S: Supported
24
F: docs/colo-proxy.txt
25
--
26
2.7.4
27
28
diff view generated by jsdifflib
New patch
1
From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
1
2
3
In net_socket_fd_init(), the 'default' case is odd: it warns,
4
then continues as if the socket type was SOCK_STREAM. The
5
comment explains "this could be a eg. a pty", but that makes
6
no sense. If @fd really was a pty, getsockopt() would fail
7
with ENOTSOCK. If @fd was a socket, but neither SOCK_DGRAM nor
8
SOCK_STREAM. It should not be treated as if it was SOCK_STREAM.
9
10
Turn this case into an Error. If there is a genuine reason to
11
support something like SOCK_RAW, it should be explicitly
12
handled.
13
14
Cc: jasowang@redhat.com
15
Cc: armbru@redhat.com
16
Cc: berrange@redhat.com
17
Cc: armbru@redhat.com
18
Cc: eblake@redhat.com
19
Suggested-by: Markus Armbruster <armbru@redhat.com>
20
Suggested-by: Daniel P. Berrange <berrange@redhat.com>
21
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
22
Reviewed-by: Markus Armbruster <armbru@redhat.com>
23
Signed-off-by: Jason Wang <jasowang@redhat.com>
24
---
25
net/socket.c | 6 +++---
26
1 file changed, 3 insertions(+), 3 deletions(-)
27
28
diff --git a/net/socket.c b/net/socket.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/net/socket.c
31
+++ b/net/socket.c
32
@@ -XXX,XX +XXX,XX @@ static NetSocketState *net_socket_fd_init(NetClientState *peer,
33
case SOCK_STREAM:
34
return net_socket_fd_init_stream(peer, model, name, fd, is_connected);
35
default:
36
- /* who knows ... this could be a eg. a pty, do warn and continue as stream */
37
- fprintf(stderr, "qemu: warning: socket type=%d for fd=%d is not SOCK_DGRAM or SOCK_STREAM\n", so_type, fd);
38
- return net_socket_fd_init_stream(peer, model, name, fd, is_connected);
39
+ error_report("socket type=%d for fd=%d must be either"
40
+ " SOCK_DGRAM or SOCK_STREAM", so_type, fd);
41
+ closesocket(fd);
42
}
43
return NULL;
44
}
45
--
46
2.7.4
47
48
diff view generated by jsdifflib
New patch
1
1
From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
2
3
Currently, net_socket_mcast_create(), net_socket_fd_init_dgram() and
4
net_socket_fd_init() use the function such as fprintf(), perror() to
5
report an error message.
6
7
Now, convert these functions to Error.
8
9
Cc: jasowang@redhat.com
10
Cc: armbru@redhat.com
11
Cc: berrange@redhat.com
12
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
13
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
14
Reviewed-by: Markus Armbruster <armbru@redhat.com>
15
Signed-off-by: Jason Wang <jasowang@redhat.com>
16
---
17
net/socket.c | 82 ++++++++++++++++++++++++++++++++++++------------------------
18
1 file changed, 50 insertions(+), 32 deletions(-)
19
20
diff --git a/net/socket.c b/net/socket.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/net/socket.c
23
+++ b/net/socket.c
24
@@ -XXX,XX +XXX,XX @@ static void net_socket_send_dgram(void *opaque)
25
}
26
}
27
28
-static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr *localaddr)
29
+static int net_socket_mcast_create(struct sockaddr_in *mcastaddr,
30
+ struct in_addr *localaddr,
31
+ Error **errp)
32
{
33
struct ip_mreq imr;
34
int fd;
35
@@ -XXX,XX +XXX,XX @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr
36
#endif
37
38
if (!IN_MULTICAST(ntohl(mcastaddr->sin_addr.s_addr))) {
39
- fprintf(stderr, "qemu: error: specified mcastaddr \"%s\" (0x%08x) "
40
- "does not contain a multicast address\n",
41
- inet_ntoa(mcastaddr->sin_addr),
42
- (int)ntohl(mcastaddr->sin_addr.s_addr));
43
+ error_setg(errp, "specified mcastaddr %s (0x%08x) "
44
+ "does not contain a multicast address",
45
+ inet_ntoa(mcastaddr->sin_addr),
46
+ (int)ntohl(mcastaddr->sin_addr.s_addr));
47
return -1;
48
-
49
}
50
+
51
fd = qemu_socket(PF_INET, SOCK_DGRAM, 0);
52
if (fd < 0) {
53
- perror("socket(PF_INET, SOCK_DGRAM)");
54
+ error_setg_errno(errp, errno, "can't create datagram socket");
55
return -1;
56
}
57
58
@@ -XXX,XX +XXX,XX @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr
59
val = 1;
60
ret = qemu_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
61
if (ret < 0) {
62
- perror("setsockopt(SOL_SOCKET, SO_REUSEADDR)");
63
+ error_setg_errno(errp, errno,
64
+ "can't set socket option SO_REUSEADDR");
65
goto fail;
66
}
67
68
ret = bind(fd, (struct sockaddr *)mcastaddr, sizeof(*mcastaddr));
69
if (ret < 0) {
70
- perror("bind");
71
+ error_setg_errno(errp, errno, "can't bind ip=%s to socket",
72
+ inet_ntoa(mcastaddr->sin_addr));
73
goto fail;
74
}
75
76
@@ -XXX,XX +XXX,XX @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr
77
ret = qemu_setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
78
&imr, sizeof(struct ip_mreq));
79
if (ret < 0) {
80
- perror("setsockopt(IP_ADD_MEMBERSHIP)");
81
+ error_setg_errno(errp, errno,
82
+ "can't add socket to multicast group %s",
83
+ inet_ntoa(imr.imr_multiaddr));
84
goto fail;
85
}
86
87
@@ -XXX,XX +XXX,XX @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr
88
ret = qemu_setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP,
89
&loop, sizeof(loop));
90
if (ret < 0) {
91
- perror("setsockopt(SOL_IP, IP_MULTICAST_LOOP)");
92
+ error_setg_errno(errp, errno,
93
+ "can't force multicast message to loopback");
94
goto fail;
95
}
96
97
@@ -XXX,XX +XXX,XX @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr
98
ret = qemu_setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
99
localaddr, sizeof(*localaddr));
100
if (ret < 0) {
101
- perror("setsockopt(IP_MULTICAST_IF)");
102
+ error_setg_errno(errp, errno,
103
+ "can't set the default network send interface");
104
goto fail;
105
}
106
}
107
@@ -XXX,XX +XXX,XX @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer,
108
const char *model,
109
const char *name,
110
int fd, int is_connected,
111
- const char *mcast)
112
+ const char *mcast,
113
+ Error **errp)
114
{
115
struct sockaddr_in saddr;
116
int newfd;
117
@@ -XXX,XX +XXX,XX @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer,
118
119
if (is_connected && mcast != NULL) {
120
if (parse_host_port(&saddr, mcast) < 0) {
121
- fprintf(stderr,
122
- "qemu: error: init_dgram: fd=%d failed parse_host_port()\n",
123
- fd);
124
+ error_setg(errp, "fd=%d failed parse_host_port()", fd);
125
goto err;
126
}
127
/* must be bound */
128
if (saddr.sin_addr.s_addr == 0) {
129
- fprintf(stderr, "qemu: error: init_dgram: fd=%d unbound, "
130
- "cannot setup multicast dst addr\n", fd);
131
+ error_setg(errp, "can't setup multicast destination address");
132
goto err;
133
}
134
/* clone dgram socket */
135
- newfd = net_socket_mcast_create(&saddr, NULL);
136
+ newfd = net_socket_mcast_create(&saddr, NULL, errp);
137
if (newfd < 0) {
138
- /* error already reported by net_socket_mcast_create() */
139
goto err;
140
}
141
/* clone newfd to fd, close newfd */
142
@@ -XXX,XX +XXX,XX @@ static NetSocketState *net_socket_fd_init_stream(NetClientState *peer,
143
144
static NetSocketState *net_socket_fd_init(NetClientState *peer,
145
const char *model, const char *name,
146
- int fd, int is_connected, const char *mc)
147
+ int fd, int is_connected,
148
+ const char *mc, Error **errp)
149
{
150
int so_type = -1, optlen=sizeof(so_type);
151
152
if(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&so_type,
153
(socklen_t *)&optlen)< 0) {
154
- fprintf(stderr, "qemu: error: getsockopt(SO_TYPE) for fd=%d failed\n",
155
- fd);
156
+ error_setg(errp, "can't get socket option SO_TYPE");
157
closesocket(fd);
158
return NULL;
159
}
160
switch(so_type) {
161
case SOCK_DGRAM:
162
- return net_socket_fd_init_dgram(peer, model, name, fd, is_connected, mc);
163
+ return net_socket_fd_init_dgram(peer, model, name, fd, is_connected,
164
+ mc, errp);
165
case SOCK_STREAM:
166
return net_socket_fd_init_stream(peer, model, name, fd, is_connected);
167
default:
168
@@ -XXX,XX +XXX,XX @@ static int net_socket_connect_init(NetClientState *peer,
169
NetSocketState *s;
170
int fd, connected, ret;
171
struct sockaddr_in saddr;
172
+ Error *err = NULL;
173
174
if (parse_host_port(&saddr, host_str) < 0)
175
return -1;
176
@@ -XXX,XX +XXX,XX @@ static int net_socket_connect_init(NetClientState *peer,
177
break;
178
}
179
}
180
- s = net_socket_fd_init(peer, model, name, fd, connected, NULL);
181
- if (!s)
182
+ s = net_socket_fd_init(peer, model, name, fd, connected, NULL, &err);
183
+ if (!s) {
184
+ error_report_err(err);
185
return -1;
186
+ }
187
+
188
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
189
"socket: connect to %s:%d",
190
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
191
@@ -XXX,XX +XXX,XX @@ static int net_socket_mcast_init(NetClientState *peer,
192
int fd;
193
struct sockaddr_in saddr;
194
struct in_addr localaddr, *param_localaddr;
195
+ Error *err = NULL;
196
197
if (parse_host_port(&saddr, host_str) < 0)
198
return -1;
199
@@ -XXX,XX +XXX,XX @@ static int net_socket_mcast_init(NetClientState *peer,
200
param_localaddr = NULL;
201
}
202
203
- fd = net_socket_mcast_create(&saddr, param_localaddr);
204
- if (fd < 0)
205
+ fd = net_socket_mcast_create(&saddr, param_localaddr, &err);
206
+ if (fd < 0) {
207
+ error_report_err(err);
208
return -1;
209
+ }
210
211
- s = net_socket_fd_init(peer, model, name, fd, 0, NULL);
212
- if (!s)
213
+ s = net_socket_fd_init(peer, model, name, fd, 0, NULL, &err);
214
+ if (!s) {
215
+ error_report_err(err);
216
return -1;
217
+ }
218
219
s->dgram_dst = saddr;
220
221
@@ -XXX,XX +XXX,XX @@ static int net_socket_udp_init(NetClientState *peer,
222
NetSocketState *s;
223
int fd, ret;
224
struct sockaddr_in laddr, raddr;
225
+ Error *err = NULL;
226
227
if (parse_host_port(&laddr, lhost) < 0) {
228
return -1;
229
@@ -XXX,XX +XXX,XX @@ static int net_socket_udp_init(NetClientState *peer,
230
}
231
qemu_set_nonblock(fd);
232
233
- s = net_socket_fd_init(peer, model, name, fd, 0, NULL);
234
+ s = net_socket_fd_init(peer, model, name, fd, 0, NULL, &err);
235
if (!s) {
236
+ error_report_err(err);
237
return -1;
238
}
239
240
@@ -XXX,XX +XXX,XX @@ int net_init_socket(const Netdev *netdev, const char *name,
241
return -1;
242
}
243
qemu_set_nonblock(fd);
244
- if (!net_socket_fd_init(peer, "socket", name, fd, 1, sock->mcast)) {
245
+ if (!net_socket_fd_init(peer, "socket", name, fd, 1, sock->mcast,
246
+ errp)) {
247
return -1;
248
}
249
return 0;
250
--
251
2.7.4
252
253
diff view generated by jsdifflib
1
From: Thomas Huth <thuth@redhat.com>
1
From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
2
2
3
The 'vlan' parameter is a continuous source of confusion for the users,
3
Cc: berrange@redhat.com
4
many people mix it up with the more common term VLAN (the link layer
4
Cc: kraxel@redhat.com
5
packet encapsulation), and even if they realize that the QEMU 'vlan' is
5
Cc: pbonzini@redhat.com
6
rather some kind of network hub emulation, there is still a high risk
6
Cc: jasowang@redhat.com
7
that they configure their QEMU networking in a wrong way with this
7
Cc: armbru@redhat.com
8
parameter (e.g. by hooking NICs together, so they get a 'loopback'
8
Cc: eblake@redhat.com
9
between one and the other NIC).
9
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
10
Thus at one point in time, we should finally get rid of the 'vlan'
10
Reviewed-by: Markus Armbruster <armbru@redhat.com>
11
feature in QEMU. Let's do a first step in this direction by declaring
12
the 'vlan' parameter as deprecated and informing the users to use the
13
'netdev' parameter instead.
14
15
Signed-off-by: Thomas Huth <thuth@redhat.com>
16
Signed-off-by: Jason Wang <jasowang@redhat.com>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
17
---
12
---
18
net/net.c | 6 ++++++
13
include/qemu/sockets.h | 3 ++-
19
1 file changed, 6 insertions(+)
14
net/net.c | 22 +++++++++++++++++-----
15
net/socket.c | 22 +++++++++++++++-------
16
3 files changed, 34 insertions(+), 13 deletions(-)
20
17
18
diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h
19
index XXXXXXX..XXXXXXX 100644
20
--- a/include/qemu/sockets.h
21
+++ b/include/qemu/sockets.h
22
@@ -XXX,XX +XXX,XX @@ void socket_listen_cleanup(int fd, Error **errp);
23
int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp);
24
25
/* Old, ipv4 only bits. Don't use for new code. */
26
-int parse_host_port(struct sockaddr_in *saddr, const char *str);
27
+int parse_host_port(struct sockaddr_in *saddr, const char *str,
28
+ Error **errp);
29
int socket_init(void);
30
31
/**
21
diff --git a/net/net.c b/net/net.c
32
diff --git a/net/net.c b/net/net.c
22
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
23
--- a/net/net.c
34
--- a/net/net.c
24
+++ b/net/net.c
35
+++ b/net/net.c
25
@@ -XXX,XX +XXX,XX @@ static int net_client_init1(const void *object, bool is_netdev, Error **errp)
36
@@ -XXX,XX +XXX,XX @@ static int get_str_sep(char *buf, int buf_size, const char **pp, int sep)
26
const Netdev *netdev;
37
return 0;
27
const char *name;
38
}
28
NetClientState *peer = NULL;
39
29
+ static bool vlan_warned;
40
-int parse_host_port(struct sockaddr_in *saddr, const char *str)
30
41
+int parse_host_port(struct sockaddr_in *saddr, const char *str,
31
if (is_netdev) {
42
+ Error **errp)
32
netdev = object;
43
{
33
@@ -XXX,XX +XXX,XX @@ static int net_client_init1(const void *object, bool is_netdev, Error **errp)
44
char buf[512];
34
!opts->u.nic.data->has_netdev) {
45
struct hostent *he;
35
peer = net_hub_add_port(net->has_vlan ? net->vlan : 0, NULL);
46
@@ -XXX,XX +XXX,XX @@ int parse_host_port(struct sockaddr_in *saddr, const char *str)
47
int port;
48
49
p = str;
50
- if (get_str_sep(buf, sizeof(buf), &p, ':') < 0)
51
+ if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) {
52
+ error_setg(errp, "host address '%s' doesn't contain ':' "
53
+ "separating host from port", str);
54
return -1;
55
+ }
56
saddr->sin_family = AF_INET;
57
if (buf[0] == '\0') {
58
saddr->sin_addr.s_addr = 0;
59
} else {
60
if (qemu_isdigit(buf[0])) {
61
- if (!inet_aton(buf, &saddr->sin_addr))
62
+ if (!inet_aton(buf, &saddr->sin_addr)) {
63
+ error_setg(errp, "host address '%s' is not a valid "
64
+ "IPv4 address", buf);
65
return -1;
66
+ }
67
} else {
68
- if ((he = gethostbyname(buf)) == NULL)
69
+ he = gethostbyname(buf);
70
+ if (he == NULL) {
71
+ error_setg(errp, "can't resolve host address '%s'", buf);
72
return - 1;
73
+ }
74
saddr->sin_addr = *(struct in_addr *)he->h_addr;
36
}
75
}
37
+
38
+ if (net->has_vlan && !vlan_warned) {
39
+ error_report("'vlan' is deprecated. Please use 'netdev' instead.");
40
+ vlan_warned = true;
41
+ }
42
}
76
}
43
77
port = strtol(p, (char **)&r, 0);
44
if (net_client_init_fun[netdev->type](netdev, name, peer, errp) < 0) {
78
- if (r == p)
79
+ if (r == p) {
80
+ error_setg(errp, "port number '%s' is invalid", p);
81
return -1;
82
+ }
83
saddr->sin_port = htons(port);
84
return 0;
85
}
86
diff --git a/net/socket.c b/net/socket.c
87
index XXXXXXX..XXXXXXX 100644
88
--- a/net/socket.c
89
+++ b/net/socket.c
90
@@ -XXX,XX +XXX,XX @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer,
91
*/
92
93
if (is_connected && mcast != NULL) {
94
- if (parse_host_port(&saddr, mcast) < 0) {
95
- error_setg(errp, "fd=%d failed parse_host_port()", fd);
96
+ if (parse_host_port(&saddr, mcast, errp) < 0) {
97
goto err;
98
}
99
/* must be bound */
100
@@ -XXX,XX +XXX,XX @@ static int net_socket_listen_init(NetClientState *peer,
101
NetSocketState *s;
102
struct sockaddr_in saddr;
103
int fd, ret;
104
+ Error *err = NULL;
105
106
- if (parse_host_port(&saddr, host_str) < 0)
107
+ if (parse_host_port(&saddr, host_str, &err) < 0) {
108
+ error_report_err(err);
109
return -1;
110
+ }
111
112
fd = qemu_socket(PF_INET, SOCK_STREAM, 0);
113
if (fd < 0) {
114
@@ -XXX,XX +XXX,XX @@ static int net_socket_connect_init(NetClientState *peer,
115
struct sockaddr_in saddr;
116
Error *err = NULL;
117
118
- if (parse_host_port(&saddr, host_str) < 0)
119
+ if (parse_host_port(&saddr, host_str, &err) < 0) {
120
+ error_report_err(err);
121
return -1;
122
+ }
123
124
fd = qemu_socket(PF_INET, SOCK_STREAM, 0);
125
if (fd < 0) {
126
@@ -XXX,XX +XXX,XX @@ static int net_socket_mcast_init(NetClientState *peer,
127
struct in_addr localaddr, *param_localaddr;
128
Error *err = NULL;
129
130
- if (parse_host_port(&saddr, host_str) < 0)
131
+ if (parse_host_port(&saddr, host_str, &err) < 0) {
132
+ error_report_err(err);
133
return -1;
134
+ }
135
136
if (localaddr_str != NULL) {
137
if (inet_aton(localaddr_str, &localaddr) == 0)
138
@@ -XXX,XX +XXX,XX @@ static int net_socket_udp_init(NetClientState *peer,
139
struct sockaddr_in laddr, raddr;
140
Error *err = NULL;
141
142
- if (parse_host_port(&laddr, lhost) < 0) {
143
+ if (parse_host_port(&laddr, lhost, &err) < 0) {
144
+ error_report_err(err);
145
return -1;
146
}
147
148
- if (parse_host_port(&raddr, rhost) < 0) {
149
+ if (parse_host_port(&raddr, rhost, &err) < 0) {
150
+ error_report_err(err);
151
return -1;
152
}
153
45
--
154
--
46
2.7.4
155
2.7.4
47
156
48
157
diff view generated by jsdifflib
New patch
1
1
From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
2
3
When -net socket fails, it first reports a specific error, then
4
a generic one, like this:
5
6
$ ./x86_64-softmmu/qemu-system-x86_64 -net socket,mcast=230.0.0.1:1234,listen
7
qemu-system-x86_64: -net socket,mcast=230.0.0.1:1234,listen: exactly one of listen=, connect=, mcast= or udp= is required
8
qemu-system-x86_64: -net socket,mcast=230.0.0.1:1234,listen: Device 'socket' could not be initialized
9
10
Convert net_socket_*_init() to Error to get rid of the superfluous second
11
error message. After the patch, the effect like this:
12
13
$ ./x86_64-softmmu/qemu-system-x86_64 -net socket,mcast=230.0.0.1:1234,listen
14
qemu-system-x86_64: -net socket,mcast=230.0.0.1:1234,listen: exactly one of listen=, connect=, mcast= or udp= is requireda
15
16
This also fixes a few silent failures to report an error.
17
18
Cc: jasowang@redhat.com
19
Cc: armbru@redhat.com
20
Cc: berrange@redhat.com
21
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
22
Reviewed-by: Markus Armbruster <armbru@redhat.com>
23
Signed-off-by: Jason Wang <jasowang@redhat.com>
24
---
25
net/socket.c | 92 +++++++++++++++++++++++++++++-------------------------------
26
1 file changed, 44 insertions(+), 48 deletions(-)
27
28
diff --git a/net/socket.c b/net/socket.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/net/socket.c
31
+++ b/net/socket.c
32
@@ -XXX,XX +XXX,XX @@ static void net_socket_accept(void *opaque)
33
static int net_socket_listen_init(NetClientState *peer,
34
const char *model,
35
const char *name,
36
- const char *host_str)
37
+ const char *host_str,
38
+ Error **errp)
39
{
40
NetClientState *nc;
41
NetSocketState *s;
42
struct sockaddr_in saddr;
43
int fd, ret;
44
- Error *err = NULL;
45
46
- if (parse_host_port(&saddr, host_str, &err) < 0) {
47
- error_report_err(err);
48
+ if (parse_host_port(&saddr, host_str, errp) < 0) {
49
return -1;
50
}
51
52
fd = qemu_socket(PF_INET, SOCK_STREAM, 0);
53
if (fd < 0) {
54
- perror("socket");
55
+ error_setg_errno(errp, errno, "can't create stream socket");
56
return -1;
57
}
58
qemu_set_nonblock(fd);
59
@@ -XXX,XX +XXX,XX @@ static int net_socket_listen_init(NetClientState *peer,
60
61
ret = bind(fd, (struct sockaddr *)&saddr, sizeof(saddr));
62
if (ret < 0) {
63
- perror("bind");
64
+ error_setg_errno(errp, errno, "can't bind ip=%s to socket",
65
+ inet_ntoa(saddr.sin_addr));
66
closesocket(fd);
67
return -1;
68
}
69
ret = listen(fd, 0);
70
if (ret < 0) {
71
- perror("listen");
72
+ error_setg_errno(errp, errno, "can't listen on socket");
73
closesocket(fd);
74
return -1;
75
}
76
@@ -XXX,XX +XXX,XX @@ static int net_socket_listen_init(NetClientState *peer,
77
static int net_socket_connect_init(NetClientState *peer,
78
const char *model,
79
const char *name,
80
- const char *host_str)
81
+ const char *host_str,
82
+ Error **errp)
83
{
84
NetSocketState *s;
85
int fd, connected, ret;
86
struct sockaddr_in saddr;
87
- Error *err = NULL;
88
89
- if (parse_host_port(&saddr, host_str, &err) < 0) {
90
- error_report_err(err);
91
+ if (parse_host_port(&saddr, host_str, errp) < 0) {
92
return -1;
93
}
94
95
fd = qemu_socket(PF_INET, SOCK_STREAM, 0);
96
if (fd < 0) {
97
- perror("socket");
98
+ error_setg_errno(errp, errno, "can't create stream socket");
99
return -1;
100
}
101
qemu_set_nonblock(fd);
102
@@ -XXX,XX +XXX,XX @@ static int net_socket_connect_init(NetClientState *peer,
103
errno == EINVAL) {
104
break;
105
} else {
106
- perror("connect");
107
+ error_setg_errno(errp, errno, "can't connect socket");
108
closesocket(fd);
109
return -1;
110
}
111
@@ -XXX,XX +XXX,XX @@ static int net_socket_connect_init(NetClientState *peer,
112
break;
113
}
114
}
115
- s = net_socket_fd_init(peer, model, name, fd, connected, NULL, &err);
116
+ s = net_socket_fd_init(peer, model, name, fd, connected, NULL, errp);
117
if (!s) {
118
- error_report_err(err);
119
return -1;
120
}
121
122
@@ -XXX,XX +XXX,XX @@ static int net_socket_mcast_init(NetClientState *peer,
123
const char *model,
124
const char *name,
125
const char *host_str,
126
- const char *localaddr_str)
127
+ const char *localaddr_str,
128
+ Error **errp)
129
{
130
NetSocketState *s;
131
int fd;
132
struct sockaddr_in saddr;
133
struct in_addr localaddr, *param_localaddr;
134
- Error *err = NULL;
135
136
- if (parse_host_port(&saddr, host_str, &err) < 0) {
137
- error_report_err(err);
138
+ if (parse_host_port(&saddr, host_str, errp) < 0) {
139
return -1;
140
}
141
142
if (localaddr_str != NULL) {
143
- if (inet_aton(localaddr_str, &localaddr) == 0)
144
+ if (inet_aton(localaddr_str, &localaddr) == 0) {
145
+ error_setg(errp, "localaddr '%s' is not a valid IPv4 address",
146
+ localaddr_str);
147
return -1;
148
+ }
149
param_localaddr = &localaddr;
150
} else {
151
param_localaddr = NULL;
152
}
153
154
- fd = net_socket_mcast_create(&saddr, param_localaddr, &err);
155
+ fd = net_socket_mcast_create(&saddr, param_localaddr, errp);
156
if (fd < 0) {
157
- error_report_err(err);
158
return -1;
159
}
160
161
- s = net_socket_fd_init(peer, model, name, fd, 0, NULL, &err);
162
+ s = net_socket_fd_init(peer, model, name, fd, 0, NULL, errp);
163
if (!s) {
164
- error_report_err(err);
165
return -1;
166
}
167
168
@@ -XXX,XX +XXX,XX @@ static int net_socket_udp_init(NetClientState *peer,
169
const char *model,
170
const char *name,
171
const char *rhost,
172
- const char *lhost)
173
+ const char *lhost,
174
+ Error **errp)
175
{
176
NetSocketState *s;
177
int fd, ret;
178
struct sockaddr_in laddr, raddr;
179
- Error *err = NULL;
180
181
- if (parse_host_port(&laddr, lhost, &err) < 0) {
182
- error_report_err(err);
183
+ if (parse_host_port(&laddr, lhost, errp) < 0) {
184
return -1;
185
}
186
187
- if (parse_host_port(&raddr, rhost, &err) < 0) {
188
- error_report_err(err);
189
+ if (parse_host_port(&raddr, rhost, errp) < 0) {
190
return -1;
191
}
192
193
fd = qemu_socket(PF_INET, SOCK_DGRAM, 0);
194
if (fd < 0) {
195
- perror("socket(PF_INET, SOCK_DGRAM)");
196
+ error_setg_errno(errp, errno, "can't create datagram socket");
197
return -1;
198
}
199
200
ret = socket_set_fast_reuse(fd);
201
if (ret < 0) {
202
+ error_setg_errno(errp, errno,
203
+ "can't set socket option SO_REUSEADDR");
204
closesocket(fd);
205
return -1;
206
}
207
ret = bind(fd, (struct sockaddr *)&laddr, sizeof(laddr));
208
if (ret < 0) {
209
- perror("bind");
210
+ error_setg_errno(errp, errno, "can't bind ip=%s to socket",
211
+ inet_ntoa(laddr.sin_addr));
212
closesocket(fd);
213
return -1;
214
}
215
qemu_set_nonblock(fd);
216
217
- s = net_socket_fd_init(peer, model, name, fd, 0, NULL, &err);
218
+ s = net_socket_fd_init(peer, model, name, fd, 0, NULL, errp);
219
if (!s) {
220
- error_report_err(err);
221
return -1;
222
}
223
224
@@ -XXX,XX +XXX,XX @@ static int net_socket_udp_init(NetClientState *peer,
225
int net_init_socket(const Netdev *netdev, const char *name,
226
NetClientState *peer, Error **errp)
227
{
228
- /* FIXME error_setg(errp, ...) on failure */
229
- Error *err = NULL;
230
const NetdevSocketOptions *sock;
231
232
assert(netdev->type == NET_CLIENT_DRIVER_SOCKET);
233
@@ -XXX,XX +XXX,XX @@ int net_init_socket(const Netdev *netdev, const char *name,
234
235
if (sock->has_listen + sock->has_connect + sock->has_mcast +
236
sock->has_udp > 1) {
237
- error_report("exactly one of listen=, connect=, mcast= or udp="
238
- " is required");
239
+ error_setg(errp, "exactly one of listen=, connect=, mcast= or udp="
240
+ " is required");
241
return -1;
242
}
243
244
if (sock->has_localaddr && !sock->has_mcast && !sock->has_udp) {
245
- error_report("localaddr= is only valid with mcast= or udp=");
246
+ error_setg(errp, "localaddr= is only valid with mcast= or udp=");
247
return -1;
248
}
249
250
if (sock->has_fd) {
251
int fd;
252
253
- fd = monitor_fd_param(cur_mon, sock->fd, &err);
254
+ fd = monitor_fd_param(cur_mon, sock->fd, errp);
255
if (fd == -1) {
256
- error_report_err(err);
257
return -1;
258
}
259
qemu_set_nonblock(fd);
260
@@ -XXX,XX +XXX,XX @@ int net_init_socket(const Netdev *netdev, const char *name,
261
}
262
263
if (sock->has_listen) {
264
- if (net_socket_listen_init(peer, "socket", name, sock->listen) == -1) {
265
+ if (net_socket_listen_init(peer, "socket", name, sock->listen, errp)
266
+ < 0) {
267
return -1;
268
}
269
return 0;
270
}
271
272
if (sock->has_connect) {
273
- if (net_socket_connect_init(peer, "socket", name, sock->connect) ==
274
- -1) {
275
+ if (net_socket_connect_init(peer, "socket", name, sock->connect, errp)
276
+ < 0) {
277
return -1;
278
}
279
return 0;
280
@@ -XXX,XX +XXX,XX @@ int net_init_socket(const Netdev *netdev, const char *name,
281
/* if sock->localaddr is missing, it has been initialized to "all bits
282
* zero" */
283
if (net_socket_mcast_init(peer, "socket", name, sock->mcast,
284
- sock->localaddr) == -1) {
285
+ sock->localaddr, errp) < 0) {
286
return -1;
287
}
288
return 0;
289
@@ -XXX,XX +XXX,XX @@ int net_init_socket(const Netdev *netdev, const char *name,
290
291
assert(sock->has_udp);
292
if (!sock->has_localaddr) {
293
- error_report("localaddr= is mandatory with udp=");
294
+ error_setg(errp, "localaddr= is mandatory with udp=");
295
return -1;
296
}
297
- if (net_socket_udp_init(peer, "socket", name, sock->udp, sock->localaddr) ==
298
- -1) {
299
+ if (net_socket_udp_init(peer, "socket", name, sock->udp, sock->localaddr,
300
+ errp) < 0) {
301
return -1;
302
}
303
return 0;
304
--
305
2.7.4
306
307
diff view generated by jsdifflib
1
From: Paolo Bonzini <pbonzini@redhat.com>
1
From: Kamil Rytarowski <n54@gmx.com>
2
2
3
Because is_first is declared inside a loop, it is always true. The store
3
SunOS defines SEC in <sys/time.h> as 1 (commonly used time symbols).
4
is dead, and so is the "else" branch of "if (is_first)". is_last is
5
okay though.
6
4
7
Reported by Coverity.
5
This fixes build on SmartOS (Joyent).
8
6
9
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7
Patch cherry-picked from pkgsrc by jperkin (Joyent).
8
9
Signed-off-by: Kamil Rytarowski <n54@gmx.com>
10
Reviewed-by: Dmitry Fleytman <dmitry@daynix.com>
10
Reviewed-by: Dmitry Fleytman <dmitry@daynix.com>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
12
---
12
---
13
hw/net/e1000e_core.c | 2 +-
13
hw/net/e1000.c | 4 ++--
14
1 file changed, 1 insertion(+), 1 deletion(-)
14
hw/net/e1000_regs.h | 2 +-
15
hw/net/e1000e_core.c | 2 +-
16
hw/net/e1000x_common.h | 2 +-
17
4 files changed, 5 insertions(+), 5 deletions(-)
15
18
19
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/net/e1000.c
22
+++ b/hw/net/e1000.c
23
@@ -XXX,XX +XXX,XX @@ static uint32_t (*macreg_readops[])(E1000State *, int) = {
24
getreg(TADV), getreg(ITR), getreg(FCRUC), getreg(IPAV),
25
getreg(WUC), getreg(WUS), getreg(SCC), getreg(ECOL),
26
getreg(MCC), getreg(LATECOL), getreg(COLC), getreg(DC),
27
- getreg(TNCRS), getreg(SEC), getreg(CEXTERR), getreg(RLEC),
28
+ getreg(TNCRS), getreg(SEQEC), getreg(CEXTERR), getreg(RLEC),
29
getreg(XONRXC), getreg(XONTXC), getreg(XOFFRXC), getreg(XOFFTXC),
30
getreg(RFC), getreg(RJC), getreg(RNBC), getreg(TSCTFC),
31
getreg(MGTPRC), getreg(MGTPDC), getreg(MGTPTC), getreg(GORCL),
32
@@ -XXX,XX +XXX,XX @@ static const uint8_t mac_reg_access[0x8000] = {
33
[FFLT] = markflag(MAC), [FFMT] = markflag(MAC),
34
[SCC] = markflag(MAC), [FCRUC] = markflag(MAC),
35
[LATECOL] = markflag(MAC), [COLC] = markflag(MAC),
36
- [SEC] = markflag(MAC), [CEXTERR] = markflag(MAC),
37
+ [SEQEC] = markflag(MAC), [CEXTERR] = markflag(MAC),
38
[XONTXC] = markflag(MAC), [XOFFRXC] = markflag(MAC),
39
[RJC] = markflag(MAC), [RNBC] = markflag(MAC),
40
[MGTPDC] = markflag(MAC), [MGTPTC] = markflag(MAC),
41
diff --git a/hw/net/e1000_regs.h b/hw/net/e1000_regs.h
42
index XXXXXXX..XXXXXXX 100644
43
--- a/hw/net/e1000_regs.h
44
+++ b/hw/net/e1000_regs.h
45
@@ -XXX,XX +XXX,XX @@
46
#define E1000_COLC 0x04028 /* Collision Count - R/clr */
47
#define E1000_DC 0x04030 /* Defer Count - R/clr */
48
#define E1000_TNCRS 0x04034 /* TX-No CRS - R/clr */
49
-#define E1000_SEC 0x04038 /* Sequence Error Count - R/clr */
50
+#define E1000_SEQEC 0x04038 /* Sequence Error Count - R/clr */
51
#define E1000_CEXTERR 0x0403C /* Carrier Extension Error Count - R/clr */
52
#define E1000_RLEC 0x04040 /* Receive Length Error Count - R/clr */
53
#define E1000_XONRXC 0x04048 /* XON RX Count - R/clr */
16
diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
54
diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
17
index XXXXXXX..XXXXXXX 100644
55
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/net/e1000e_core.c
56
--- a/hw/net/e1000e_core.c
19
+++ b/hw/net/e1000e_core.c
57
+++ b/hw/net/e1000e_core.c
20
@@ -XXX,XX +XXX,XX @@ e1000e_write_packet_to_guest(E1000ECore *core, struct NetRxPkt *pkt,
58
@@ -XXX,XX +XXX,XX @@ static uint32_t (*e1000e_macreg_readops[])(E1000ECore *, int) = {
21
const E1000E_RingInfo *rxi;
59
e1000e_getreg(RDLEN0),
22
size_t ps_hdr_len = 0;
60
e1000e_getreg(RDH1),
23
bool do_ps = e1000e_do_ps(core, pkt, &ps_hdr_len);
61
e1000e_getreg(LATECOL),
24
+ bool is_first = true;
62
- e1000e_getreg(SEC),
25
63
+ e1000e_getreg(SEQEC),
26
rxi = rxr->i;
64
e1000e_getreg(XONTXC),
27
65
e1000e_getreg(WUS),
28
@@ -XXX,XX +XXX,XX @@ e1000e_write_packet_to_guest(E1000ECore *core, struct NetRxPkt *pkt,
66
e1000e_getreg(GORCL),
29
hwaddr ba[MAX_PS_BUFFERS];
67
diff --git a/hw/net/e1000x_common.h b/hw/net/e1000x_common.h
30
e1000e_ba_state bastate = { { 0 } };
68
index XXXXXXX..XXXXXXX 100644
31
bool is_last = false;
69
--- a/hw/net/e1000x_common.h
32
- bool is_first = true;
70
+++ b/hw/net/e1000x_common.h
33
71
@@ -XXX,XX +XXX,XX @@ enum {
34
desc_size = total_size - desc_offset;
72
defreg(VFTA), defreg(VET), defreg(RDTR), defreg(RADV),
35
73
defreg(TADV), defreg(ITR), defreg(SCC), defreg(ECOL),
74
defreg(MCC), defreg(LATECOL), defreg(COLC), defreg(DC),
75
- defreg(TNCRS), defreg(SEC), defreg(CEXTERR), defreg(RLEC),
76
+ defreg(TNCRS), defreg(SEQEC), defreg(CEXTERR), defreg(RLEC),
77
defreg(XONRXC), defreg(XONTXC), defreg(XOFFRXC), defreg(XOFFTXC),
78
defreg(FCRUC), defreg(AIT), defreg(TDFH), defreg(TDFT),
79
defreg(TDFHS), defreg(TDFTS), defreg(TDFPC), defreg(WUC),
36
--
80
--
37
2.7.4
81
2.7.4
38
82
39
83
diff view generated by jsdifflib
New patch
1
From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
1
2
3
When network is busy, some tcp options(like sack) will unpredictable
4
occur in primary side or secondary side. it will make packet size
5
not same, but the two packet's payload is identical. colo just
6
care about packet payload, so we skip the option field.
7
8
Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
9
Signed-off-by: Jason Wang <jasowang@redhat.com>
10
---
11
net/colo-compare.c | 39 +++++++++++++++++++++++++++------------
12
1 file changed, 27 insertions(+), 12 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
* return: 0 means packet same
20
* > 0 || < 0 means packet different
21
*/
22
-static int colo_packet_compare_common(Packet *ppkt, Packet *spkt, int offset)
23
+static int colo_packet_compare_common(Packet *ppkt,
24
+ Packet *spkt,
25
+ int poffset,
26
+ int soffset)
27
{
28
if (trace_event_get_state_backends(TRACE_COLO_COMPARE_MISCOMPARE)) {
29
char pri_ip_src[20], pri_ip_dst[20], sec_ip_src[20], sec_ip_dst[20];
30
@@ -XXX,XX +XXX,XX @@ static int colo_packet_compare_common(Packet *ppkt, Packet *spkt, int offset)
31
sec_ip_src, sec_ip_dst);
32
}
33
34
- offset = ppkt->vnet_hdr_len + offset;
35
+ poffset = ppkt->vnet_hdr_len + poffset;
36
+ soffset = ppkt->vnet_hdr_len + soffset;
37
38
- if (ppkt->size == spkt->size) {
39
- return memcmp(ppkt->data + offset,
40
- spkt->data + offset,
41
- spkt->size - offset);
42
+ if (ppkt->size - poffset == spkt->size - soffset) {
43
+ return memcmp(ppkt->data + poffset,
44
+ spkt->data + soffset,
45
+ spkt->size - soffset);
46
} else {
47
trace_colo_compare_main("Net packet size are not the same");
48
return -1;
49
@@ -XXX,XX +XXX,XX @@ static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt)
50
* so we just need skip this field.
51
*/
52
if (ptcp->th_off > 5) {
53
- ptrdiff_t tcp_offset;
54
+ ptrdiff_t ptcp_offset, stcp_offset;
55
56
- tcp_offset = ppkt->transport_header - (uint8_t *)ppkt->data
57
- + (ptcp->th_off * 4) - ppkt->vnet_hdr_len;
58
- res = colo_packet_compare_common(ppkt, spkt, tcp_offset);
59
+ ptcp_offset = ppkt->transport_header - (uint8_t *)ppkt->data
60
+ + (ptcp->th_off * 4) - ppkt->vnet_hdr_len;
61
+ stcp_offset = spkt->transport_header - (uint8_t *)spkt->data
62
+ + (stcp->th_off * 4) - spkt->vnet_hdr_len;
63
+
64
+ /*
65
+ * When network is busy, some tcp options(like sack) will unpredictable
66
+ * occur in primary side or secondary side. it will make packet size
67
+ * not same, but the two packet's payload is identical. colo just
68
+ * care about packet payload, so we skip the option field.
69
+ */
70
+ res = colo_packet_compare_common(ppkt, spkt, ptcp_offset, stcp_offset);
71
} else if (ptcp->th_sum == stcp->th_sum) {
72
- res = colo_packet_compare_common(ppkt, spkt, ETH_HLEN);
73
+ res = colo_packet_compare_common(ppkt, spkt, ETH_HLEN, ETH_HLEN);
74
} else {
75
res = -1;
76
}
77
@@ -XXX,XX +XXX,XX @@ static int colo_packet_compare_udp(Packet *spkt, Packet *ppkt)
78
* the ip payload here.
79
*/
80
ret = colo_packet_compare_common(ppkt, spkt,
81
+ network_header_length + ETH_HLEN,
82
network_header_length + ETH_HLEN);
83
84
if (ret) {
85
@@ -XXX,XX +XXX,XX @@ static int colo_packet_compare_icmp(Packet *spkt, Packet *ppkt)
86
* the ip payload here.
87
*/
88
if (colo_packet_compare_common(ppkt, spkt,
89
+ network_header_length + ETH_HLEN,
90
network_header_length + ETH_HLEN)) {
91
trace_colo_compare_icmp_miscompare("primary pkt size",
92
ppkt->size);
93
@@ -XXX,XX +XXX,XX @@ static int colo_packet_compare_other(Packet *spkt, Packet *ppkt)
94
sec_ip_src, sec_ip_dst);
95
}
96
97
- return colo_packet_compare_common(ppkt, spkt, 0);
98
+ return colo_packet_compare_common(ppkt, spkt, 0, 0);
99
}
100
101
static int colo_old_packet_check_one(Packet *pkt, int64_t *check_time)
102
--
103
2.7.4
104
105
diff view generated by jsdifflib
1
From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
1
From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
2
2
3
Improve efficiency of TCP packet comparison.
3
The packet_enqueue() use g_queue_push_tail() to
4
enqueue net packet, so it is more efficent way use
5
g_queue_pop_head() to get packet for compare.
6
That will improve the success rate of comparison.
7
In my test the performance of ftp put 1000M file
8
will increase 10%
4
9
5
Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
10
Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
6
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.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 | 19 +++++++++++++++++++
13
net/colo-compare.c | 4 ++--
10
1 file changed, 19 insertions(+)
14
1 file changed, 2 insertions(+), 2 deletions(-)
11
15
12
diff --git a/net/colo-compare.c b/net/colo-compare.c
16
diff --git a/net/colo-compare.c b/net/colo-compare.c
13
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
14
--- a/net/colo-compare.c
18
--- a/net/colo-compare.c
15
+++ b/net/colo-compare.c
19
+++ b/net/colo-compare.c
16
@@ -XXX,XX +XXX,XX @@ static int compare_chr_send(CharBackend *out,
20
@@ -XXX,XX +XXX,XX @@ static void colo_compare_connection(void *opaque, void *user_data)
17
const uint8_t *buf,
21
18
uint32_t size);
22
while (!g_queue_is_empty(&conn->primary_list) &&
19
23
!g_queue_is_empty(&conn->secondary_list)) {
20
+static gint seq_sorter(Packet *a, Packet *b, gpointer data)
24
- pkt = g_queue_pop_tail(&conn->primary_list);
21
+{
25
+ pkt = g_queue_pop_head(&conn->primary_list);
22
+ struct tcphdr *atcp, *btcp;
26
switch (conn->ip_proto) {
23
+
27
case IPPROTO_TCP:
24
+ atcp = (struct tcphdr *)(a->transport_header);
28
result = g_queue_find_custom(&conn->secondary_list,
25
+ btcp = (struct tcphdr *)(b->transport_header);
29
@@ -XXX,XX +XXX,XX @@ static void colo_compare_connection(void *opaque, void *user_data)
26
+ return ntohl(atcp->th_seq) - ntohl(btcp->th_seq);
30
* until next comparison.
27
+}
31
*/
28
+
32
trace_colo_compare_main("packet different");
29
/*
33
- g_queue_push_tail(&conn->primary_list, pkt);
30
* Return 0 on success, if return -1 means the pkt
34
+ g_queue_push_head(&conn->primary_list, pkt);
31
* is unsupported(arp and ipv6) and will be sent later
35
/* TODO: colo_notify_checkpoint();*/
32
@@ -XXX,XX +XXX,XX @@ static int packet_enqueue(CompareState *s, int mode)
36
break;
33
if (g_queue_get_length(&conn->primary_list) <=
37
}
34
MAX_QUEUE_SIZE) {
35
g_queue_push_tail(&conn->primary_list, pkt);
36
+ if (conn->ip_proto == IPPROTO_TCP) {
37
+ g_queue_sort(&conn->primary_list,
38
+ (GCompareDataFunc)seq_sorter,
39
+ NULL);
40
+ }
41
} else {
42
error_report("colo compare primary queue size too big,"
43
"drop packet");
44
@@ -XXX,XX +XXX,XX @@ static int packet_enqueue(CompareState *s, int mode)
45
if (g_queue_get_length(&conn->secondary_list) <=
46
MAX_QUEUE_SIZE) {
47
g_queue_push_tail(&conn->secondary_list, pkt);
48
+ if (conn->ip_proto == IPPROTO_TCP) {
49
+ g_queue_sort(&conn->secondary_list,
50
+ (GCompareDataFunc)seq_sorter,
51
+ NULL);
52
+ }
53
} else {
54
error_report("colo compare secondary queue size too big,"
55
"drop packet");
56
--
38
--
57
2.7.4
39
2.7.4
58
40
59
41
diff view generated by jsdifflib
1
From: Prasad J Pandit <pjp@fedoraproject.org>
1
From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
2
2
3
i.MX Fast Ethernet Controller uses buffer descriptors to manage
3
Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
4
data flow to/fro receive & transmit queues. While transmitting
5
packets, it could continue to read buffer descriptors if a buffer
6
descriptor has length of zero and has crafted values in bd.flags.
7
Set an upper limit to number of buffer descriptors.
8
9
Reported-by: Li Qiang <liqiang6-s@360.cn>
10
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
4
Signed-off-by: Jason Wang <jasowang@redhat.com>
12
---
5
---
13
hw/net/imx_fec.c | 10 ++++++----
6
net/colo-compare.c | 59 ++++++++++++++++++++++++++++--------------------------
14
1 file changed, 6 insertions(+), 4 deletions(-)
7
1 file changed, 31 insertions(+), 28 deletions(-)
15
8
16
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
9
diff --git a/net/colo-compare.c b/net/colo-compare.c
17
index XXXXXXX..XXXXXXX 100644
10
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/net/imx_fec.c
11
--- a/net/colo-compare.c
19
+++ b/hw/net/imx_fec.c
12
+++ b/net/colo-compare.c
20
@@ -XXX,XX +XXX,XX @@
13
@@ -XXX,XX +XXX,XX @@
21
} \
14
#define REGULAR_PACKET_CHECK_MS 3000
22
} while (0)
15
23
16
/*
24
+#define IMX_MAX_DESC 1024
17
- + CompareState ++
25
+
18
- | |
26
static const char *imx_default_reg_name(IMXFECState *s, uint32_t index)
19
- +---------------+ +---------------+ +---------------+
27
{
20
- |conn list +--->conn +--------->conn |
28
static char tmp[20];
21
- +---------------+ +---------------+ +---------------+
29
@@ -XXX,XX +XXX,XX @@ static void imx_eth_update(IMXFECState *s)
22
- | | | | | |
30
23
- +---------------+ +---v----+ +---v----+ +---v----+ +---v----+
31
static void imx_fec_do_tx(IMXFECState *s)
24
- |primary | |secondary |primary | |secondary
32
{
25
- |packet | |packet + |packet | |packet +
33
- int frame_size = 0;
26
- +--------+ +--------+ +--------+ +--------+
34
+ int frame_size = 0, descnt = 0;
27
- | | | |
35
uint8_t frame[ENET_MAX_FRAME_SIZE];
28
- +---v----+ +---v----+ +---v----+ +---v----+
36
uint8_t *ptr = frame;
29
- |primary | |secondary |primary | |secondary
37
uint32_t addr = s->tx_descriptor;
30
- |packet | |packet + |packet | |packet +
38
31
- +--------+ +--------+ +--------+ +--------+
39
- while (1) {
32
- | | | |
40
+ while (descnt++ < IMX_MAX_DESC) {
33
- +---v----+ +---v----+ +---v----+ +---v----+
41
IMXFECBufDesc bd;
34
- |primary | |secondary |primary | |secondary
42
int len;
35
- |packet | |packet + |packet | |packet +
43
36
- +--------+ +--------+ +--------+ +--------+
44
@@ -XXX,XX +XXX,XX @@ static void imx_fec_do_tx(IMXFECState *s)
37
-*/
45
38
+ * + CompareState ++
46
static void imx_enet_do_tx(IMXFECState *s)
39
+ * | |
47
{
40
+ * +---------------+ +---------------+ +---------------+
48
- int frame_size = 0;
41
+ * | conn list + - > conn + ------- > conn + -- > ......
49
+ int frame_size = 0, descnt = 0;
42
+ * +---------------+ +---------------+ +---------------+
50
uint8_t frame[ENET_MAX_FRAME_SIZE];
43
+ * | | | | | |
51
uint8_t *ptr = frame;
44
+ * +---------------+ +---v----+ +---v----+ +---v----+ +---v----+
52
uint32_t addr = s->tx_descriptor;
45
+ * |primary | |secondary |primary | |secondary
53
46
+ * |packet | |packet + |packet | |packet +
54
- while (1) {
47
+ * +--------+ +--------+ +--------+ +--------+
55
+ while (descnt++ < IMX_MAX_DESC) {
48
+ * | | | |
56
IMXENETBufDesc bd;
49
+ * +---v----+ +---v----+ +---v----+ +---v----+
57
int len;
50
+ * |primary | |secondary |primary | |secondary
51
+ * |packet | |packet + |packet | |packet +
52
+ * +--------+ +--------+ +--------+ +--------+
53
+ * | | | |
54
+ * +---v----+ +---v----+ +---v----+ +---v----+
55
+ * |primary | |secondary |primary | |secondary
56
+ * |packet | |packet + |packet | |packet +
57
+ * +--------+ +--------+ +--------+ +--------+
58
+ */
59
typedef struct CompareState {
60
Object parent;
61
62
@@ -XXX,XX +XXX,XX @@ typedef struct CompareState {
63
SocketReadState sec_rs;
64
bool vnet_hdr;
65
66
- /* connection list: the connections belonged to this NIC could be found
67
- * in this list.
68
- * element type: Connection
69
+ /*
70
+ * Record the connection that through the NIC
71
+ * Element type: Connection
72
*/
73
GQueue conn_list;
74
- /* hashtable to save connection */
75
+ /* Record the connection without repetition */
76
GHashTable *connection_track_table;
77
- /* compare thread, a thread for each NIC */
78
+ /* This thread just do packet compare job */
79
QemuThread thread;
80
81
GMainContext *worker_context;
82
@@ -XXX,XX +XXX,XX @@ static int colo_old_packet_check_one_conn(Connection *conn,
83
(GCompareFunc)colo_old_packet_check_one);
84
85
if (result) {
86
- /* do checkpoint will flush old packet */
87
- /* TODO: colo_notify_checkpoint();*/
88
+ /* Do checkpoint will flush old packet */
89
+ /*
90
+ * TODO: Notify colo frame to do checkpoint.
91
+ * colo_compare_inconsistent_notify();
92
+ */
93
return 0;
94
}
58
95
59
--
96
--
60
2.7.4
97
2.7.4
61
98
62
99
diff view generated by jsdifflib
New patch
1
From: Wang Yong <wang.yong155@zte.com.cn>
1
2
3
IOThread uses AioContext event loop and does not run a GMainContext.
4
Therefore,chardev cannot work in IOThread,such as the chardev is
5
used for colo-compare packets reception.
6
7
This patch makes the IOThread run the GMainContext event loop,
8
chardev and IOThread can work together.
9
10
Reviewed-by: Fam Zheng <famz@redhat.com>
11
Signed-off-by: Wang Yong <wang.yong155@zte.com.cn>
12
Signed-off-by: Wang Guang <wang.guang55@zte.com.cn>
13
Signed-off-by: Jason Wang <jasowang@redhat.com>
14
---
15
include/sysemu/iothread.h | 4 ++++
16
iothread.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
17
2 files changed, 49 insertions(+)
18
19
diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h
20
index XXXXXXX..XXXXXXX 100644
21
--- a/include/sysemu/iothread.h
22
+++ b/include/sysemu/iothread.h
23
@@ -XXX,XX +XXX,XX @@ typedef struct {
24
25
QemuThread thread;
26
AioContext *ctx;
27
+ GMainContext *worker_context;
28
+ GMainLoop *main_loop;
29
+ GOnce once;
30
QemuMutex init_done_lock;
31
QemuCond init_done_cond; /* is thread initialization done? */
32
bool stopping;
33
@@ -XXX,XX +XXX,XX @@ typedef struct {
34
char *iothread_get_id(IOThread *iothread);
35
AioContext *iothread_get_aio_context(IOThread *iothread);
36
void iothread_stop_all(void);
37
+GMainContext *iothread_get_g_main_context(IOThread *iothread);
38
39
#endif /* IOTHREAD_H */
40
diff --git a/iothread.c b/iothread.c
41
index XXXXXXX..XXXXXXX 100644
42
--- a/iothread.c
43
+++ b/iothread.c
44
@@ -XXX,XX +XXX,XX @@ static void *iothread_run(void *opaque)
45
46
while (!atomic_read(&iothread->stopping)) {
47
aio_poll(iothread->ctx, true);
48
+
49
+ if (atomic_read(&iothread->worker_context)) {
50
+ GMainLoop *loop;
51
+
52
+ g_main_context_push_thread_default(iothread->worker_context);
53
+ iothread->main_loop =
54
+ g_main_loop_new(iothread->worker_context, TRUE);
55
+ loop = iothread->main_loop;
56
+
57
+ g_main_loop_run(iothread->main_loop);
58
+ iothread->main_loop = NULL;
59
+ g_main_loop_unref(loop);
60
+
61
+ g_main_context_pop_thread_default(iothread->worker_context);
62
+ g_main_context_unref(iothread->worker_context);
63
+ iothread->worker_context = NULL;
64
+ }
65
}
66
67
rcu_unregister_thread();
68
@@ -XXX,XX +XXX,XX @@ static int iothread_stop(Object *object, void *opaque)
69
}
70
iothread->stopping = true;
71
aio_notify(iothread->ctx);
72
+ if (atomic_read(&iothread->main_loop)) {
73
+ g_main_loop_quit(iothread->main_loop);
74
+ }
75
qemu_thread_join(&iothread->thread);
76
return 0;
77
}
78
@@ -XXX,XX +XXX,XX @@ static void iothread_complete(UserCreatable *obj, Error **errp)
79
80
qemu_mutex_init(&iothread->init_done_lock);
81
qemu_cond_init(&iothread->init_done_cond);
82
+ iothread->once = (GOnce) G_ONCE_INIT;
83
84
/* This assumes we are called from a thread with useful CPU affinity for us
85
* to inherit.
86
@@ -XXX,XX +XXX,XX @@ void iothread_stop_all(void)
87
88
object_child_foreach(container, iothread_stop, NULL);
89
}
90
+
91
+static gpointer iothread_g_main_context_init(gpointer opaque)
92
+{
93
+ AioContext *ctx;
94
+ IOThread *iothread = opaque;
95
+ GSource *source;
96
+
97
+ iothread->worker_context = g_main_context_new();
98
+
99
+ ctx = iothread_get_aio_context(iothread);
100
+ source = aio_get_g_source(ctx);
101
+ g_source_attach(source, iothread->worker_context);
102
+ g_source_unref(source);
103
+
104
+ aio_notify(iothread->ctx);
105
+ return NULL;
106
+}
107
+
108
+GMainContext *iothread_get_g_main_context(IOThread *iothread)
109
+{
110
+ g_once(&iothread->once, iothread_g_main_context_init, iothread);
111
+
112
+ return iothread->worker_context;
113
+}
114
--
115
2.7.4
116
117
diff view generated by jsdifflib
1
From: Li Qiang <liq3ea@gmail.com>
1
From: Wang Yong <wang.yong155@zte.com.cn>
2
2
3
This issue is like the issue in e1000 network card addressed in
3
Remove the task which check old packet in the comparing thread,
4
this commit:
4
then use IOthread context timer to handle it.
5
e1000: eliminate infinite loops on out-of-bounds transfer start.
6
5
7
Signed-off-by: Li Qiang <liqiang6-s@360.cn>
6
Process pactkets in the IOThread which arrived over the socket.
8
Reviewed-by: Dmitry Fleytman <dmitry@daynix.com>
7
we use iothread_get_g_main_context to create a new g_main_loop in
8
the IOThread.then the packets from the primary and the secondary
9
are processed in the IOThread.
10
11
Finally remove the colo-compare thread using the IOThread instead.
12
13
Reviewed-by: Zhang Chen<zhangchen.fnst@cn.fujitsu.com>
14
Signed-off-by: Wang Yong <wang.yong155@zte.com.cn>
15
Signed-off-by: Wang Guang <wang.guang55@zte.com.cn>
9
Signed-off-by: Jason Wang <jasowang@redhat.com>
16
Signed-off-by: Jason Wang <jasowang@redhat.com>
10
---
17
---
11
hw/net/e1000e_core.c | 7 ++++++-
18
net/colo-compare.c | 83 +++++++++++++++++++++++++++++-------------------------
12
1 file changed, 6 insertions(+), 1 deletion(-)
19
1 file changed, 45 insertions(+), 38 deletions(-)
13
20
14
diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
21
diff --git a/net/colo-compare.c b/net/colo-compare.c
15
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/net/e1000e_core.c
23
--- a/net/colo-compare.c
17
+++ b/hw/net/e1000e_core.c
24
+++ b/net/colo-compare.c
18
@@ -XXX,XX +XXX,XX @@ typedef struct E1000E_RingInfo_st {
25
@@ -XXX,XX +XXX,XX @@
19
static inline bool
26
#include "qemu/sockets.h"
20
e1000e_ring_empty(E1000ECore *core, const E1000E_RingInfo *r)
27
#include "qapi-visit.h"
28
#include "net/colo.h"
29
+#include "sysemu/iothread.h"
30
31
#define TYPE_COLO_COMPARE "colo-compare"
32
#define COLO_COMPARE(obj) \
33
@@ -XXX,XX +XXX,XX @@ typedef struct CompareState {
34
GQueue conn_list;
35
/* Record the connection without repetition */
36
GHashTable *connection_track_table;
37
- /* This thread just do packet compare job */
38
- QemuThread thread;
39
40
+ IOThread *iothread;
41
GMainContext *worker_context;
42
- GMainLoop *compare_loop;
43
+ QEMUTimer *packet_check_timer;
44
} CompareState;
45
46
typedef struct CompareClass {
47
@@ -XXX,XX +XXX,XX @@ static void compare_sec_chr_in(void *opaque, const uint8_t *buf, int size)
48
* Check old packet regularly so it can watch for any packets
49
* that the secondary hasn't produced equivalents of.
50
*/
51
-static gboolean check_old_packet_regular(void *opaque)
52
+static void check_old_packet_regular(void *opaque)
21
{
53
{
22
- return core->mac[r->dh] == core->mac[r->dt];
54
CompareState *s = opaque;
23
+ return core->mac[r->dh] == core->mac[r->dt] ||
55
24
+ core->mac[r->dt] >= core->mac[r->dlen] / E1000_RING_DESC_LEN;
56
/* if have old packet we will notify checkpoint */
57
colo_old_packet_check(s);
58
+ timer_mod(s->packet_check_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) +
59
+ REGULAR_PACKET_CHECK_MS);
60
+}
61
+
62
+static void colo_compare_timer_init(CompareState *s)
63
+{
64
+ AioContext *ctx = iothread_get_aio_context(s->iothread);
65
66
- return TRUE;
67
+ s->packet_check_timer = aio_timer_new(ctx, QEMU_CLOCK_VIRTUAL,
68
+ SCALE_MS, check_old_packet_regular,
69
+ s);
70
+ timer_mod(s->packet_check_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) +
71
+ REGULAR_PACKET_CHECK_MS);
25
}
72
}
26
73
27
static inline uint64_t
74
-static void *colo_compare_thread(void *opaque)
28
@@ -XXX,XX +XXX,XX @@ e1000e_write_packet_to_guest(E1000ECore *core, struct NetRxPkt *pkt,
75
+static void colo_compare_timer_del(CompareState *s)
29
desc_size = core->rx_desc_buf_size;
76
{
30
}
77
- CompareState *s = opaque;
31
78
- GSource *timeout_source;
32
+ if (e1000e_ring_empty(core, rxi)) {
79
+ if (s->packet_check_timer) {
33
+ return;
80
+ timer_del(s->packet_check_timer);
34
+ }
81
+ timer_free(s->packet_check_timer);
82
+ s->packet_check_timer = NULL;
83
+ }
84
+ }
85
86
- s->worker_context = g_main_context_new();
87
+static void colo_compare_iothread(CompareState *s)
88
+{
89
+ object_ref(OBJECT(s->iothread));
90
+ s->worker_context = iothread_get_g_main_context(s->iothread);
91
92
qemu_chr_fe_set_handlers(&s->chr_pri_in, compare_chr_can_read,
93
compare_pri_chr_in, NULL, NULL,
94
@@ -XXX,XX +XXX,XX @@ static void *colo_compare_thread(void *opaque)
95
compare_sec_chr_in, NULL, NULL,
96
s, s->worker_context, true);
97
98
- s->compare_loop = g_main_loop_new(s->worker_context, FALSE);
99
-
100
- /* To kick any packets that the secondary doesn't match */
101
- timeout_source = g_timeout_source_new(REGULAR_PACKET_CHECK_MS);
102
- g_source_set_callback(timeout_source,
103
- (GSourceFunc)check_old_packet_regular, s, NULL);
104
- g_source_attach(timeout_source, s->worker_context);
105
-
106
- g_main_loop_run(s->compare_loop);
107
-
108
- g_source_unref(timeout_source);
109
- g_main_loop_unref(s->compare_loop);
110
- g_main_context_unref(s->worker_context);
111
- return NULL;
112
+ colo_compare_timer_init(s);
113
}
114
115
static char *compare_get_pri_indev(Object *obj, Error **errp)
116
@@ -XXX,XX +XXX,XX @@ static void colo_compare_complete(UserCreatable *uc, Error **errp)
117
{
118
CompareState *s = COLO_COMPARE(uc);
119
Chardev *chr;
120
- char thread_name[64];
121
- static int compare_id;
122
123
- if (!s->pri_indev || !s->sec_indev || !s->outdev) {
124
+ if (!s->pri_indev || !s->sec_indev || !s->outdev || !s->iothread) {
125
error_setg(errp, "colo compare needs 'primary_in' ,"
126
- "'secondary_in','outdev' property set");
127
+ "'secondary_in','outdev','iothread' property set");
128
return;
129
} else if (!strcmp(s->pri_indev, s->outdev) ||
130
!strcmp(s->sec_indev, s->outdev) ||
131
@@ -XXX,XX +XXX,XX @@ static void colo_compare_complete(UserCreatable *uc, Error **errp)
132
g_free,
133
connection_destroy);
134
135
- sprintf(thread_name, "colo-compare %d", compare_id);
136
- qemu_thread_create(&s->thread, thread_name,
137
- colo_compare_thread, s,
138
- QEMU_THREAD_JOINABLE);
139
- compare_id++;
140
-
141
+ colo_compare_iothread(s);
142
return;
143
}
144
145
@@ -XXX,XX +XXX,XX @@ static void colo_compare_init(Object *obj)
146
object_property_add_str(obj, "outdev",
147
compare_get_outdev, compare_set_outdev,
148
NULL);
149
+ object_property_add_link(obj, "iothread", TYPE_IOTHREAD,
150
+ (Object **)&s->iothread,
151
+ object_property_allow_set_link,
152
+ OBJ_PROP_LINK_UNREF_ON_RELEASE, NULL);
153
154
s->vnet_hdr = false;
155
object_property_add_bool(obj, "vnet_hdr_support", compare_get_vnet_hdr,
156
@@ -XXX,XX +XXX,XX @@ static void colo_compare_finalize(Object *obj)
157
qemu_chr_fe_deinit(&s->chr_pri_in, false);
158
qemu_chr_fe_deinit(&s->chr_sec_in, false);
159
qemu_chr_fe_deinit(&s->chr_out, false);
160
-
161
- g_main_loop_quit(s->compare_loop);
162
- qemu_thread_join(&s->thread);
163
-
164
+ if (s->iothread) {
165
+ colo_compare_timer_del(s);
166
+ }
167
/* Release all unhandled packets after compare thead exited */
168
g_queue_foreach(&s->conn_list, colo_flush_packets, s);
169
170
g_queue_clear(&s->conn_list);
171
172
- g_hash_table_destroy(s->connection_track_table);
173
+ if (s->connection_track_table) {
174
+ g_hash_table_destroy(s->connection_track_table);
175
+ }
35
+
176
+
36
base = e1000e_ring_head_descr(core, rxi);
177
+ if (s->iothread) {
37
178
+ object_unref(OBJECT(s->iothread));
38
pci_dma_read(d, base, &desc, core->rx_desc_len);
179
+ }
180
g_free(s->pri_indev);
181
g_free(s->sec_indev);
182
g_free(s->outdev);
39
--
183
--
40
2.7.4
184
2.7.4
41
185
42
186
diff view generated by jsdifflib
New patch
1
From: Wang Yong <wang.yong155@zte.com.cn>
1
2
3
Update colo-proxy.txt,add IOThread configuration.
4
Later we have to configure IOThread,if not COLO can not work.
5
6
Reviewed-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
7
Signed-off-by: Wang Yong <wang.yong155@zte.com.cn>
8
Signed-off-by: Wang Guang <wang.guang55@zte.com.cn>
9
Signed-off-by: Jason Wang <jasowang@redhat.com>
10
---
11
docs/colo-proxy.txt | 3 ++-
12
1 file changed, 2 insertions(+), 1 deletion(-)
13
14
diff --git a/docs/colo-proxy.txt b/docs/colo-proxy.txt
15
index XXXXXXX..XXXXXXX 100644
16
--- a/docs/colo-proxy.txt
17
+++ b/docs/colo-proxy.txt
18
@@ -XXX,XX +XXX,XX @@ Primary(ip:3.3.3.3):
19
-chardev socket,id=compare0-0,host=3.3.3.3,port=9001
20
-chardev socket,id=compare_out,host=3.3.3.3,port=9005,server,nowait
21
-chardev socket,id=compare_out0,host=3.3.3.3,port=9005
22
+-object iothread,id=iothread1
23
-object filter-mirror,id=m0,netdev=hn0,queue=tx,outdev=mirror0
24
-object filter-redirector,netdev=hn0,id=redire0,queue=rx,indev=compare_out
25
-object filter-redirector,netdev=hn0,id=redire1,queue=rx,outdev=compare0
26
--object colo-compare,id=comp0,primary_in=compare0-0,secondary_in=compare1,outdev=compare_out0
27
+-object colo-compare,id=comp0,primary_in=compare0-0,secondary_in=compare1,outdev=compare_out0,iothread=iothread1
28
29
Secondary(ip:3.3.3.8):
30
-netdev tap,id=hn0,vhost=off,script=/etc/qemu-ifup,down script=/etc/qemu-ifdown
31
--
32
2.7.4
33
34
diff view generated by jsdifflib