1 | The following changes since commit cda4a338c4243fa3bff4498b935340ac7121cc76: | 1 | The following changes since commit 5012e522aca161be5c141596c66e5cc6082538a9: |
---|---|---|---|
2 | 2 | ||
3 | tcg/tci: Add TCG_TARGET_DEFAULT_MO (2017-09-07 18:57:34 +0100) | 3 | Update version for v9.0.0-rc1 release (2024-03-26 19:46:55 +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 861d51e62bb197b43606f888dbefbabebaf0d854: | 9 | for you to fetch changes up to d9b33018a0da51eddceb48c42345cfb351065f3e: |
10 | 10 | ||
11 | colo-compare: Update the COLO document to add the IOThread configuration (2017-09-08 09:34:40 +0800) | 11 | Revert "tap: setting error appropriately when calling net_init_tap_one()" (2024-03-29 14:59:07 +0800) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | -----BEGIN PGP SIGNATURE----- | ||
15 | |||
16 | iQEzBAABCAAdFiEEIV1G9IJGaJ7HfzVi7wSWWzmNYhEFAmYGZ7EACgkQ7wSWWzmN | ||
17 | YhHvxgf/SDEYYMlxU7PA1SfwlIYtUG8K1zQnwLXNY6ySCJuCn1IdVoITaUt3BtE5 | ||
18 | OtrhKI8cW5WwL4qzkElWlL431vyqomGdmJQedF8agwoR2aIo24i/Ue09MHxJxXUB | ||
19 | ONEOv3bizDCYWUjz+PMHRdIbo0AiSNaUDnB8iY59yD6HZqSLVMDx8Ia2KVrzUKwc | ||
20 | nMuqkDsVIc3gwqFNPbTl3yqVt6k1x+vBCGQUg9BiKE3pkUcONhsJpBYYj4hlY9mn | ||
21 | /BPlQBcRUoLHQD7KGSUKVFSODHPYzDg7BsSz2+EpuZucRRI3VEyHlcB5A6LIVhrK | ||
22 | fpqd+80Fb7VE9CAxA2gFj7gh5uPJ1A== | ||
23 | =shO6 | ||
24 | -----END PGP SIGNATURE----- | ||
14 | 25 | ||
15 | ---------------------------------------------------------------- | 26 | ---------------------------------------------------------------- |
16 | Kamil Rytarowski (1): | 27 | Akihiko Odaki (5): |
17 | e1000: Rename the SEC symbol to SEQEC | 28 | virtio-net: Fix vhost virtqueue notifiers for RSS |
29 | ebpf: Fix indirections table setting | ||
30 | hw/net/net_tx_pkt: Fix virtio header without checksum offloading | ||
31 | tap-win32: Remove unnecessary stubs | ||
32 | Revert "tap: setting error appropriately when calling net_init_tap_one()" | ||
18 | 33 | ||
19 | Mao Zhongyi (8): | 34 | ebpf/ebpf_rss.c | 9 +++++++-- |
20 | net/rocker: Remove the dead error handling | 35 | hw/net/net_tx_pkt.c | 1 + |
21 | net/rocker: Plug memory leak in pci_rocker_init() | 36 | hw/net/virtio-net.c | 4 ++-- |
22 | net/rocker: Convert to realize() | 37 | include/net/vhost_net.h | 3 --- |
23 | net/rocker: Fix the unusual macro name | 38 | net/tap-win32.c | 54 ------------------------------------------------- |
24 | net/socket: Don't treat odd socket type as SOCK_STREAM | 39 | net/tap.c | 22 +++++--------------- |
25 | net/socket: Convert several helper functions to Error | 40 | 6 files changed, 15 insertions(+), 78 deletions(-) |
26 | net/net: Convert parse_host_port() to Error | ||
27 | net/socket: Improve -net socket error reporting | ||
28 | |||
29 | Matt Parker (1): | ||
30 | net: rtl8139: do not use old_mmio accesses | ||
31 | |||
32 | Wang Yong (3): | ||
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 | ||
36 | |||
37 | Zhang Chen (5): | ||
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 | ||
43 | |||
44 | MAINTAINERS | 2 +- | ||
45 | docs/colo-proxy.txt | 3 +- | ||
46 | hw/net/e1000.c | 4 +- | ||
47 | hw/net/e1000_regs.h | 2 +- | ||
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(-) | ||
64 | |||
65 | diff view generated by jsdifflib |
1 | From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | 1 | From: Akihiko Odaki <akihiko.odaki@daynix.com> |
---|---|---|---|
2 | 2 | ||
3 | The packet_enqueue() use g_queue_push_tail() to | 3 | virtio_net_guest_notifier_pending() and virtio_net_guest_notifier_mask() |
4 | enqueue net packet, so it is more efficent way use | 4 | checked VIRTIO_NET_F_MQ to know there are multiple queues, but |
5 | g_queue_pop_head() to get packet for compare. | 5 | VIRTIO_NET_F_RSS also enables multiple queues. Refer to n->multiqueue, |
6 | That will improve the success rate of comparison. | 6 | which is set to true either of VIRTIO_NET_F_MQ or VIRTIO_NET_F_RSS is |
7 | In my test the performance of ftp put 1000M file | 7 | enabled. |
8 | will increase 10% | ||
9 | 8 | ||
10 | Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | 9 | Fixes: 68b0a6395f36 ("virtio-net: align ctrl_vq index for non-mq guest for vhost_vdpa") |
10 | Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
11 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 11 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
12 | --- | 12 | --- |
13 | net/colo-compare.c | 4 ++-- | 13 | hw/net/virtio-net.c | 4 ++-- |
14 | 1 file changed, 2 insertions(+), 2 deletions(-) | 14 | 1 file changed, 2 insertions(+), 2 deletions(-) |
15 | 15 | ||
16 | diff --git a/net/colo-compare.c b/net/colo-compare.c | 16 | diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/net/colo-compare.c | 18 | --- a/hw/net/virtio-net.c |
19 | +++ b/net/colo-compare.c | 19 | +++ b/hw/net/virtio-net.c |
20 | @@ -XXX,XX +XXX,XX @@ static void colo_compare_connection(void *opaque, void *user_data) | 20 | @@ -XXX,XX +XXX,XX @@ static bool virtio_net_guest_notifier_pending(VirtIODevice *vdev, int idx) |
21 | 21 | VirtIONet *n = VIRTIO_NET(vdev); | |
22 | while (!g_queue_is_empty(&conn->primary_list) && | 22 | NetClientState *nc; |
23 | !g_queue_is_empty(&conn->secondary_list)) { | 23 | assert(n->vhost_started); |
24 | - pkt = g_queue_pop_tail(&conn->primary_list); | 24 | - if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_MQ) && idx == 2) { |
25 | + pkt = g_queue_pop_head(&conn->primary_list); | 25 | + if (!n->multiqueue && idx == 2) { |
26 | switch (conn->ip_proto) { | 26 | /* Must guard against invalid features and bogus queue index |
27 | case IPPROTO_TCP: | 27 | * from being set by malicious guest, or penetrated through |
28 | result = g_queue_find_custom(&conn->secondary_list, | 28 | * buggy migration stream. |
29 | @@ -XXX,XX +XXX,XX @@ static void colo_compare_connection(void *opaque, void *user_data) | 29 | @@ -XXX,XX +XXX,XX @@ static void virtio_net_guest_notifier_mask(VirtIODevice *vdev, int idx, |
30 | * until next comparison. | 30 | VirtIONet *n = VIRTIO_NET(vdev); |
31 | */ | 31 | NetClientState *nc; |
32 | trace_colo_compare_main("packet different"); | 32 | assert(n->vhost_started); |
33 | - g_queue_push_tail(&conn->primary_list, pkt); | 33 | - if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_MQ) && idx == 2) { |
34 | + g_queue_push_head(&conn->primary_list, pkt); | 34 | + if (!n->multiqueue && idx == 2) { |
35 | /* TODO: colo_notify_checkpoint();*/ | 35 | /* Must guard against invalid features and bogus queue index |
36 | break; | 36 | * from being set by malicious guest, or penetrated through |
37 | } | 37 | * buggy migration stream. |
38 | -- | 38 | -- |
39 | 2.7.4 | 39 | 2.42.0 |
40 | |||
41 | diff view generated by jsdifflib |
1 | From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | 1 | From: Akihiko Odaki <akihiko.odaki@daynix.com> |
---|---|---|---|
2 | 2 | ||
3 | Because vnet_hdr have a offset to net packet, we must add it when use | 3 | The kernel documentation says: |
4 | virtio-net. | 4 | > The value stored can be of any size, however, all array elements are |
5 | > aligned to 8 bytes. | ||
6 | https://www.kernel.org/doc/html/v6.8/bpf/map_array.html | ||
5 | 7 | ||
6 | Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | 8 | Fixes: 333b3e5fab75 ("ebpf: Added eBPF map update through mmap.") |
9 | Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
10 | Acked-by: Andrew Melnychenko <andrew@daynix.com> | ||
7 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 11 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
8 | --- | 12 | --- |
9 | net/filter-rewriter.c | 6 ++++-- | 13 | ebpf/ebpf_rss.c | 9 +++++++-- |
10 | 1 file changed, 4 insertions(+), 2 deletions(-) | 14 | 1 file changed, 7 insertions(+), 2 deletions(-) |
11 | 15 | ||
12 | diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c | 16 | diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c |
13 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/net/filter-rewriter.c | 18 | --- a/ebpf/ebpf_rss.c |
15 | +++ b/net/filter-rewriter.c | 19 | +++ b/ebpf/ebpf_rss.c |
16 | @@ -XXX,XX +XXX,XX @@ static int handle_primary_tcp_pkt(NetFilterState *nf, | 20 | @@ -XXX,XX +XXX,XX @@ static bool ebpf_rss_set_indirections_table(struct EBPFRSSContext *ctx, |
17 | /* handle packets to the secondary from the primary */ | 21 | uint16_t *indirections_table, |
18 | tcp_pkt->th_ack = htonl(ntohl(tcp_pkt->th_ack) + conn->offset); | 22 | size_t len) |
19 | 23 | { | |
20 | - net_checksum_calculate((uint8_t *)pkt->data, pkt->size); | 24 | + char *cursor = ctx->mmap_indirections_table; |
21 | + net_checksum_calculate((uint8_t *)pkt->data + pkt->vnet_hdr_len, | 25 | + |
22 | + pkt->size - pkt->vnet_hdr_len); | 26 | if (!ebpf_rss_is_loaded(ctx) || indirections_table == NULL || |
23 | } | 27 | len > VIRTIO_NET_RSS_MAX_TABLE_LEN) { |
28 | return false; | ||
24 | } | 29 | } |
25 | 30 | ||
26 | @@ -XXX,XX +XXX,XX @@ static int handle_secondary_tcp_pkt(NetFilterState *nf, | 31 | - memcpy(ctx->mmap_indirections_table, indirections_table, |
27 | /* handle packets to the primary from the secondary*/ | 32 | - sizeof(*indirections_table) * len); |
28 | tcp_pkt->th_seq = htonl(ntohl(tcp_pkt->th_seq) - conn->offset); | 33 | + for (size_t i = 0; i < len; i++) { |
29 | 34 | + *(uint16_t *)cursor = indirections_table[i]; | |
30 | - net_checksum_calculate((uint8_t *)pkt->data, pkt->size); | 35 | + cursor += 8; |
31 | + net_checksum_calculate((uint8_t *)pkt->data + pkt->vnet_hdr_len, | 36 | + } |
32 | + pkt->size - pkt->vnet_hdr_len); | 37 | + |
33 | } | 38 | return true; |
34 | } | 39 | } |
35 | 40 | ||
36 | -- | 41 | -- |
37 | 2.7.4 | 42 | 2.42.0 |
38 | |||
39 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com> | ||
2 | 1 | ||
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 |
Deleted patch | |||
---|---|---|---|
1 | From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com> | ||
2 | 1 | ||
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 |
Deleted patch | |||
---|---|---|---|
1 | From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com> | ||
2 | 1 | ||
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 |
Deleted patch | |||
---|---|---|---|
1 | From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com> | ||
2 | 1 | ||
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 |
1 | From: Wang Yong <wang.yong155@zte.com.cn> | 1 | From: Akihiko Odaki <akihiko.odaki@daynix.com> |
---|---|---|---|
2 | 2 | ||
3 | Update colo-proxy.txt,add IOThread configuration. | 3 | It is incorrect to have the VIRTIO_NET_HDR_F_NEEDS_CSUM set when |
4 | Later we have to configure IOThread,if not COLO can not work. | 4 | checksum offloading is disabled so clear the bit. |
5 | 5 | ||
6 | Reviewed-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | 6 | TCP/UDP checksum is usually offloaded when the peer requires virtio |
7 | Signed-off-by: Wang Yong <wang.yong155@zte.com.cn> | 7 | headers because they can instruct the peer to compute checksum. However, |
8 | Signed-off-by: Wang Guang <wang.guang55@zte.com.cn> | 8 | igb disables TX checksum offloading when a VF is enabled whether the |
9 | peer requires virtio headers because a transmitted packet can be routed | ||
10 | to it and it expects the packet has a proper checksum. Therefore, it | ||
11 | is necessary to have a correct virtio header even when checksum | ||
12 | offloading is disabled. | ||
13 | |||
14 | A real TCP/UDP checksum will be computed and saved in the buffer when | ||
15 | checksum offloading is disabled. The virtio specification requires to | ||
16 | set the packet checksum stored in the buffer to the TCP/UDP pseudo | ||
17 | header when the VIRTIO_NET_HDR_F_NEEDS_CSUM bit is set so the bit must | ||
18 | be cleared in that case. | ||
19 | |||
20 | Fixes: ffbd2dbd8e64 ("e1000e: Perform software segmentation for loopback") | ||
21 | Buglink: https://issues.redhat.com/browse/RHEL-23067 | ||
22 | Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
9 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 23 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
10 | --- | 24 | --- |
11 | docs/colo-proxy.txt | 3 ++- | 25 | hw/net/net_tx_pkt.c | 1 + |
12 | 1 file changed, 2 insertions(+), 1 deletion(-) | 26 | 1 file changed, 1 insertion(+) |
13 | 27 | ||
14 | diff --git a/docs/colo-proxy.txt b/docs/colo-proxy.txt | 28 | diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c |
15 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/docs/colo-proxy.txt | 30 | --- a/hw/net/net_tx_pkt.c |
17 | +++ b/docs/colo-proxy.txt | 31 | +++ b/hw/net/net_tx_pkt.c |
18 | @@ -XXX,XX +XXX,XX @@ Primary(ip:3.3.3.3): | 32 | @@ -XXX,XX +XXX,XX @@ bool net_tx_pkt_send_custom(struct NetTxPkt *pkt, bool offload, |
19 | -chardev socket,id=compare0-0,host=3.3.3.3,port=9001 | 33 | |
20 | -chardev socket,id=compare_out,host=3.3.3.3,port=9005,server,nowait | 34 | if (offload || gso_type == VIRTIO_NET_HDR_GSO_NONE) { |
21 | -chardev socket,id=compare_out0,host=3.3.3.3,port=9005 | 35 | if (!offload && pkt->virt_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) { |
22 | +-object iothread,id=iothread1 | 36 | + pkt->virt_hdr.flags &= ~VIRTIO_NET_HDR_F_NEEDS_CSUM; |
23 | -object filter-mirror,id=m0,netdev=hn0,queue=tx,outdev=mirror0 | 37 | net_tx_pkt_do_sw_csum(pkt, &pkt->vec[NET_TX_PKT_L2HDR_FRAG], |
24 | -object filter-redirector,netdev=hn0,id=redire0,queue=rx,indev=compare_out | 38 | pkt->payload_frags + NET_TX_PKT_PL_START_FRAG - 1, |
25 | -object filter-redirector,netdev=hn0,id=redire1,queue=rx,outdev=compare0 | 39 | pkt->payload_len); |
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 | -- | 40 | -- |
32 | 2.7.4 | 41 | 2.42.0 |
33 | |||
34 | diff view generated by jsdifflib |
1 | From: Matt Parker <mtparkr@gmail.com> | 1 | From: Akihiko Odaki <akihiko.odaki@daynix.com> |
---|---|---|---|
2 | 2 | ||
3 | Both io and memory use the same mmio functions in the rtl8139 device. | 3 | Some of them are only necessary for POSIX systems. The others are |
4 | This patch removes the separate MemoryRegionOps and old_mmio accessors | 4 | assigned to function pointers in NetClientInfo that can actually be |
5 | for memory, and replaces it with an alias to the io memory region. | 5 | NULL. |
6 | 6 | ||
7 | Signed-off-by: Matt Parker <mtparkr@gmail.com> | 7 | Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> |
8 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 8 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
9 | --- | 9 | --- |
10 | hw/net/rtl8139.c | 53 +++-------------------------------------------------- | 10 | net/tap-win32.c | 54 ------------------------------------------------- |
11 | 1 file changed, 3 insertions(+), 50 deletions(-) | 11 | 1 file changed, 54 deletions(-) |
12 | 12 | ||
13 | diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c | 13 | diff --git a/net/tap-win32.c b/net/tap-win32.c |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/net/rtl8139.c | 15 | --- a/net/tap-win32.c |
16 | +++ b/hw/net/rtl8139.c | 16 | +++ b/net/tap-win32.c |
17 | @@ -XXX,XX +XXX,XX @@ static uint32_t rtl8139_io_readl(void *opaque, uint8_t addr) | 17 | @@ -XXX,XX +XXX,XX @@ static void tap_win32_send(void *opaque) |
18 | 18 | } | |
19 | /* */ | 19 | } |
20 | 20 | ||
21 | -static void rtl8139_mmio_writeb(void *opaque, hwaddr addr, uint32_t val) | 21 | -static bool tap_has_ufo(NetClientState *nc) |
22 | -{ | 22 | -{ |
23 | - rtl8139_io_writeb(opaque, addr & 0xFF, val); | 23 | - return false; |
24 | -} | 24 | -} |
25 | - | 25 | - |
26 | -static void rtl8139_mmio_writew(void *opaque, hwaddr addr, uint32_t val) | 26 | -static bool tap_has_vnet_hdr(NetClientState *nc) |
27 | -{ | 27 | -{ |
28 | - rtl8139_io_writew(opaque, addr & 0xFF, val); | 28 | - return false; |
29 | -} | 29 | -} |
30 | - | 30 | - |
31 | -static void rtl8139_mmio_writel(void *opaque, hwaddr addr, uint32_t val) | 31 | -int tap_probe_vnet_hdr_len(int fd, int len) |
32 | -{ | 32 | -{ |
33 | - rtl8139_io_writel(opaque, addr & 0xFF, val); | 33 | - return 0; |
34 | -} | 34 | -} |
35 | - | 35 | - |
36 | -static uint32_t rtl8139_mmio_readb(void *opaque, hwaddr addr) | 36 | -void tap_fd_set_vnet_hdr_len(int fd, int len) |
37 | -{ | 37 | -{ |
38 | - return rtl8139_io_readb(opaque, addr & 0xFF); | ||
39 | -} | 38 | -} |
40 | - | 39 | - |
41 | -static uint32_t rtl8139_mmio_readw(void *opaque, hwaddr addr) | 40 | -int tap_fd_set_vnet_le(int fd, int is_le) |
42 | -{ | 41 | -{ |
43 | - uint32_t val = rtl8139_io_readw(opaque, addr & 0xFF); | 42 | - return -EINVAL; |
44 | - return val; | ||
45 | -} | 43 | -} |
46 | - | 44 | - |
47 | -static uint32_t rtl8139_mmio_readl(void *opaque, hwaddr addr) | 45 | -int tap_fd_set_vnet_be(int fd, int is_be) |
48 | -{ | 46 | -{ |
49 | - uint32_t val = rtl8139_io_readl(opaque, addr & 0xFF); | 47 | - return -EINVAL; |
50 | - return val; | ||
51 | -} | 48 | -} |
52 | - | 49 | - |
53 | static int rtl8139_post_load(void *opaque, int version_id) | 50 | -static void tap_using_vnet_hdr(NetClientState *nc, bool using_vnet_hdr) |
51 | -{ | ||
52 | -} | ||
53 | - | ||
54 | -static void tap_set_offload(NetClientState *nc, int csum, int tso4, | ||
55 | - int tso6, int ecn, int ufo, int uso4, int uso6) | ||
56 | -{ | ||
57 | -} | ||
58 | - | ||
59 | struct vhost_net *tap_get_vhost_net(NetClientState *nc) | ||
54 | { | 60 | { |
55 | RTL8139State* s = opaque; | 61 | return NULL; |
56 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps rtl8139_io_ops = { | 62 | } |
57 | .endianness = DEVICE_LITTLE_ENDIAN, | 63 | |
64 | -static bool tap_has_vnet_hdr_len(NetClientState *nc, int len) | ||
65 | -{ | ||
66 | - return false; | ||
67 | -} | ||
68 | - | ||
69 | -static void tap_set_vnet_hdr_len(NetClientState *nc, int len) | ||
70 | -{ | ||
71 | - abort(); | ||
72 | -} | ||
73 | - | ||
74 | static NetClientInfo net_tap_win32_info = { | ||
75 | .type = NET_CLIENT_DRIVER_TAP, | ||
76 | .size = sizeof(TAPState), | ||
77 | .receive = tap_receive, | ||
78 | .cleanup = tap_cleanup, | ||
79 | - .has_ufo = tap_has_ufo, | ||
80 | - .has_vnet_hdr = tap_has_vnet_hdr, | ||
81 | - .has_vnet_hdr_len = tap_has_vnet_hdr_len, | ||
82 | - .using_vnet_hdr = tap_using_vnet_hdr, | ||
83 | - .set_offload = tap_set_offload, | ||
84 | - .set_vnet_hdr_len = tap_set_vnet_hdr_len, | ||
58 | }; | 85 | }; |
59 | 86 | ||
60 | -static const MemoryRegionOps rtl8139_mmio_ops = { | 87 | static int tap_win32_init(NetClientState *peer, const char *model, |
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 | -- | 88 | -- |
92 | 2.7.4 | 89 | 2.42.0 |
93 | |||
94 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | ||
2 | 1 | ||
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 |
Deleted patch | |||
---|---|---|---|
1 | From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com> | ||
2 | 1 | ||
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 |
Deleted patch | |||
---|---|---|---|
1 | From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com> | ||
2 | 1 | ||
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 |
Deleted patch | |||
---|---|---|---|
1 | From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com> | ||
2 | 1 | ||
3 | Cc: berrange@redhat.com | ||
4 | Cc: kraxel@redhat.com | ||
5 | Cc: pbonzini@redhat.com | ||
6 | Cc: jasowang@redhat.com | ||
7 | Cc: armbru@redhat.com | ||
8 | Cc: eblake@redhat.com | ||
9 | Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com> | ||
10 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | ||
11 | Signed-off-by: Jason Wang <jasowang@redhat.com> | ||
12 | --- | ||
13 | include/qemu/sockets.h | 3 ++- | ||
14 | net/net.c | 22 +++++++++++++++++----- | ||
15 | net/socket.c | 22 +++++++++++++++------- | ||
16 | 3 files changed, 34 insertions(+), 13 deletions(-) | ||
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 | /** | ||
32 | diff --git a/net/net.c b/net/net.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/net/net.c | ||
35 | +++ b/net/net.c | ||
36 | @@ -XXX,XX +XXX,XX @@ static int get_str_sep(char *buf, int buf_size, const char **pp, int sep) | ||
37 | return 0; | ||
38 | } | ||
39 | |||
40 | -int parse_host_port(struct sockaddr_in *saddr, const char *str) | ||
41 | +int parse_host_port(struct sockaddr_in *saddr, const char *str, | ||
42 | + Error **errp) | ||
43 | { | ||
44 | char buf[512]; | ||
45 | struct hostent *he; | ||
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; | ||
75 | } | ||
76 | } | ||
77 | port = strtol(p, (char **)&r, 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 | |||
154 | -- | ||
155 | 2.7.4 | ||
156 | |||
157 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com> | ||
2 | 1 | ||
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 |
Deleted patch | |||
---|---|---|---|
1 | From: Kamil Rytarowski <n54@gmx.com> | ||
2 | 1 | ||
3 | SunOS defines SEC in <sys/time.h> as 1 (commonly used time symbols). | ||
4 | |||
5 | This fixes build on SmartOS (Joyent). | ||
6 | |||
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> | ||
11 | Signed-off-by: Jason Wang <jasowang@redhat.com> | ||
12 | --- | ||
13 | hw/net/e1000.c | 4 ++-- | ||
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(-) | ||
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 */ | ||
54 | diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/hw/net/e1000e_core.c | ||
57 | +++ b/hw/net/e1000e_core.c | ||
58 | @@ -XXX,XX +XXX,XX @@ static uint32_t (*e1000e_macreg_readops[])(E1000ECore *, int) = { | ||
59 | e1000e_getreg(RDLEN0), | ||
60 | e1000e_getreg(RDH1), | ||
61 | e1000e_getreg(LATECOL), | ||
62 | - e1000e_getreg(SEC), | ||
63 | + e1000e_getreg(SEQEC), | ||
64 | e1000e_getreg(XONTXC), | ||
65 | e1000e_getreg(WUS), | ||
66 | e1000e_getreg(GORCL), | ||
67 | diff --git a/hw/net/e1000x_common.h b/hw/net/e1000x_common.h | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/hw/net/e1000x_common.h | ||
70 | +++ b/hw/net/e1000x_common.h | ||
71 | @@ -XXX,XX +XXX,XX @@ enum { | ||
72 | defreg(VFTA), defreg(VET), defreg(RDTR), defreg(RADV), | ||
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), | ||
80 | -- | ||
81 | 2.7.4 | ||
82 | |||
83 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | ||
2 | 1 | ||
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 |
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 | net/colo-compare.c | 59 ++++++++++++++++++++++++++++-------------------------- | ||
7 | 1 file changed, 31 insertions(+), 28 deletions(-) | ||
8 | |||
9 | diff --git a/net/colo-compare.c b/net/colo-compare.c | ||
10 | index XXXXXXX..XXXXXXX 100644 | ||
11 | --- a/net/colo-compare.c | ||
12 | +++ b/net/colo-compare.c | ||
13 | @@ -XXX,XX +XXX,XX @@ | ||
14 | #define REGULAR_PACKET_CHECK_MS 3000 | ||
15 | |||
16 | /* | ||
17 | - + CompareState ++ | ||
18 | - | | | ||
19 | - +---------------+ +---------------+ +---------------+ | ||
20 | - |conn list +--->conn +--------->conn | | ||
21 | - +---------------+ +---------------+ +---------------+ | ||
22 | - | | | | | | | ||
23 | - +---------------+ +---v----+ +---v----+ +---v----+ +---v----+ | ||
24 | - |primary | |secondary |primary | |secondary | ||
25 | - |packet | |packet + |packet | |packet + | ||
26 | - +--------+ +--------+ +--------+ +--------+ | ||
27 | - | | | | | ||
28 | - +---v----+ +---v----+ +---v----+ +---v----+ | ||
29 | - |primary | |secondary |primary | |secondary | ||
30 | - |packet | |packet + |packet | |packet + | ||
31 | - +--------+ +--------+ +--------+ +--------+ | ||
32 | - | | | | | ||
33 | - +---v----+ +---v----+ +---v----+ +---v----+ | ||
34 | - |primary | |secondary |primary | |secondary | ||
35 | - |packet | |packet + |packet | |packet + | ||
36 | - +--------+ +--------+ +--------+ +--------+ | ||
37 | -*/ | ||
38 | + * + CompareState ++ | ||
39 | + * | | | ||
40 | + * +---------------+ +---------------+ +---------------+ | ||
41 | + * | conn list + - > conn + ------- > conn + -- > ...... | ||
42 | + * +---------------+ +---------------+ +---------------+ | ||
43 | + * | | | | | | | ||
44 | + * +---------------+ +---v----+ +---v----+ +---v----+ +---v----+ | ||
45 | + * |primary | |secondary |primary | |secondary | ||
46 | + * |packet | |packet + |packet | |packet + | ||
47 | + * +--------+ +--------+ +--------+ +--------+ | ||
48 | + * | | | | | ||
49 | + * +---v----+ +---v----+ +---v----+ +---v----+ | ||
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 | } | ||
95 | |||
96 | -- | ||
97 | 2.7.4 | ||
98 | |||
99 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Wang Yong <wang.yong155@zte.com.cn> | ||
2 | 1 | ||
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: Wang Yong <wang.yong155@zte.com.cn> | 1 | From: Akihiko Odaki <akihiko.odaki@daynix.com> |
---|---|---|---|
2 | 2 | ||
3 | Remove the task which check old packet in the comparing thread, | 3 | This reverts commit 46d4d36d0bf2b24b205f2f604f0905db80264eef. |
4 | then use IOthread context timer to handle it. | ||
5 | 4 | ||
6 | Process pactkets in the IOThread which arrived over the socket. | 5 | The reverted commit changed to emit warnings instead of errors when |
7 | we use iothread_get_g_main_context to create a new g_main_loop in | 6 | vhost is requested but vhost initialization fails if vhostforce option |
8 | the IOThread.then the packets from the primary and the secondary | 7 | is not set. |
9 | are processed in the IOThread. | ||
10 | 8 | ||
11 | Finally remove the colo-compare thread using the IOThread instead. | 9 | However, vhostforce is not meant to ignore vhost errors. It was once |
10 | introduced as an option to commit 5430a28fe4 ("vhost: force vhost off | ||
11 | for non-MSI guests") to force enabling vhost for non-MSI guests, which | ||
12 | will have worse performance with vhost. The option was deprecated with | ||
13 | commit 1e7398a140 ("vhost: enable vhost without without MSI-X") and | ||
14 | changed to behave identical with the vhost option for compatibility. | ||
12 | 15 | ||
13 | Reviewed-by: Zhang Chen<zhangchen.fnst@cn.fujitsu.com> | 16 | Worse, commit bf769f742c ("virtio: del net client if net_init_tap_one |
14 | Signed-off-by: Wang Yong <wang.yong155@zte.com.cn> | 17 | failed") changed to delete the client when vhost fails even when the |
15 | Signed-off-by: Wang Guang <wang.guang55@zte.com.cn> | 18 | failure only results in a warning. The leads to an assertion failure |
19 | for the -netdev command line option. | ||
20 | |||
21 | The reverted commit was intended to avoid that the vhost initialization | ||
22 | failure won't result in a corrupted netdev. This problem should have | ||
23 | been fixed by deleting netdev when the initialization fails instead of | ||
24 | ignoring the failure with an arbitrary option. Fortunately, commit | ||
25 | bf769f742c ("virtio: del net client if net_init_tap_one failed"), | ||
26 | mentioned earlier, implements this behavior. | ||
27 | |||
28 | Restore the correct semantics and fix the assertion failure for the | ||
29 | -netdev command line option by reverting the problematic commit. | ||
30 | |||
31 | Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
16 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 32 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
17 | --- | 33 | --- |
18 | net/colo-compare.c | 83 +++++++++++++++++++++++++++++------------------------- | 34 | include/net/vhost_net.h | 3 --- |
19 | 1 file changed, 45 insertions(+), 38 deletions(-) | 35 | net/tap.c | 22 +++++----------------- |
36 | 2 files changed, 5 insertions(+), 20 deletions(-) | ||
20 | 37 | ||
21 | diff --git a/net/colo-compare.c b/net/colo-compare.c | 38 | diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h |
22 | index XXXXXXX..XXXXXXX 100644 | 39 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/net/colo-compare.c | 40 | --- a/include/net/vhost_net.h |
24 | +++ b/net/colo-compare.c | 41 | +++ b/include/net/vhost_net.h |
25 | @@ -XXX,XX +XXX,XX @@ | 42 | @@ -XXX,XX +XXX,XX @@ |
26 | #include "qemu/sockets.h" | 43 | #include "net/net.h" |
27 | #include "qapi-visit.h" | 44 | #include "hw/virtio/vhost-backend.h" |
28 | #include "net/colo.h" | 45 | |
29 | +#include "sysemu/iothread.h" | 46 | -#define VHOST_NET_INIT_FAILED \ |
30 | 47 | - "vhost-net requested but could not be initialized" | |
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) | ||
53 | { | ||
54 | CompareState *s = opaque; | ||
55 | |||
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); | ||
72 | } | ||
73 | |||
74 | -static void *colo_compare_thread(void *opaque) | ||
75 | +static void colo_compare_timer_del(CompareState *s) | ||
76 | { | ||
77 | - CompareState *s = opaque; | ||
78 | - GSource *timeout_source; | ||
79 | + if (s->packet_check_timer) { | ||
80 | + timer_del(s->packet_check_timer); | ||
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 | - | 48 | - |
100 | - /* To kick any packets that the secondary doesn't match */ | 49 | struct vhost_net; |
101 | - timeout_source = g_timeout_source_new(REGULAR_PACKET_CHECK_MS); | 50 | typedef struct vhost_net VHostNetState; |
102 | - g_source_set_callback(timeout_source, | 51 | |
103 | - (GSourceFunc)check_old_packet_regular, s, NULL); | 52 | diff --git a/net/tap.c b/net/tap.c |
104 | - g_source_attach(timeout_source, s->worker_context); | 53 | index XXXXXXX..XXXXXXX 100644 |
105 | - | 54 | --- a/net/tap.c |
106 | - g_main_loop_run(s->compare_loop); | 55 | +++ b/net/tap.c |
107 | - | 56 | @@ -XXX,XX +XXX,XX @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, |
108 | - g_source_unref(timeout_source); | 57 | if (vhostfdname) { |
109 | - g_main_loop_unref(s->compare_loop); | 58 | vhostfd = monitor_fd_param(monitor_cur(), vhostfdname, &err); |
110 | - g_main_context_unref(s->worker_context); | 59 | if (vhostfd == -1) { |
111 | - return NULL; | 60 | - if (tap->has_vhostforce && tap->vhostforce) { |
112 | + colo_compare_timer_init(s); | 61 | - error_propagate(errp, err); |
113 | } | 62 | - } else { |
114 | 63 | - warn_report_err(err); | |
115 | static char *compare_get_pri_indev(Object *obj, Error **errp) | 64 | - } |
116 | @@ -XXX,XX +XXX,XX @@ static void colo_compare_complete(UserCreatable *uc, Error **errp) | 65 | + error_propagate(errp, err); |
117 | { | 66 | goto failed; |
118 | CompareState *s = COLO_COMPARE(uc); | 67 | } |
119 | Chardev *chr; | 68 | if (!g_unix_set_fd_nonblocking(vhostfd, true, NULL)) { |
120 | - char thread_name[64]; | 69 | @@ -XXX,XX +XXX,XX @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, |
121 | - static int compare_id; | 70 | } else { |
122 | 71 | vhostfd = open("/dev/vhost-net", O_RDWR); | |
123 | - if (!s->pri_indev || !s->sec_indev || !s->outdev) { | 72 | if (vhostfd < 0) { |
124 | + if (!s->pri_indev || !s->sec_indev || !s->outdev || !s->iothread) { | 73 | - if (tap->has_vhostforce && tap->vhostforce) { |
125 | error_setg(errp, "colo compare needs 'primary_in' ," | 74 | - error_setg_errno(errp, errno, |
126 | - "'secondary_in','outdev' property set"); | 75 | - "tap: open vhost char device failed"); |
127 | + "'secondary_in','outdev','iothread' property set"); | 76 | - } else { |
128 | return; | 77 | - warn_report("tap: open vhost char device failed: %s", |
129 | } else if (!strcmp(s->pri_indev, s->outdev) || | 78 | - strerror(errno)); |
130 | !strcmp(s->sec_indev, s->outdev) || | 79 | - } |
131 | @@ -XXX,XX +XXX,XX @@ static void colo_compare_complete(UserCreatable *uc, Error **errp) | 80 | + error_setg_errno(errp, errno, |
132 | g_free, | 81 | + "tap: open vhost char device failed"); |
133 | connection_destroy); | 82 | goto failed; |
134 | 83 | } | |
135 | - sprintf(thread_name, "colo-compare %d", compare_id); | 84 | if (!g_unix_set_fd_nonblocking(vhostfd, true, NULL)) { |
136 | - qemu_thread_create(&s->thread, thread_name, | 85 | @@ -XXX,XX +XXX,XX @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, |
137 | - colo_compare_thread, s, | 86 | |
138 | - QEMU_THREAD_JOINABLE); | 87 | s->vhost_net = vhost_net_init(&options); |
139 | - compare_id++; | 88 | if (!s->vhost_net) { |
140 | - | 89 | - if (tap->has_vhostforce && tap->vhostforce) { |
141 | + colo_compare_iothread(s); | 90 | - error_setg(errp, VHOST_NET_INIT_FAILED); |
142 | return; | 91 | - } else { |
143 | } | 92 | - warn_report(VHOST_NET_INIT_FAILED); |
144 | 93 | - } | |
145 | @@ -XXX,XX +XXX,XX @@ static void colo_compare_init(Object *obj) | 94 | + error_setg(errp, |
146 | object_property_add_str(obj, "outdev", | 95 | + "vhost-net requested but could not be initialized"); |
147 | compare_get_outdev, compare_set_outdev, | 96 | goto failed; |
148 | NULL); | 97 | } |
149 | + object_property_add_link(obj, "iothread", TYPE_IOTHREAD, | 98 | } else if (vhostfdname) { |
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 | + } | ||
176 | + | ||
177 | + if (s->iothread) { | ||
178 | + object_unref(OBJECT(s->iothread)); | ||
179 | + } | ||
180 | g_free(s->pri_indev); | ||
181 | g_free(s->sec_indev); | ||
182 | g_free(s->outdev); | ||
183 | -- | 99 | -- |
184 | 2.7.4 | 100 | 2.42.0 |
185 | |||
186 | diff view generated by jsdifflib |