1
The following changes since commit 23895cbd82be95428e90168b12e925d0d3ca2f06:
1
The following changes since commit 99d6b11b5b44d7dd64f4cb1973184e40a4a174f8:
2
2
3
Merge remote-tracking branch 'remotes/awilliam/tags/vfio-update-20201123.0' into staging (2020-11-23 18:51:13 +0000)
3
Merge tag 'pull-target-arm-20220922' of https://git.linaro.org/people/pmaydell/qemu-arm into staging (2022-09-26 13:38:26 -0400)
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 bf769f742c3624952f125b303878a77ea870c156:
10
10
11
net: Use correct default-path macro for downscript (2020-11-24 10:40:17 +0800)
11
virtio: del net client if net_init_tap_one failed (2022-09-27 15:14:37 +0800)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
14
15
----------------------------------------------------------------
15
----------------------------------------------------------------
16
Keqian Zhu (1):
16
Ding Hui (1):
17
net: Use correct default-path macro for downscript
17
e1000e: set RX desc status with DD flag in a separate operation
18
18
19
Paolo Bonzini (1):
19
Eugenio Pérez (6):
20
net: do not exit on "netdev_add help" monitor command
20
vdpa: Make VhostVDPAState cvq_cmd_in_buffer control ack type
21
vdpa: extract vhost_vdpa_net_load_mac from vhost_vdpa_net_load
22
vdpa: Add vhost_vdpa_net_load_mq
23
vdpa: validate MQ CVQ commands
24
virtio-net: Update virtio-net curr_queue_pairs in vdpa backends
25
vdpa: Allow MQ feature in SVQ
21
26
22
Prasad J Pandit (1):
27
lu zhipeng (1):
23
hw/net/e1000e: advance desc_offset in case of null descriptor
28
virtio: del net client if net_init_tap_one failed
24
29
25
Yuri Benditovich (1):
30
hw/net/e1000e_core.c | 53 ++++++++++++++++++++++-
26
net: purge queued rx packets on queue deletion
31
hw/net/virtio-net.c | 17 +++-----
32
net/tap.c | 18 +++++---
33
net/vhost-vdpa.c | 119 +++++++++++++++++++++++++++++++++++++--------------
34
4 files changed, 157 insertions(+), 50 deletions(-)
27
35
28
yuanjungong (1):
36
Ding Hui (1):
29
tap: fix a memory leak
37
e1000e: set RX desc status with DD flag in a separate operation
30
38
31
hw/net/e1000e_core.c | 8 +++---
39
Eugenio Pérez (6):
32
include/net/net.h | 1 +
40
vdpa: Make VhostVDPAState cvq_cmd_in_buffer control ack type
33
monitor/hmp-cmds.c | 6 ++++
41
vdpa: extract vhost_vdpa_net_load_mac from vhost_vdpa_net_load
34
net/net.c | 80 +++++++++++++++++++++++++++-------------------------
42
vdpa: Add vhost_vdpa_net_load_mq
35
net/tap.c | 5 +++-
43
vdpa: validate MQ CVQ commands
36
5 files changed, 57 insertions(+), 43 deletions(-)
44
virtio-net: Update virtio-net curr_queue_pairs in vdpa backends
45
vdpa: Allow MQ feature in SVQ
46
47
lu zhipeng (1):
48
virtio: del net client if net_init_tap_one failed
49
50
hw/net/e1000e_core.c | 53 ++++++++++++++++++++++-
51
hw/net/virtio-net.c | 17 +++-----
52
net/tap.c | 18 +++++---
53
net/vhost-vdpa.c | 119 +++++++++++++++++++++++++++++++++++++--------------
54
4 files changed, 157 insertions(+), 50 deletions(-)
55
56
--
57
2.7.4
37
58
38
59
diff view generated by jsdifflib
1
From: Prasad J Pandit <pjp@fedoraproject.org>
1
From: Ding Hui <dinghui@sangfor.com.cn>
2
2
3
While receiving packets via e1000e_write_packet_to_guest() routine,
3
Like commit 034d00d48581 ("e1000: set RX descriptor status in
4
'desc_offset' is advanced only when RX descriptor is processed. And
4
a separate operation"), there is also same issue in e1000e, which
5
RX descriptor is not processed if it has NULL buffer address.
5
would cause lost packets or stop sending packets to VM with DPDK.
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
6
9
Reported-by: Cheol-woo Myung <330cjfdn@gmail.com>
7
Do similar fix in e1000e.
10
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
8
9
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/402
10
Signed-off-by: Ding Hui <dinghui@sangfor.com.cn>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
12
---
12
---
13
hw/net/e1000e_core.c | 8 ++++----
13
hw/net/e1000e_core.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++-
14
1 file changed, 4 insertions(+), 4 deletions(-)
14
1 file changed, 52 insertions(+), 1 deletion(-)
15
15
16
diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
16
diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
17
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/net/e1000e_core.c
18
--- a/hw/net/e1000e_core.c
19
+++ b/hw/net/e1000e_core.c
19
+++ b/hw/net/e1000e_core.c
20
@@ -XXX,XX +XXX,XX @@ struct NetRxPkt *pkt, const E1000E_RSSInfo *rss_info,
21
}
22
}
23
24
+static inline void
25
+e1000e_pci_dma_write_rx_desc(E1000ECore *core, dma_addr_t addr,
26
+ uint8_t *desc, dma_addr_t len)
27
+{
28
+ PCIDevice *dev = core->owner;
29
+
30
+ if (e1000e_rx_use_legacy_descriptor(core)) {
31
+ struct e1000_rx_desc *d = (struct e1000_rx_desc *) desc;
32
+ size_t offset = offsetof(struct e1000_rx_desc, status);
33
+ uint8_t status = d->status;
34
+
35
+ d->status &= ~E1000_RXD_STAT_DD;
36
+ pci_dma_write(dev, addr, desc, len);
37
+
38
+ if (status & E1000_RXD_STAT_DD) {
39
+ d->status = status;
40
+ pci_dma_write(dev, addr + offset, &status, sizeof(status));
41
+ }
42
+ } else {
43
+ if (core->mac[RCTL] & E1000_RCTL_DTYP_PS) {
44
+ union e1000_rx_desc_packet_split *d =
45
+ (union e1000_rx_desc_packet_split *) desc;
46
+ size_t offset = offsetof(union e1000_rx_desc_packet_split,
47
+ wb.middle.status_error);
48
+ uint32_t status = d->wb.middle.status_error;
49
+
50
+ d->wb.middle.status_error &= ~E1000_RXD_STAT_DD;
51
+ pci_dma_write(dev, addr, desc, len);
52
+
53
+ if (status & E1000_RXD_STAT_DD) {
54
+ d->wb.middle.status_error = status;
55
+ pci_dma_write(dev, addr + offset, &status, sizeof(status));
56
+ }
57
+ } else {
58
+ union e1000_rx_desc_extended *d =
59
+ (union e1000_rx_desc_extended *) desc;
60
+ size_t offset = offsetof(union e1000_rx_desc_extended,
61
+ wb.upper.status_error);
62
+ uint32_t status = d->wb.upper.status_error;
63
+
64
+ d->wb.upper.status_error &= ~E1000_RXD_STAT_DD;
65
+ pci_dma_write(dev, addr, desc, len);
66
+
67
+ if (status & E1000_RXD_STAT_DD) {
68
+ d->wb.upper.status_error = status;
69
+ pci_dma_write(dev, addr + offset, &status, sizeof(status));
70
+ }
71
+ }
72
+ }
73
+}
74
+
75
typedef struct e1000e_ba_state_st {
76
uint16_t written[MAX_PS_BUFFERS];
77
uint8_t cur_idx;
20
@@ -XXX,XX +XXX,XX @@ e1000e_write_packet_to_guest(E1000ECore *core, struct NetRxPkt *pkt,
78
@@ -XXX,XX +XXX,XX @@ e1000e_write_packet_to_guest(E1000ECore *core, struct NetRxPkt *pkt,
21
(const char *) &fcs_pad, e1000x_fcs_len(core->mac));
22
}
23
}
24
- desc_offset += desc_size;
25
- if (desc_offset >= total_size) {
26
- is_last = true;
27
- }
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
79
36
e1000e_write_rx_descr(core, desc, is_last ? core->rx_pkt : NULL,
80
e1000e_write_rx_descr(core, desc, is_last ? core->rx_pkt : NULL,
37
rss_info, do_ps ? ps_hdr_len : 0, &bastate.written);
81
rss_info, do_ps ? ps_hdr_len : 0, &bastate.written);
82
- pci_dma_write(d, base, &desc, core->rx_desc_len);
83
+ e1000e_pci_dma_write_rx_desc(core, base, desc, core->rx_desc_len);
84
85
e1000e_ring_advance(core, rxi,
86
core->rx_desc_len / E1000_MIN_RX_DESC_LEN);
38
--
87
--
39
2.7.4
88
2.7.4
40
41
diff view generated by jsdifflib
1
From: Paolo Bonzini <pbonzini@redhat.com>
1
From: Eugenio Pérez <eperezma@redhat.com>
2
2
3
"netdev_add help" is causing QEMU to exit because the code that
3
This allows to simplify the code. Rename to status while we're at it.
4
invokes show_netdevs is shared between CLI and HMP processing.
5
Move the check to the callers so that exit(0) remains only
6
in the CLI flow.
7
4
8
"netdev_add help" is not fixed by this patch; that is left for
5
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
9
later work.
10
11
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12
Signed-off-by: Jason Wang <jasowang@redhat.com>
6
Signed-off-by: Jason Wang <jasowang@redhat.com>
13
---
7
---
14
include/net/net.h | 1 +
8
net/vhost-vdpa.c | 23 ++++++++++++-----------
15
monitor/hmp-cmds.c | 6 +++++
9
1 file changed, 12 insertions(+), 11 deletions(-)
16
net/net.c | 68 +++++++++++++++++++++++++++---------------------------
17
3 files changed, 41 insertions(+), 34 deletions(-)
18
10
19
diff --git a/include/net/net.h b/include/net/net.h
11
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
20
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
21
--- a/include/net/net.h
13
--- a/net/vhost-vdpa.c
22
+++ b/include/net/net.h
14
+++ b/net/vhost-vdpa.c
23
@@ -XXX,XX +XXX,XX @@ extern const char *host_net_devices[];
15
@@ -XXX,XX +XXX,XX @@ typedef struct VhostVDPAState {
24
16
VHostNetState *vhost_net;
25
/* from net.c */
17
26
int net_client_parse(QemuOptsList *opts_list, const char *str);
18
/* Control commands shadow buffers */
27
+void show_netdevs(void);
19
- void *cvq_cmd_out_buffer, *cvq_cmd_in_buffer;
28
int net_init_clients(Error **errp);
20
+ void *cvq_cmd_out_buffer;
29
void net_check_clients(void);
21
+ virtio_net_ctrl_ack *status;
30
void net_cleanup(void);
22
+
31
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
23
bool started;
32
index XXXXXXX..XXXXXXX 100644
24
} VhostVDPAState;
33
--- a/monitor/hmp-cmds.c
25
34
+++ b/monitor/hmp-cmds.c
26
@@ -XXX,XX +XXX,XX @@ static void vhost_vdpa_cleanup(NetClientState *nc)
35
@@ -XXX,XX +XXX,XX @@
27
struct vhost_dev *dev = &s->vhost_net->dev;
36
#include "qemu/option.h"
28
37
#include "qemu/timer.h"
29
qemu_vfree(s->cvq_cmd_out_buffer);
38
#include "qemu/sockets.h"
30
- qemu_vfree(s->cvq_cmd_in_buffer);
39
+#include "qemu/help_option.h"
31
+ qemu_vfree(s->status);
40
#include "monitor/monitor-internal.h"
32
if (dev->vq_index + dev->nvqs == dev->vq_index_end) {
41
#include "qapi/error.h"
33
g_clear_pointer(&s->vhost_vdpa.iova_tree, vhost_iova_tree_delete);
42
#include "qapi/clone-visitor.h"
34
}
43
@@ -XXX,XX +XXX,XX @@ void hmp_netdev_add(Monitor *mon, const QDict *qdict)
35
@@ -XXX,XX +XXX,XX @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc)
44
{
36
return r;
45
Error *err = NULL;
37
}
46
QemuOpts *opts;
38
47
+ const char *type = qdict_get_try_str(qdict, "type");
39
- r = vhost_vdpa_cvq_map_buf(&s->vhost_vdpa, s->cvq_cmd_in_buffer,
48
40
+ r = vhost_vdpa_cvq_map_buf(&s->vhost_vdpa, s->status,
49
+ if (type && is_help_option(type)) {
41
vhost_vdpa_net_cvq_cmd_page_len(), true);
50
+ show_netdevs();
42
if (unlikely(r < 0)) {
51
+ return;
43
vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->cvq_cmd_out_buffer);
52
+ }
44
@@ -XXX,XX +XXX,XX @@ static void vhost_vdpa_net_cvq_stop(NetClientState *nc)
53
opts = qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict, &err);
45
54
if (err) {
46
if (s->vhost_vdpa.shadow_vqs_enabled) {
55
goto out;
47
vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->cvq_cmd_out_buffer);
56
diff --git a/net/net.c b/net/net.c
48
- vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->cvq_cmd_in_buffer);
57
index XXXXXXX..XXXXXXX 100644
49
+ vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->status);
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
}
50
}
87
}
51
}
88
52
89
@@ -XXX,XX +XXX,XX @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
53
@@ -XXX,XX +XXX,XX @@ static ssize_t vhost_vdpa_net_cvq_add(VhostVDPAState *s, size_t out_len,
90
int ret = -1;
54
.iov_len = out_len,
91
Visitor *v = opts_visitor_new(opts);
55
};
92
56
const struct iovec in = {
93
- const char *type = qemu_opt_get(opts, "type");
57
- .iov_base = s->cvq_cmd_in_buffer,
94
-
58
+ .iov_base = s->status,
95
- if (is_netdev && type && is_help_option(type)) {
59
.iov_len = sizeof(virtio_net_ctrl_ack),
96
- show_netdevs();
60
};
97
- exit(0);
61
VhostShadowVirtqueue *svq = g_ptr_array_index(s->vhost_vdpa.shadow_vqs, 0);
98
- } else {
62
@@ -XXX,XX +XXX,XX @@ static int vhost_vdpa_net_load(NetClientState *nc)
99
- /* Parse convenience option format ip6-net=fec0::0[/64] */
63
return dev_written;
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
-
136
- qemu_opt_set(opts, "ipv6-prefix", prefix_addr, &error_abort);
137
- qemu_opt_set_number(opts, "ipv6-prefixlen", prefix_len,
138
- &error_abort);
139
- qemu_opt_unset(opts, "ipv6-net");
140
+ /* Handle user-specified prefix length. */
141
+ if (substrings[1] &&
142
+ qemu_strtoul(substrings[1], NULL, 10, &prefix_len))
143
+ {
144
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
145
+ "ipv6-prefixlen", "a number");
146
+ goto out;
147
}
64
}
148
+
65
149
+ qemu_opt_set(opts, "ipv6-prefix", prefix_addr, &error_abort);
66
- return *((virtio_net_ctrl_ack *)s->cvq_cmd_in_buffer) != VIRTIO_NET_OK;
150
+ qemu_opt_set_number(opts, "ipv6-prefixlen", prefix_len,
67
+ return *s->status != VIRTIO_NET_OK;
151
+ &error_abort);
152
+ qemu_opt_unset(opts, "ipv6-net");
153
}
68
}
154
69
155
/* Create an ID for -net if the user did not specify one */
70
return 0;
156
@@ -XXX,XX +XXX,XX @@ static int net_init_client(void *dummy, QemuOpts *opts, Error **errp)
71
@@ -XXX,XX +XXX,XX @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShadowVirtqueue *svq,
157
72
goto out;
158
static int net_init_netdev(void *dummy, QemuOpts *opts, Error **errp)
73
}
159
{
74
160
+ const char *type = qemu_opt_get(opts, "type");
75
- memcpy(&status, s->cvq_cmd_in_buffer, sizeof(status));
161
+
76
- if (status != VIRTIO_NET_OK) {
162
+ if (type && is_help_option(type)) {
77
+ if (*s->status != VIRTIO_NET_OK) {
163
+ show_netdevs();
78
return VIRTIO_NET_ERR;
164
+ exit(0);
79
}
165
+ }
80
166
return net_client_init(opts, true, errp);
81
@@ -XXX,XX +XXX,XX @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
167
}
82
s->cvq_cmd_out_buffer = qemu_memalign(qemu_real_host_page_size(),
168
83
vhost_vdpa_net_cvq_cmd_page_len());
84
memset(s->cvq_cmd_out_buffer, 0, vhost_vdpa_net_cvq_cmd_page_len());
85
- s->cvq_cmd_in_buffer = qemu_memalign(qemu_real_host_page_size(),
86
- vhost_vdpa_net_cvq_cmd_page_len());
87
- memset(s->cvq_cmd_in_buffer, 0, vhost_vdpa_net_cvq_cmd_page_len());
88
+ s->status = qemu_memalign(qemu_real_host_page_size(),
89
+ vhost_vdpa_net_cvq_cmd_page_len());
90
+ memset(s->status, 0, vhost_vdpa_net_cvq_cmd_page_len());
91
92
s->vhost_vdpa.shadow_vq_ops = &vhost_vdpa_net_svq_ops;
93
s->vhost_vdpa.shadow_vq_ops_opaque = s;
169
--
94
--
170
2.7.4
95
2.7.4
171
96
172
97
diff view generated by jsdifflib
New patch
1
From: Eugenio Pérez <eperezma@redhat.com>
1
2
3
Since there may be many commands we need to issue to load the NIC
4
state, let's split them in individual functions
5
6
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
7
Signed-off-by: Jason Wang <jasowang@redhat.com>
8
---
9
net/vhost-vdpa.c | 62 ++++++++++++++++++++++++++++++++++++--------------------
10
1 file changed, 40 insertions(+), 22 deletions(-)
11
12
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/net/vhost-vdpa.c
15
+++ b/net/vhost-vdpa.c
16
@@ -XXX,XX +XXX,XX @@ static ssize_t vhost_vdpa_net_cvq_add(VhostVDPAState *s, size_t out_len,
17
return vhost_svq_poll(svq);
18
}
19
20
+static ssize_t vhost_vdpa_net_load_cmd(VhostVDPAState *s, uint8_t class,
21
+ uint8_t cmd, const void *data,
22
+ size_t data_size)
23
+{
24
+ const struct virtio_net_ctrl_hdr ctrl = {
25
+ .class = class,
26
+ .cmd = cmd,
27
+ };
28
+
29
+ assert(data_size < vhost_vdpa_net_cvq_cmd_page_len() - sizeof(ctrl));
30
+
31
+ memcpy(s->cvq_cmd_out_buffer, &ctrl, sizeof(ctrl));
32
+ memcpy(s->cvq_cmd_out_buffer + sizeof(ctrl), data, data_size);
33
+
34
+ return vhost_vdpa_net_cvq_add(s, sizeof(ctrl) + data_size,
35
+ sizeof(virtio_net_ctrl_ack));
36
+}
37
+
38
+static int vhost_vdpa_net_load_mac(VhostVDPAState *s, const VirtIONet *n)
39
+{
40
+ uint64_t features = n->parent_obj.guest_features;
41
+ if (features & BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR)) {
42
+ ssize_t dev_written = vhost_vdpa_net_load_cmd(s, VIRTIO_NET_CTRL_MAC,
43
+ VIRTIO_NET_CTRL_MAC_ADDR_SET,
44
+ n->mac, sizeof(n->mac));
45
+ if (unlikely(dev_written < 0)) {
46
+ return dev_written;
47
+ }
48
+
49
+ return *s->status != VIRTIO_NET_OK;
50
+ }
51
+
52
+ return 0;
53
+}
54
+
55
static int vhost_vdpa_net_load(NetClientState *nc)
56
{
57
VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc);
58
- const struct vhost_vdpa *v = &s->vhost_vdpa;
59
+ struct vhost_vdpa *v = &s->vhost_vdpa;
60
const VirtIONet *n;
61
- uint64_t features;
62
+ int r;
63
64
assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_VDPA);
65
66
@@ -XXX,XX +XXX,XX @@ static int vhost_vdpa_net_load(NetClientState *nc)
67
}
68
69
n = VIRTIO_NET(v->dev->vdev);
70
- features = n->parent_obj.guest_features;
71
- if (features & BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR)) {
72
- const struct virtio_net_ctrl_hdr ctrl = {
73
- .class = VIRTIO_NET_CTRL_MAC,
74
- .cmd = VIRTIO_NET_CTRL_MAC_ADDR_SET,
75
- };
76
- char *cursor = s->cvq_cmd_out_buffer;
77
- ssize_t dev_written;
78
-
79
- memcpy(cursor, &ctrl, sizeof(ctrl));
80
- cursor += sizeof(ctrl);
81
- memcpy(cursor, n->mac, sizeof(n->mac));
82
-
83
- dev_written = vhost_vdpa_net_cvq_add(s, sizeof(ctrl) + sizeof(n->mac),
84
- sizeof(virtio_net_ctrl_ack));
85
- if (unlikely(dev_written < 0)) {
86
- return dev_written;
87
- }
88
-
89
- return *s->status != VIRTIO_NET_OK;
90
+ r = vhost_vdpa_net_load_mac(s, n);
91
+ if (unlikely(r < 0)) {
92
+ return r;
93
}
94
95
return 0;
96
--
97
2.7.4
98
99
diff view generated by jsdifflib
New patch
1
From: Eugenio Pérez <eperezma@redhat.com>
1
2
3
Same way as with the MAC, restore the expected number of queues at
4
device's start.
5
6
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
7
Signed-off-by: Jason Wang <jasowang@redhat.com>
8
---
9
net/vhost-vdpa.c | 26 ++++++++++++++++++++++++++
10
1 file changed, 26 insertions(+)
11
12
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/net/vhost-vdpa.c
15
+++ b/net/vhost-vdpa.c
16
@@ -XXX,XX +XXX,XX @@ static int vhost_vdpa_net_load_mac(VhostVDPAState *s, const VirtIONet *n)
17
return 0;
18
}
19
20
+static int vhost_vdpa_net_load_mq(VhostVDPAState *s,
21
+ const VirtIONet *n)
22
+{
23
+ struct virtio_net_ctrl_mq mq;
24
+ uint64_t features = n->parent_obj.guest_features;
25
+ ssize_t dev_written;
26
+
27
+ if (!(features & BIT_ULL(VIRTIO_NET_F_MQ))) {
28
+ return 0;
29
+ }
30
+
31
+ mq.virtqueue_pairs = cpu_to_le16(n->curr_queue_pairs);
32
+ dev_written = vhost_vdpa_net_load_cmd(s, VIRTIO_NET_CTRL_MQ,
33
+ VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET, &mq,
34
+ sizeof(mq));
35
+ if (unlikely(dev_written < 0)) {
36
+ return dev_written;
37
+ }
38
+
39
+ return *s->status != VIRTIO_NET_OK;
40
+}
41
+
42
static int vhost_vdpa_net_load(NetClientState *nc)
43
{
44
VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc);
45
@@ -XXX,XX +XXX,XX @@ static int vhost_vdpa_net_load(NetClientState *nc)
46
if (unlikely(r < 0)) {
47
return r;
48
}
49
+ r = vhost_vdpa_net_load_mq(s, n);
50
+ if (unlikely(r)) {
51
+ return r;
52
+ }
53
54
return 0;
55
}
56
--
57
2.7.4
58
59
diff view generated by jsdifflib
New patch
1
From: Eugenio Pérez <eperezma@redhat.com>
1
2
3
So we are sure we can update the device model properly before sending to
4
the device.
5
6
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
7
Signed-off-by: Jason Wang <jasowang@redhat.com>
8
---
9
net/vhost-vdpa.c | 9 +++++++++
10
1 file changed, 9 insertions(+)
11
12
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/net/vhost-vdpa.c
15
+++ b/net/vhost-vdpa.c
16
@@ -XXX,XX +XXX,XX @@ static bool vhost_vdpa_net_cvq_validate_cmd(const void *out_buf, size_t len)
17
__func__, ctrl.cmd);
18
};
19
break;
20
+ case VIRTIO_NET_CTRL_MQ:
21
+ switch (ctrl.cmd) {
22
+ case VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET:
23
+ return true;
24
+ default:
25
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid mq cmd %u\n",
26
+ __func__, ctrl.cmd);
27
+ };
28
+ break;
29
default:
30
qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid control class %u\n",
31
__func__, ctrl.class);
32
--
33
2.7.4
34
35
diff view generated by jsdifflib
1
From: Yuri Benditovich <yuri.benditovich@daynix.com>
1
From: Eugenio Pérez <eperezma@redhat.com>
2
2
3
https://bugzilla.redhat.com/show_bug.cgi?id=1829272
3
It was returned as error before. Instead of it, simply update the
4
When deleting queue pair, purge pending RX packets if any.
4
corresponding field so qemu can send it in the migration data.
5
Example of problematic flow:
6
1. Bring up q35 VM with tap (vhost off) and virtio-net or e1000e
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
5
15
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
6
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
7
Acked-by: Si-Wei Liu <si-wei.liu@oracle.com>
16
Signed-off-by: Jason Wang <jasowang@redhat.com>
8
Signed-off-by: Jason Wang <jasowang@redhat.com>
17
---
9
---
18
net/net.c | 12 ++++++++----
10
hw/net/virtio-net.c | 17 ++++++-----------
19
1 file changed, 8 insertions(+), 4 deletions(-)
11
1 file changed, 6 insertions(+), 11 deletions(-)
20
12
21
diff --git a/net/net.c b/net/net.c
13
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
22
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
23
--- a/net/net.c
15
--- a/hw/net/virtio-net.c
24
+++ b/net/net.c
16
+++ b/hw/net/virtio-net.c
25
@@ -XXX,XX +XXX,XX @@ void qemu_del_nic(NICState *nic)
17
@@ -XXX,XX +XXX,XX @@ static int virtio_net_handle_mq(VirtIONet *n, uint8_t cmd,
26
18
return VIRTIO_NET_ERR;
27
qemu_macaddr_set_free(&nic->conf->macaddr);
28
29
- /* If this is a peer NIC and peer has already been deleted, free it now. */
30
- if (nic->peer_deleted) {
31
- for (i = 0; i < queues; i++) {
32
- qemu_free_net_client(qemu_get_subqueue(nic, i)->peer);
33
+ for (i = 0; i < queues; i++) {
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
}
19
}
43
20
21
- /* Avoid changing the number of queue_pairs for vdpa device in
22
- * userspace handler. A future fix is needed to handle the mq
23
- * change in userspace handler with vhost-vdpa. Let's disable
24
- * the mq handling from userspace for now and only allow get
25
- * done through the kernel. Ripples may be seen when falling
26
- * back to userspace, but without doing it qemu process would
27
- * crash on a recursive entry to virtio_net_set_status().
28
- */
29
+ n->curr_queue_pairs = queue_pairs;
30
if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) {
31
- return VIRTIO_NET_ERR;
32
+ /*
33
+ * Avoid updating the backend for a vdpa device: We're only interested
34
+ * in updating the device model queues.
35
+ */
36
+ return VIRTIO_NET_OK;
37
}
38
-
39
- n->curr_queue_pairs = queue_pairs;
40
/* stop the backend before changing the number of queue_pairs to avoid handling a
41
* disabled queue */
42
virtio_net_set_status(vdev, vdev->status);
44
--
43
--
45
2.7.4
44
2.7.4
46
45
47
46
diff view generated by jsdifflib
1
From: Keqian Zhu <zhukeqian1@huawei.com>
1
From: Eugenio Pérez <eperezma@redhat.com>
2
2
3
Fixes: 63c4db4c2e6d (net: relocate paths to helpers and scripts)
3
Finally enable SVQ with MQ feature.
4
Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
4
5
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
5
Signed-off-by: Jason Wang <jasowang@redhat.com>
6
Signed-off-by: Jason Wang <jasowang@redhat.com>
6
---
7
---
7
net/tap.c | 3 ++-
8
net/vhost-vdpa.c | 1 +
8
1 file changed, 2 insertions(+), 1 deletion(-)
9
1 file changed, 1 insertion(+)
9
10
10
diff --git a/net/tap.c b/net/tap.c
11
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
11
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
12
--- a/net/tap.c
13
--- a/net/vhost-vdpa.c
13
+++ b/net/tap.c
14
+++ b/net/vhost-vdpa.c
14
@@ -XXX,XX +XXX,XX @@ free_fail:
15
@@ -XXX,XX +XXX,XX @@ static const uint64_t vdpa_svq_device_features =
15
script = default_script = get_relocated_path(DEFAULT_NETWORK_SCRIPT);
16
BIT_ULL(VIRTIO_NET_F_MRG_RXBUF) |
16
}
17
BIT_ULL(VIRTIO_NET_F_STATUS) |
17
if (!downscript) {
18
BIT_ULL(VIRTIO_NET_F_CTRL_VQ) |
18
- downscript = default_downscript = get_relocated_path(DEFAULT_NETWORK_SCRIPT);
19
+ BIT_ULL(VIRTIO_NET_F_MQ) |
19
+ downscript = default_downscript =
20
BIT_ULL(VIRTIO_F_ANY_LAYOUT) |
20
+ get_relocated_path(DEFAULT_NETWORK_DOWN_SCRIPT);
21
BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR) |
21
}
22
BIT_ULL(VIRTIO_NET_F_RSC_EXT) |
22
23
if (tap->has_ifname) {
24
--
23
--
25
2.7.4
24
2.7.4
26
25
27
26
diff view generated by jsdifflib
1
From: yuanjungong <ruc_gongyuanjun@163.com>
1
From: lu zhipeng <luzhipeng@cestc.cn>
2
2
3
Close fd before returning.
3
If the net tap initializes successful, but failed during
4
network card hot-plugging, the net-tap will remains,
5
so cleanup.
4
6
5
Buglink: https://bugs.launchpad.net/qemu/+bug/1904486
7
Signed-off-by: lu zhipeng <luzhipeng@cestc.cn>
6
7
Signed-off-by: yuanjungong <ruc_gongyuanjun@163.com>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Jason Wang <jasowang@redhat.com>
8
Signed-off-by: Jason Wang <jasowang@redhat.com>
10
---
9
---
11
net/tap.c | 2 ++
10
net/tap.c | 18 ++++++++++++------
12
1 file changed, 2 insertions(+)
11
1 file changed, 12 insertions(+), 6 deletions(-)
13
12
14
diff --git a/net/tap.c b/net/tap.c
13
diff --git a/net/tap.c b/net/tap.c
15
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
16
--- a/net/tap.c
15
--- a/net/tap.c
17
+++ b/net/tap.c
16
+++ b/net/tap.c
18
@@ -XXX,XX +XXX,XX @@ int net_init_tap(const Netdev *netdev, const char *name,
17
@@ -XXX,XX +XXX,XX @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
19
if (ret < 0) {
18
tap_set_sndbuf(s->fd, tap, &err);
20
error_setg_errno(errp, -ret, "%s: Can't use file descriptor %d",
19
if (err) {
21
name, fd);
20
error_propagate(errp, err);
22
+ close(fd);
21
- return;
23
return -1;
22
+ goto failed;
23
}
24
25
if (tap->has_fd || tap->has_fds) {
26
@@ -XXX,XX +XXX,XX @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
27
} else {
28
warn_report_err(err);
29
}
30
- return;
31
+ goto failed;
32
}
33
if (!g_unix_set_fd_nonblocking(vhostfd, true, NULL)) {
34
error_setg_errno(errp, errno, "%s: Can't use file descriptor %d",
35
name, fd);
36
- return;
37
+ goto failed;
38
}
39
} else {
40
vhostfd = open("/dev/vhost-net", O_RDWR);
41
@@ -XXX,XX +XXX,XX @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
42
warn_report("tap: open vhost char device failed: %s",
43
strerror(errno));
44
}
45
- return;
46
+ goto failed;
47
}
48
if (!g_unix_set_fd_nonblocking(vhostfd, true, NULL)) {
49
error_setg_errno(errp, errno, "Failed to set FD nonblocking");
50
- return;
51
+ goto failed;
52
}
24
}
53
}
25
54
options.opaque = (void *)(uintptr_t)vhostfd;
26
@@ -XXX,XX +XXX,XX @@ int net_init_tap(const Netdev *netdev, const char *name,
55
@@ -XXX,XX +XXX,XX @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
27
vhostfdname, vnet_hdr, fd, &err);
56
} else {
28
if (err) {
57
warn_report(VHOST_NET_INIT_FAILED);
29
error_propagate(errp, err);
58
}
30
+ close(fd);
59
- return;
31
return -1;
60
+ goto failed;
32
}
61
}
33
} else if (tap->has_fds) {
62
} else if (vhostfdname) {
63
error_setg(errp, "vhostfd(s)= is not valid without vhost");
64
+ goto failed;
65
}
66
+
67
+ return;
68
+
69
+failed:
70
+ qemu_del_net_client(&s->nc);
71
}
72
73
static int get_fds(char *str, char *fds[], int max)
34
--
74
--
35
2.7.4
75
2.7.4
36
37
diff view generated by jsdifflib