1
The following changes since commit 23895cbd82be95428e90168b12e925d0d3ca2f06:
1
The following changes since commit 5012e522aca161be5c141596c66e5cc6082538a9:
2
2
3
Merge remote-tracking branch 'remotes/awilliam/tags/vfio-update-20201123.0' into staging (2020-11-23 18:51:13 +0000)
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 9925990d01a92564af55f6f69d0f5f59b47609b1:
9
for you to fetch changes up to d9b33018a0da51eddceb48c42345cfb351065f3e:
10
10
11
net: Use correct default-path macro for downscript (2020-11-24 10:40:17 +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
Keqian Zhu (1):
27
Akihiko Odaki (5):
17
net: Use correct default-path macro for downscript
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
Paolo Bonzini (1):
34
ebpf/ebpf_rss.c | 9 +++++++--
20
net: do not exit on "netdev_add help" monitor command
35
hw/net/net_tx_pkt.c | 1 +
21
36
hw/net/virtio-net.c | 4 ++--
22
Prasad J Pandit (1):
37
include/net/vhost_net.h | 3 ---
23
hw/net/e1000e: advance desc_offset in case of null descriptor
38
net/tap-win32.c | 54 -------------------------------------------------
24
39
net/tap.c | 22 +++++---------------
25
Yuri Benditovich (1):
40
6 files changed, 15 insertions(+), 78 deletions(-)
26
net: purge queued rx packets on queue deletion
27
28
yuanjungong (1):
29
tap: fix a memory leak
30
31
hw/net/e1000e_core.c | 8 +++---
32
include/net/net.h | 1 +
33
monitor/hmp-cmds.c | 6 ++++
34
net/net.c | 80 +++++++++++++++++++++++++++-------------------------
35
net/tap.c | 5 +++-
36
5 files changed, 57 insertions(+), 43 deletions(-)
37
38
diff view generated by jsdifflib
1
From: Keqian Zhu <zhukeqian1@huawei.com>
1
From: Akihiko Odaki <akihiko.odaki@daynix.com>
2
2
3
Fixes: 63c4db4c2e6d (net: relocate paths to helpers and scripts)
3
virtio_net_guest_notifier_pending() and virtio_net_guest_notifier_mask()
4
Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
4
checked VIRTIO_NET_F_MQ to know there are multiple queues, but
5
VIRTIO_NET_F_RSS also enables multiple queues. Refer to n->multiqueue,
6
which is set to true either of VIRTIO_NET_F_MQ or VIRTIO_NET_F_RSS is
7
enabled.
8
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>
5
Signed-off-by: Jason Wang <jasowang@redhat.com>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
6
---
12
---
7
net/tap.c | 3 ++-
13
hw/net/virtio-net.c | 4 ++--
8
1 file changed, 2 insertions(+), 1 deletion(-)
14
1 file changed, 2 insertions(+), 2 deletions(-)
9
15
10
diff --git a/net/tap.c b/net/tap.c
16
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
11
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
12
--- a/net/tap.c
18
--- a/hw/net/virtio-net.c
13
+++ b/net/tap.c
19
+++ b/hw/net/virtio-net.c
14
@@ -XXX,XX +XXX,XX @@ free_fail:
20
@@ -XXX,XX +XXX,XX @@ static bool virtio_net_guest_notifier_pending(VirtIODevice *vdev, int idx)
15
script = default_script = get_relocated_path(DEFAULT_NETWORK_SCRIPT);
21
VirtIONet *n = VIRTIO_NET(vdev);
16
}
22
NetClientState *nc;
17
if (!downscript) {
23
assert(n->vhost_started);
18
- downscript = default_downscript = get_relocated_path(DEFAULT_NETWORK_SCRIPT);
24
- if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_MQ) && idx == 2) {
19
+ downscript = default_downscript =
25
+ if (!n->multiqueue && idx == 2) {
20
+ get_relocated_path(DEFAULT_NETWORK_DOWN_SCRIPT);
26
/* Must guard against invalid features and bogus queue index
21
}
27
* from being set by malicious guest, or penetrated through
22
28
* buggy migration stream.
23
if (tap->has_ifname) {
29
@@ -XXX,XX +XXX,XX @@ static void virtio_net_guest_notifier_mask(VirtIODevice *vdev, int idx,
30
VirtIONet *n = VIRTIO_NET(vdev);
31
NetClientState *nc;
32
assert(n->vhost_started);
33
- if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_MQ) && idx == 2) {
34
+ if (!n->multiqueue && idx == 2) {
35
/* Must guard against invalid features and bogus queue index
36
* from being set by malicious guest, or penetrated through
37
* buggy migration stream.
24
--
38
--
25
2.7.4
39
2.42.0
26
27
diff view generated by jsdifflib
1
From: Yuri Benditovich <yuri.benditovich@daynix.com>
1
From: Akihiko Odaki <akihiko.odaki@daynix.com>
2
2
3
https://bugzilla.redhat.com/show_bug.cgi?id=1829272
3
The kernel documentation says:
4
When deleting queue pair, purge pending RX packets if any.
4
> The value stored can be of any size, however, all array elements are
5
Example of problematic flow:
5
> aligned to 8 bytes.
6
1. Bring up q35 VM with tap (vhost off) and virtio-net or e1000e
6
https://www.kernel.org/doc/html/v6.8/bpf/map_array.html
7
2. Run ping flood to the VM NIC ( 1 ms interval)
8
3. Hot unplug the NIC device (device_del)
9
During unplug process one or more packets come, the NIC
10
can't receive, tap disables read_poll
11
4. Hot plug the device (device_add) with the same netdev
12
The tap stays with read_poll disabled and does not receive
13
any packets anymore (tap_send never triggered)
14
7
15
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.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>
16
Signed-off-by: Jason Wang <jasowang@redhat.com>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
17
---
12
---
18
net/net.c | 12 ++++++++----
13
ebpf/ebpf_rss.c | 9 +++++++--
19
1 file changed, 8 insertions(+), 4 deletions(-)
14
1 file changed, 7 insertions(+), 2 deletions(-)
20
15
21
diff --git a/net/net.c b/net/net.c
16
diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c
22
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
23
--- a/net/net.c
18
--- a/ebpf/ebpf_rss.c
24
+++ b/net/net.c
19
+++ b/ebpf/ebpf_rss.c
25
@@ -XXX,XX +XXX,XX @@ void qemu_del_nic(NICState *nic)
20
@@ -XXX,XX +XXX,XX @@ static bool ebpf_rss_set_indirections_table(struct EBPFRSSContext *ctx,
26
21
uint16_t *indirections_table,
27
qemu_macaddr_set_free(&nic->conf->macaddr);
22
size_t len)
28
23
{
29
- /* If this is a peer NIC and peer has already been deleted, free it now. */
24
+ char *cursor = ctx->mmap_indirections_table;
30
- if (nic->peer_deleted) {
25
+
31
- for (i = 0; i < queues; i++) {
26
if (!ebpf_rss_is_loaded(ctx) || indirections_table == NULL ||
32
- qemu_free_net_client(qemu_get_subqueue(nic, i)->peer);
27
len > VIRTIO_NET_RSS_MAX_TABLE_LEN) {
33
+ for (i = 0; i < queues; i++) {
28
return false;
34
+ NetClientState *nc = qemu_get_subqueue(nic, i);
35
+ /* If this is a peer NIC and peer has already been deleted, free it now. */
36
+ if (nic->peer_deleted) {
37
+ qemu_free_net_client(nc->peer);
38
+ } else if (nc->peer) {
39
+ /* if there are RX packets pending, complete them */
40
+ qemu_purge_queued_packets(nc->peer);
41
}
42
}
29
}
43
30
31
- memcpy(ctx->mmap_indirections_table, indirections_table,
32
- sizeof(*indirections_table) * len);
33
+ for (size_t i = 0; i < len; i++) {
34
+ *(uint16_t *)cursor = indirections_table[i];
35
+ cursor += 8;
36
+ }
37
+
38
return true;
39
}
40
44
--
41
--
45
2.7.4
42
2.42.0
46
47
diff view generated by jsdifflib
1
From: Prasad J Pandit <pjp@fedoraproject.org>
1
From: Akihiko Odaki <akihiko.odaki@daynix.com>
2
2
3
While receiving packets via e1000e_write_packet_to_guest() routine,
3
It is incorrect to have the VIRTIO_NET_HDR_F_NEEDS_CSUM set when
4
'desc_offset' is advanced only when RX descriptor is processed. And
4
checksum offloading is disabled so clear the bit.
5
RX descriptor is not processed if it has NULL buffer address.
6
This may lead to an infinite loop condition. Increament 'desc_offset'
7
to process next descriptor in the ring to avoid infinite loop.
8
5
9
Reported-by: Cheol-woo Myung <330cjfdn@gmail.com>
6
TCP/UDP checksum is usually offloaded when the peer requires virtio
10
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
7
headers because they can instruct the peer to compute checksum. However,
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>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
23
Signed-off-by: Jason Wang <jasowang@redhat.com>
12
---
24
---
13
hw/net/e1000e_core.c | 8 ++++----
25
hw/net/net_tx_pkt.c | 1 +
14
1 file changed, 4 insertions(+), 4 deletions(-)
26
1 file changed, 1 insertion(+)
15
27
16
diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
28
diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c
17
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/net/e1000e_core.c
30
--- a/hw/net/net_tx_pkt.c
19
+++ b/hw/net/e1000e_core.c
31
+++ b/hw/net/net_tx_pkt.c
20
@@ -XXX,XX +XXX,XX @@ e1000e_write_packet_to_guest(E1000ECore *core, struct NetRxPkt *pkt,
32
@@ -XXX,XX +XXX,XX @@ bool net_tx_pkt_send_custom(struct NetTxPkt *pkt, bool offload,
21
(const char *) &fcs_pad, e1000x_fcs_len(core->mac));
33
22
}
34
if (offload || gso_type == VIRTIO_NET_HDR_GSO_NONE) {
23
}
35
if (!offload && pkt->virt_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
24
- desc_offset += desc_size;
36
+ pkt->virt_hdr.flags &= ~VIRTIO_NET_HDR_F_NEEDS_CSUM;
25
- if (desc_offset >= total_size) {
37
net_tx_pkt_do_sw_csum(pkt, &pkt->vec[NET_TX_PKT_L2HDR_FRAG],
26
- is_last = true;
38
pkt->payload_frags + NET_TX_PKT_PL_START_FRAG - 1,
27
- }
39
pkt->payload_len);
28
} else { /* as per intel docs; skip descriptors with null buf addr */
29
trace_e1000e_rx_null_descriptor();
30
}
31
+ desc_offset += desc_size;
32
+ if (desc_offset >= total_size) {
33
+ is_last = true;
34
+ }
35
36
e1000e_write_rx_descr(core, desc, is_last ? core->rx_pkt : NULL,
37
rss_info, do_ps ? ps_hdr_len : 0, &bastate.written);
38
--
40
--
39
2.7.4
41
2.42.0
40
41
diff view generated by jsdifflib
1
From: Paolo Bonzini <pbonzini@redhat.com>
1
From: Akihiko Odaki <akihiko.odaki@daynix.com>
2
2
3
"netdev_add help" is causing QEMU to exit because the code that
3
Some of them are only necessary for POSIX systems. The others are
4
invokes show_netdevs is shared between CLI and HMP processing.
4
assigned to function pointers in NetClientInfo that can actually be
5
Move the check to the callers so that exit(0) remains only
5
NULL.
6
in the CLI flow.
7
6
8
"netdev_add help" is not fixed by this patch; that is left for
7
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
9
later work.
10
11
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12
Signed-off-by: Jason Wang <jasowang@redhat.com>
8
Signed-off-by: Jason Wang <jasowang@redhat.com>
13
---
9
---
14
include/net/net.h | 1 +
10
net/tap-win32.c | 54 -------------------------------------------------
15
monitor/hmp-cmds.c | 6 +++++
11
1 file changed, 54 deletions(-)
16
net/net.c | 68 +++++++++++++++++++++++++++---------------------------
17
3 files changed, 41 insertions(+), 34 deletions(-)
18
12
19
diff --git a/include/net/net.h b/include/net/net.h
13
diff --git a/net/tap-win32.c b/net/tap-win32.c
20
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
21
--- a/include/net/net.h
15
--- a/net/tap-win32.c
22
+++ b/include/net/net.h
16
+++ b/net/tap-win32.c
23
@@ -XXX,XX +XXX,XX @@ extern const char *host_net_devices[];
17
@@ -XXX,XX +XXX,XX @@ static void tap_win32_send(void *opaque)
24
25
/* from net.c */
26
int net_client_parse(QemuOptsList *opts_list, const char *str);
27
+void show_netdevs(void);
28
int net_init_clients(Error **errp);
29
void net_check_clients(void);
30
void net_cleanup(void);
31
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/monitor/hmp-cmds.c
34
+++ b/monitor/hmp-cmds.c
35
@@ -XXX,XX +XXX,XX @@
36
#include "qemu/option.h"
37
#include "qemu/timer.h"
38
#include "qemu/sockets.h"
39
+#include "qemu/help_option.h"
40
#include "monitor/monitor-internal.h"
41
#include "qapi/error.h"
42
#include "qapi/clone-visitor.h"
43
@@ -XXX,XX +XXX,XX @@ void hmp_netdev_add(Monitor *mon, const QDict *qdict)
44
{
45
Error *err = NULL;
46
QemuOpts *opts;
47
+ const char *type = qdict_get_try_str(qdict, "type");
48
49
+ if (type && is_help_option(type)) {
50
+ show_netdevs();
51
+ return;
52
+ }
53
opts = qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict, &err);
54
if (err) {
55
goto out;
56
diff --git a/net/net.c b/net/net.c
57
index XXXXXXX..XXXXXXX 100644
58
--- a/net/net.c
59
+++ b/net/net.c
60
@@ -XXX,XX +XXX,XX @@
61
#include "qemu/config-file.h"
62
#include "qemu/ctype.h"
63
#include "qemu/iov.h"
64
+#include "qemu/qemu-print.h"
65
#include "qemu/main-loop.h"
66
#include "qemu/option.h"
67
#include "qapi/error.h"
68
@@ -XXX,XX +XXX,XX @@ static int net_client_init1(const Netdev *netdev, bool is_netdev, Error **errp)
69
return 0;
70
}
71
72
-static void show_netdevs(void)
73
+void show_netdevs(void)
74
{
75
int idx;
76
const char *available_netdevs[] = {
77
@@ -XXX,XX +XXX,XX @@ static void show_netdevs(void)
78
#endif
79
};
80
81
- printf("Available netdev backend types:\n");
82
+ qemu_printf("Available netdev backend types:\n");
83
for (idx = 0; idx < ARRAY_SIZE(available_netdevs); idx++) {
84
- puts(available_netdevs[idx]);
85
+ qemu_printf("%s\n", available_netdevs[idx]);
86
}
18
}
87
}
19
}
88
20
89
@@ -XXX,XX +XXX,XX @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
21
-static bool tap_has_ufo(NetClientState *nc)
90
int ret = -1;
22
-{
91
Visitor *v = opts_visitor_new(opts);
23
- return false;
92
24
-}
93
- const char *type = qemu_opt_get(opts, "type");
94
-
25
-
95
- if (is_netdev && type && is_help_option(type)) {
26
-static bool tap_has_vnet_hdr(NetClientState *nc)
96
- show_netdevs();
27
-{
97
- exit(0);
28
- return false;
98
- } else {
29
-}
99
- /* Parse convenience option format ip6-net=fec0::0[/64] */
100
- const char *ip6_net = qemu_opt_get(opts, "ipv6-net");
101
+ /* Parse convenience option format ip6-net=fec0::0[/64] */
102
+ const char *ip6_net = qemu_opt_get(opts, "ipv6-net");
103
104
- if (ip6_net) {
105
- char *prefix_addr;
106
- unsigned long prefix_len = 64; /* Default 64bit prefix length. */
107
+ if (ip6_net) {
108
+ char *prefix_addr;
109
+ unsigned long prefix_len = 64; /* Default 64bit prefix length. */
110
111
- substrings = g_strsplit(ip6_net, "/", 2);
112
- if (!substrings || !substrings[0]) {
113
- error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "ipv6-net",
114
- "a valid IPv6 prefix");
115
- goto out;
116
- }
117
+ substrings = g_strsplit(ip6_net, "/", 2);
118
+ if (!substrings || !substrings[0]) {
119
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "ipv6-net",
120
+ "a valid IPv6 prefix");
121
+ goto out;
122
+ }
123
124
- prefix_addr = substrings[0];
125
+ prefix_addr = substrings[0];
126
127
- /* Handle user-specified prefix length. */
128
- if (substrings[1] &&
129
- qemu_strtoul(substrings[1], NULL, 10, &prefix_len))
130
- {
131
- error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
132
- "ipv6-prefixlen", "a number");
133
- goto out;
134
- }
135
-
30
-
136
- qemu_opt_set(opts, "ipv6-prefix", prefix_addr, &error_abort);
31
-int tap_probe_vnet_hdr_len(int fd, int len)
137
- qemu_opt_set_number(opts, "ipv6-prefixlen", prefix_len,
32
-{
138
- &error_abort);
33
- return 0;
139
- qemu_opt_unset(opts, "ipv6-net");
34
-}
140
+ /* Handle user-specified prefix length. */
35
-
141
+ if (substrings[1] &&
36
-void tap_fd_set_vnet_hdr_len(int fd, int len)
142
+ qemu_strtoul(substrings[1], NULL, 10, &prefix_len))
37
-{
143
+ {
38
-}
144
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
39
-
145
+ "ipv6-prefixlen", "a number");
40
-int tap_fd_set_vnet_le(int fd, int is_le)
146
+ goto out;
41
-{
147
}
42
- return -EINVAL;
148
+
43
-}
149
+ qemu_opt_set(opts, "ipv6-prefix", prefix_addr, &error_abort);
44
-
150
+ qemu_opt_set_number(opts, "ipv6-prefixlen", prefix_len,
45
-int tap_fd_set_vnet_be(int fd, int is_be)
151
+ &error_abort);
46
-{
152
+ qemu_opt_unset(opts, "ipv6-net");
47
- return -EINVAL;
153
}
48
-}
154
49
-
155
/* Create an ID for -net if the user did not specify one */
50
-static void tap_using_vnet_hdr(NetClientState *nc, bool using_vnet_hdr)
156
@@ -XXX,XX +XXX,XX @@ static int net_init_client(void *dummy, QemuOpts *opts, Error **errp)
51
-{
157
52
-}
158
static int net_init_netdev(void *dummy, QemuOpts *opts, Error **errp)
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)
159
{
60
{
160
+ const char *type = qemu_opt_get(opts, "type");
61
return NULL;
161
+
162
+ if (type && is_help_option(type)) {
163
+ show_netdevs();
164
+ exit(0);
165
+ }
166
return net_client_init(opts, true, errp);
167
}
62
}
168
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,
85
};
86
87
static int tap_win32_init(NetClientState *peer, const char *model,
169
--
88
--
170
2.7.4
89
2.42.0
171
172
diff view generated by jsdifflib
1
From: yuanjungong <ruc_gongyuanjun@163.com>
1
From: Akihiko Odaki <akihiko.odaki@daynix.com>
2
2
3
Close fd before returning.
3
This reverts commit 46d4d36d0bf2b24b205f2f604f0905db80264eef.
4
4
5
Buglink: https://bugs.launchpad.net/qemu/+bug/1904486
5
The reverted commit changed to emit warnings instead of errors when
6
vhost is requested but vhost initialization fails if vhostforce option
7
is not set.
6
8
7
Signed-off-by: yuanjungong <ruc_gongyuanjun@163.com>
9
However, vhostforce is not meant to ignore vhost errors. It was once
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
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.
15
16
Worse, commit bf769f742c ("virtio: del net client if net_init_tap_one
17
failed") changed to delete the client when vhost fails even when the
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>
9
Signed-off-by: Jason Wang <jasowang@redhat.com>
32
Signed-off-by: Jason Wang <jasowang@redhat.com>
10
---
33
---
11
net/tap.c | 2 ++
34
include/net/vhost_net.h | 3 ---
12
1 file changed, 2 insertions(+)
35
net/tap.c | 22 +++++-----------------
36
2 files changed, 5 insertions(+), 20 deletions(-)
13
37
38
diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h
39
index XXXXXXX..XXXXXXX 100644
40
--- a/include/net/vhost_net.h
41
+++ b/include/net/vhost_net.h
42
@@ -XXX,XX +XXX,XX @@
43
#include "net/net.h"
44
#include "hw/virtio/vhost-backend.h"
45
46
-#define VHOST_NET_INIT_FAILED \
47
- "vhost-net requested but could not be initialized"
48
-
49
struct vhost_net;
50
typedef struct vhost_net VHostNetState;
51
14
diff --git a/net/tap.c b/net/tap.c
52
diff --git a/net/tap.c b/net/tap.c
15
index XXXXXXX..XXXXXXX 100644
53
index XXXXXXX..XXXXXXX 100644
16
--- a/net/tap.c
54
--- a/net/tap.c
17
+++ b/net/tap.c
55
+++ b/net/tap.c
18
@@ -XXX,XX +XXX,XX @@ int net_init_tap(const Netdev *netdev, const char *name,
56
@@ -XXX,XX +XXX,XX @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
19
if (ret < 0) {
57
if (vhostfdname) {
20
error_setg_errno(errp, -ret, "%s: Can't use file descriptor %d",
58
vhostfd = monitor_fd_param(monitor_cur(), vhostfdname, &err);
21
name, fd);
59
if (vhostfd == -1) {
22
+ close(fd);
60
- if (tap->has_vhostforce && tap->vhostforce) {
23
return -1;
61
- error_propagate(errp, err);
62
- } else {
63
- warn_report_err(err);
64
- }
65
+ error_propagate(errp, err);
66
goto failed;
67
}
68
if (!g_unix_set_fd_nonblocking(vhostfd, true, NULL)) {
69
@@ -XXX,XX +XXX,XX @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
70
} else {
71
vhostfd = open("/dev/vhost-net", O_RDWR);
72
if (vhostfd < 0) {
73
- if (tap->has_vhostforce && tap->vhostforce) {
74
- error_setg_errno(errp, errno,
75
- "tap: open vhost char device failed");
76
- } else {
77
- warn_report("tap: open vhost char device failed: %s",
78
- strerror(errno));
79
- }
80
+ error_setg_errno(errp, errno,
81
+ "tap: open vhost char device failed");
82
goto failed;
83
}
84
if (!g_unix_set_fd_nonblocking(vhostfd, true, NULL)) {
85
@@ -XXX,XX +XXX,XX @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
86
87
s->vhost_net = vhost_net_init(&options);
88
if (!s->vhost_net) {
89
- if (tap->has_vhostforce && tap->vhostforce) {
90
- error_setg(errp, VHOST_NET_INIT_FAILED);
91
- } else {
92
- warn_report(VHOST_NET_INIT_FAILED);
93
- }
94
+ error_setg(errp,
95
+ "vhost-net requested but could not be initialized");
96
goto failed;
24
}
97
}
25
98
} else if (vhostfdname) {
26
@@ -XXX,XX +XXX,XX @@ int net_init_tap(const Netdev *netdev, const char *name,
27
vhostfdname, vnet_hdr, fd, &err);
28
if (err) {
29
error_propagate(errp, err);
30
+ close(fd);
31
return -1;
32
}
33
} else if (tap->has_fds) {
34
--
99
--
35
2.7.4
100
2.42.0
36
37
diff view generated by jsdifflib