1
The following changes since commit 23895cbd82be95428e90168b12e925d0d3ca2f06:
1
The following changes since commit d0d3dd401b70168a353450e031727affee828527:
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 v6.0.0-rc2 release (2021-04-06 18:34:34 +0100)
4
4
5
are available in the git repository at:
5
are available in the git repository at:
6
6
7
https://github.com/jasowang/qemu.git tags/net-pull-request
7
https://github.com/jasowang/qemu.git tags/net-pull-request
8
8
9
for you to fetch changes up to 9925990d01a92564af55f6f69d0f5f59b47609b1:
9
for you to fetch changes up to 21df394d9e2ffce9fa308f496d1ae228cf6cdb57:
10
10
11
net: Use correct default-path macro for downscript (2020-11-24 10:40:17 +0800)
11
tap-win32: correctly recycle buffers (2021-04-08 17:33:59 +0800)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
14
15
----------------------------------------------------------------
15
Fixes for rc3:
16
Keqian Zhu (1):
17
net: Use correct default-path macro for downscript
18
16
19
Paolo Bonzini (1):
17
- query-netdev is reverted (that's why the changeset is huge)
20
net: do not exit on "netdev_add help" monitor command
18
- fix a regression caused by padding for in TAP for win32
21
22
Prasad J Pandit (1):
23
hw/net/e1000e: advance desc_offset in case of null descriptor
24
25
Yuri Benditovich (1):
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
19
38
20
21
----------------------------------------------------------------
22
Jason Wang (6):
23
Revert "net: Do not fill legacy info_str for backends"
24
Revert "hmp: Use QAPI NetdevInfo in hmp_info_network"
25
Revert "net: Move NetClientState.info_str to dynamic allocations"
26
Revert "tests: Add tests for query-netdev command"
27
Revert "qapi: net: Add query-netdev command"
28
tap-win32: correctly recycle buffers
29
30
hw/net/xen_nic.c | 5 +-
31
include/net/net.h | 5 +-
32
include/qapi/hmp-output-visitor.h | 30 ------
33
net/l2tpv3.c | 8 +-
34
net/net.c | 73 ++------------
35
net/netmap.c | 7 --
36
net/slirp.c | 124 +-----------------------
37
net/socket.c | 92 +++++-------------
38
net/tap-win32.c | 16 ++--
39
net/tap.c | 107 +++------------------
40
net/vde.c | 25 +----
41
net/vhost-user.c | 20 +---
42
net/vhost-vdpa.c | 15 +--
43
qapi/hmp-output-visitor.c | 193 --------------------------------------
44
qapi/meson.build | 1 -
45
qapi/net.json | 80 ----------------
46
tests/qtest/meson.build | 3 -
47
tests/qtest/test-query-netdev.c | 120 ------------------------
48
18 files changed, 66 insertions(+), 858 deletions(-)
49
delete mode 100644 include/qapi/hmp-output-visitor.h
50
delete mode 100644 qapi/hmp-output-visitor.c
51
delete mode 100644 tests/qtest/test-query-netdev.c
52
53
54
diff view generated by jsdifflib
1
From: yuanjungong <ruc_gongyuanjun@163.com>
1
Several issues has been reported for query-netdev info
2
2
series. Consider it's late in the rc, this reverts commit
3
Close fd before returning.
3
f2e8319d456724c3d8514d943dc4607e2f08e88a.
4
4
5
Buglink: https://bugs.launchpad.net/qemu/+bug/1904486
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>
5
Signed-off-by: Jason Wang <jasowang@redhat.com>
10
---
6
---
11
net/tap.c | 2 ++
7
net/l2tpv3.c | 2 ++
12
1 file changed, 2 insertions(+)
8
net/slirp.c | 3 +++
13
9
net/socket.c | 28 ++++++++++++++++++++++++++++
10
net/tap-win32.c | 2 ++
11
net/tap.c | 9 +++++++++
12
net/vde.c | 2 ++
13
net/vhost-user.c | 1 +
14
net/vhost-vdpa.c | 1 +
15
8 files changed, 48 insertions(+)
16
17
diff --git a/net/l2tpv3.c b/net/l2tpv3.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/net/l2tpv3.c
20
+++ b/net/l2tpv3.c
21
@@ -XXX,XX +XXX,XX @@ int net_init_l2tpv3(const Netdev *netdev,
22
23
QAPI_CLONE_MEMBERS(NetdevL2TPv3Options,
24
&nc->stored_config->u.l2tpv3, l2tpv3);
25
+
26
+ s->nc.info_str = g_strdup_printf("l2tpv3: connected");
27
return 0;
28
outerr:
29
qemu_del_net_client(nc);
30
diff --git a/net/slirp.c b/net/slirp.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/net/slirp.c
33
+++ b/net/slirp.c
34
@@ -XXX,XX +XXX,XX @@ static int net_slirp_init(NetClientState *peer, const char *model,
35
stored->tftp_server_name = g_strdup(tftp_server_name);
36
}
37
38
+ nc->info_str = g_strdup_printf("net=%s,restrict=%s", inet_ntoa(net),
39
+ restricted ? "on" : "off");
40
+
41
s = DO_UPCAST(SlirpState, nc, nc);
42
43
s->slirp = slirp_init(restricted, ipv4, net, mask, host,
44
diff --git a/net/socket.c b/net/socket.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/net/socket.c
47
+++ b/net/socket.c
48
@@ -XXX,XX +XXX,XX @@ static void net_socket_send(void *opaque)
49
s->fd = -1;
50
net_socket_rs_init(&s->rs, net_socket_rs_finalize, false);
51
s->nc.link_down = true;
52
+ g_free(s->nc.info_str);
53
+ s->nc.info_str = g_new0(char, 1);
54
55
return;
56
}
57
@@ -XXX,XX +XXX,XX @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer,
58
stored->mcast = g_strdup(mcast);
59
60
s->dgram_dst = saddr;
61
+ nc->info_str = g_strdup_printf("socket: fd=%d (cloned mcast=%s:%d)",
62
+ fd, inet_ntoa(saddr.sin_addr),
63
+ ntohs(saddr.sin_port));
64
} else {
65
if (sa_type == SOCKET_ADDRESS_TYPE_UNIX) {
66
s->dgram_dst.sin_family = AF_UNIX;
67
}
68
+
69
+ nc->info_str = g_strdup_printf("socket: fd=%d %s",
70
+ fd, SocketAddressType_str(sa_type));
71
}
72
73
return s;
74
@@ -XXX,XX +XXX,XX @@ static NetSocketState *net_socket_fd_init_stream(NetClientState *peer,
75
76
nc = qemu_new_net_client(&net_socket_info, peer, model, name);
77
78
+ nc->info_str = g_strdup_printf("socket: fd=%d", fd);
79
+
80
s = DO_UPCAST(NetSocketState, nc, nc);
81
82
s->fd = fd;
83
@@ -XXX,XX +XXX,XX @@ static void net_socket_accept(void *opaque)
84
85
stored->has_fd = true;
86
stored->fd = g_strdup_printf("%d", fd);
87
+
88
+ g_free(s->nc.info_str);
89
+ s->nc.info_str = g_strdup_printf("socket: connection from %s:%d",
90
+ inet_ntoa(saddr.sin_addr),
91
+ ntohs(saddr.sin_port));
92
}
93
94
static int net_socket_listen_init(NetClientState *peer,
95
@@ -XXX,XX +XXX,XX @@ static int net_socket_connect_init(NetClientState *peer,
96
stored->has_connect = true;
97
stored->connect = g_strdup(host_str);
98
99
+ g_free(s->nc.info_str);
100
+ s->nc.info_str = g_strdup_printf("socket: connect to %s:%d",
101
+ inet_ntoa(saddr.sin_addr),
102
+ ntohs(saddr.sin_port));
103
return 0;
104
}
105
106
@@ -XXX,XX +XXX,XX @@ static int net_socket_mcast_init(NetClientState *peer,
107
stored->localaddr = g_strdup(localaddr_str);
108
}
109
110
+ g_free(s->nc.info_str);
111
+ s->nc.info_str = g_strdup_printf("socket: mcast=%s:%d",
112
+ inet_ntoa(saddr.sin_addr),
113
+ ntohs(saddr.sin_port));
114
return 0;
115
+
116
}
117
118
static int net_socket_udp_init(NetClientState *peer,
119
@@ -XXX,XX +XXX,XX @@ static int net_socket_udp_init(NetClientState *peer,
120
stored->has_udp = true;
121
stored->udp = g_strdup(rhost);
122
123
+ g_free(s->nc.info_str);
124
+ s->nc.info_str = g_strdup_printf("socket: udp=%s:%d",
125
+ inet_ntoa(raddr.sin_addr),
126
+ ntohs(raddr.sin_port));
127
return 0;
128
}
129
130
diff --git a/net/tap-win32.c b/net/tap-win32.c
131
index XXXXXXX..XXXXXXX 100644
132
--- a/net/tap-win32.c
133
+++ b/net/tap-win32.c
134
@@ -XXX,XX +XXX,XX @@ static int tap_win32_init(NetClientState *peer, const char *model,
135
stored->has_ifname = true;
136
stored->ifname = g_strdup(ifname);
137
138
+ s->nc.info_str = g_strdup_printf("tap: ifname=%s", ifname);
139
+
140
s->handle = handle;
141
142
qemu_add_wait_object(s->handle->tap_semaphore, tap_win32_send, s);
14
diff --git a/net/tap.c b/net/tap.c
143
diff --git a/net/tap.c b/net/tap.c
15
index XXXXXXX..XXXXXXX 100644
144
index XXXXXXX..XXXXXXX 100644
16
--- a/net/tap.c
145
--- a/net/tap.c
17
+++ b/net/tap.c
146
+++ b/net/tap.c
18
@@ -XXX,XX +XXX,XX @@ int net_init_tap(const Netdev *netdev, const char *name,
147
@@ -XXX,XX +XXX,XX @@ int net_init_bridge(const Netdev *netdev, const char *name,
19
if (ret < 0) {
148
stored->helper = g_strdup(helper);
20
error_setg_errno(errp, -ret, "%s: Can't use file descriptor %d",
149
}
21
name, fd);
150
22
+ close(fd);
151
+ s->nc.info_str = g_strdup_printf("helper=%s,br=%s", helper, br);
23
return -1;
152
+
24
}
153
return 0;
25
154
}
26
@@ -XXX,XX +XXX,XX @@ int net_init_tap(const Netdev *netdev, const char *name,
155
27
vhostfdname, vnet_hdr, fd, &err);
156
@@ -XXX,XX +XXX,XX @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
28
if (err) {
157
stored->fds = g_strdup_printf("%s:%d", stored->fds, fd);
29
error_propagate(errp, err);
158
g_free(tmp_s);
30
+ close(fd);
159
}
31
return -1;
160
+
32
}
161
+ s->nc.info_str = g_strdup_printf("fd=%d", fd);
33
} else if (tap->has_fds) {
162
} else if (tap->has_helper) {
163
if (!stored->has_helper) {
164
stored->has_helper = true;
165
@@ -XXX,XX +XXX,XX @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
166
stored->br = tap->has_br ? g_strdup(tap->br) :
167
g_strdup(DEFAULT_BRIDGE_INTERFACE);
168
}
169
+
170
+ s->nc.info_str = g_strdup_printf("helper=%s", tap->helper);
171
} else {
172
if (ifname && !stored->has_ifname) {
173
stored->has_ifname = true;
174
@@ -XXX,XX +XXX,XX @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
175
stored->downscript = g_strdup(downscript);
176
}
177
178
+ s->nc.info_str = g_strdup_printf("ifname=%s,script=%s,downscript=%s",
179
+ ifname, script, downscript);
180
+
181
if (strcmp(downscript, "no") != 0) {
182
snprintf(s->down_script, sizeof(s->down_script), "%s", downscript);
183
snprintf(s->down_script_arg, sizeof(s->down_script_arg),
184
diff --git a/net/vde.c b/net/vde.c
185
index XXXXXXX..XXXXXXX 100644
186
--- a/net/vde.c
187
+++ b/net/vde.c
188
@@ -XXX,XX +XXX,XX @@ static int net_vde_init(NetClientState *peer, const char *model,
189
190
nc = qemu_new_net_client(&net_vde_info, peer, model, name);
191
192
+ nc->info_str = g_strdup_printf("sock=%s,fd=%d", sock, vde_datafd(vde));
193
+
194
s = DO_UPCAST(VDEState, nc, nc);
195
196
s->vde = vde;
197
diff --git a/net/vhost-user.c b/net/vhost-user.c
198
index XXXXXXX..XXXXXXX 100644
199
--- a/net/vhost-user.c
200
+++ b/net/vhost-user.c
201
@@ -XXX,XX +XXX,XX @@ static int net_vhost_user_init(NetClientState *peer, const char *device,
202
user = g_new0(struct VhostUserState, 1);
203
for (i = 0; i < queues; i++) {
204
nc = qemu_new_net_client(&net_vhost_user_info, peer, device, name);
205
+ nc->info_str = g_strdup_printf("vhost-user%d to %s", i, chr->label);
206
nc->queue_index = i;
207
if (!nc0) {
208
nc0 = nc;
209
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
210
index XXXXXXX..XXXXXXX 100644
211
--- a/net/vhost-vdpa.c
212
+++ b/net/vhost-vdpa.c
213
@@ -XXX,XX +XXX,XX @@ static int net_vhost_vdpa_init(NetClientState *peer, const char *device,
214
stored->has_queues = true;
215
stored->queues = 1; /* TODO: change when support multiqueue */
216
217
+ nc->info_str = g_strdup_printf(TYPE_VHOST_VDPA);
218
nc->queue_index = 0;
219
s = DO_UPCAST(VhostVDPAState, nc, nc);
220
vdpa_device_fd = qemu_open_old(vhostdev, O_RDWR);
34
--
221
--
35
2.7.4
222
2.7.4
36
223
37
224
diff view generated by jsdifflib
1
From: Yuri Benditovich <yuri.benditovich@daynix.com>
1
Several issues has been reported for query-netdev info
2
series. Consider it's late in the rc, this reverts commit
3
a0724776c5a98a08fc946bb5a4ad16410ca64c0e.
2
4
3
https://bugzilla.redhat.com/show_bug.cgi?id=1829272
4
When deleting queue pair, purge pending RX packets if any.
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
15
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
16
Signed-off-by: Jason Wang <jasowang@redhat.com>
5
Signed-off-by: Jason Wang <jasowang@redhat.com>
17
---
6
---
18
net/net.c | 12 ++++++++----
7
include/qapi/hmp-output-visitor.h | 30 ------
19
1 file changed, 8 insertions(+), 4 deletions(-)
8
net/net.c | 31 +-----
9
qapi/hmp-output-visitor.c | 193 --------------------------------------
10
qapi/meson.build | 1 -
11
4 files changed, 1 insertion(+), 254 deletions(-)
12
delete mode 100644 include/qapi/hmp-output-visitor.h
13
delete mode 100644 qapi/hmp-output-visitor.c
20
14
15
diff --git a/include/qapi/hmp-output-visitor.h b/include/qapi/hmp-output-visitor.h
16
deleted file mode 100644
17
index XXXXXXX..XXXXXXX
18
--- a/include/qapi/hmp-output-visitor.h
19
+++ /dev/null
20
@@ -XXX,XX +XXX,XX @@
21
-/*
22
- * HMP string output Visitor
23
- *
24
- * Copyright Yandex N.V., 2021
25
- *
26
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
27
- * See the COPYING file in the top-level directory.
28
- *
29
- */
30
-
31
-#ifndef HMP_OUTPUT_VISITOR_H
32
-#define HMP_OUTPUT_VISITOR_H
33
-
34
-#include "qapi/visitor.h"
35
-
36
-typedef struct HMPOutputVisitor HMPOutputVisitor;
37
-
38
-/**
39
- * Create a HMP string output visitor for @obj
40
- *
41
- * Flattens dicts/structures, only shows arrays borders.
42
- *
43
- * Errors are not expected to happen.
44
- *
45
- * The caller is responsible for freeing the visitor with
46
- * visit_free().
47
- */
48
-Visitor *hmp_output_visitor_new(char **result);
49
-
50
-#endif
21
diff --git a/net/net.c b/net/net.c
51
diff --git a/net/net.c b/net/net.c
22
index XXXXXXX..XXXXXXX 100644
52
index XXXXXXX..XXXXXXX 100644
23
--- a/net/net.c
53
--- a/net/net.c
24
+++ b/net/net.c
54
+++ b/net/net.c
25
@@ -XXX,XX +XXX,XX @@ void qemu_del_nic(NICState *nic)
55
@@ -XXX,XX +XXX,XX @@
26
56
#include "sysemu/sysemu.h"
27
qemu_macaddr_set_free(&nic->conf->macaddr);
57
#include "net/filter.h"
28
58
#include "qapi/string-output-visitor.h"
29
- /* If this is a peer NIC and peer has already been deleted, free it now. */
59
-#include "qapi/hmp-output-visitor.h"
30
- if (nic->peer_deleted) {
60
31
- for (i = 0; i < queues; i++) {
61
/* Net bridge is currently not supported for W32. */
32
- qemu_free_net_client(qemu_get_subqueue(nic, i)->peer);
62
#if !defined(_WIN32)
33
+ for (i = 0; i < queues; i++) {
63
@@ -XXX,XX +XXX,XX @@ static void netfilter_print_info(Monitor *mon, NetFilterState *nf)
34
+ NetClientState *nc = qemu_get_subqueue(nic, i);
64
monitor_printf(mon, "\n");
35
+ /* If this is a peer NIC and peer has already been deleted, free it now. */
65
}
36
+ if (nic->peer_deleted) {
66
37
+ qemu_free_net_client(nc->peer);
67
-static char *generate_info_str(NetClientState *nc)
38
+ } else if (nc->peer) {
68
-{
39
+ /* if there are RX packets pending, complete them */
69
- NetdevInfo *ni = nc->stored_config;
40
+ qemu_purge_queued_packets(nc->peer);
70
- char *ret_out = NULL;
41
}
71
- Visitor *v;
72
-
73
- /* Use legacy field info_str for NIC and hubports */
74
- if ((nc->info->type == NET_CLIENT_DRIVER_NIC) ||
75
- (nc->info->type == NET_CLIENT_DRIVER_HUBPORT)) {
76
- return g_strdup(nc->info_str ? nc->info_str : "");
77
- }
78
-
79
- if (!ni) {
80
- return g_malloc0(1);
81
- }
82
-
83
- v = hmp_output_visitor_new(&ret_out);
84
- if (visit_type_NetdevInfo(v, "", &ni, NULL)) {
85
- visit_complete(v, &ret_out);
86
- }
87
- visit_free(v);
88
-
89
- return ret_out;
90
-}
91
-
92
void print_net_client(Monitor *mon, NetClientState *nc)
93
{
94
NetFilterState *nf;
95
- char *info_str = generate_info_str(nc);
96
97
monitor_printf(mon, "%s: index=%d,type=%s,%s\n", nc->name,
98
nc->queue_index,
99
NetClientDriver_str(nc->info->type),
100
- info_str);
101
- g_free(info_str);
102
-
103
+ nc->info_str ? nc->info_str : "");
104
if (!QTAILQ_EMPTY(&nc->filters)) {
105
monitor_printf(mon, "filters:\n");
42
}
106
}
43
107
diff --git a/qapi/hmp-output-visitor.c b/qapi/hmp-output-visitor.c
108
deleted file mode 100644
109
index XXXXXXX..XXXXXXX
110
--- a/qapi/hmp-output-visitor.c
111
+++ /dev/null
112
@@ -XXX,XX +XXX,XX @@
113
-/*
114
- * HMP string output Visitor
115
- *
116
- * Copyright Yandex N.V., 2021
117
- *
118
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
119
- * See the COPYING file in the top-level directory.
120
- *
121
- */
122
-
123
-#include "qemu/osdep.h"
124
-#include "qemu/cutils.h"
125
-#include "qapi/hmp-output-visitor.h"
126
-#include "qapi/visitor-impl.h"
127
-
128
-struct HMPOutputVisitor {
129
- Visitor visitor;
130
- char **result;
131
- GString *buffer;
132
- bool is_continue;
133
-};
134
-
135
-static HMPOutputVisitor *to_hov(Visitor *v)
136
-{
137
- return container_of(v, HMPOutputVisitor, visitor);
138
-}
139
-
140
-static void hmp_output_append_formatted(Visitor *v, const char *fmt, ...)
141
-{
142
- HMPOutputVisitor *ov = to_hov(v);
143
- va_list args;
144
-
145
- if (ov->is_continue) {
146
- g_string_append(ov->buffer, ",");
147
- } else {
148
- ov->is_continue = true;
149
- }
150
-
151
- va_start(args, fmt);
152
- g_string_append_vprintf(ov->buffer, fmt, args);
153
- va_end(args);
154
-}
155
-
156
-static void hmp_output_skip_comma(Visitor *v)
157
-{
158
- HMPOutputVisitor *ov = to_hov(v);
159
-
160
- ov->is_continue = false;
161
-}
162
-
163
-static bool hmp_output_start_struct(Visitor *v, const char *name,
164
- void **obj, size_t unused, Error **errp)
165
-{
166
- return true;
167
-}
168
-
169
-static void hmp_output_end_struct(Visitor *v, void **obj) {}
170
-
171
-static bool hmp_output_start_list(Visitor *v, const char *name,
172
- GenericList **listp, size_t size,
173
- Error **errp)
174
-{
175
- hmp_output_append_formatted(v, "%s=[", name);
176
- /* First element in array without comma before it */
177
- hmp_output_skip_comma(v);
178
-
179
- return true;
180
-}
181
-
182
-static GenericList *hmp_output_next_list(Visitor *v, GenericList *tail,
183
- size_t size)
184
-{
185
- return tail->next;
186
-}
187
-
188
-static void hmp_output_end_list(Visitor *v, void **obj)
189
-{
190
- /* Don't need comma after last array element */
191
- hmp_output_skip_comma(v);
192
- hmp_output_append_formatted(v, "]");
193
-}
194
-
195
-static bool hmp_output_type_int64(Visitor *v, const char *name,
196
- int64_t *obj, Error **errp)
197
-{
198
- hmp_output_append_formatted(v, "%s=%" PRId64, name, *obj);
199
-
200
- return true;
201
-}
202
-
203
-static bool hmp_output_type_uint64(Visitor *v, const char *name,
204
- uint64_t *obj, Error **errp)
205
-{
206
- hmp_output_append_formatted(v, "%s=%" PRIu64, name, *obj);
207
-
208
- return true;
209
-}
210
-
211
-static bool hmp_output_type_bool(Visitor *v, const char *name, bool *obj,
212
- Error **errp)
213
-{
214
- hmp_output_append_formatted(v, "%s=%s", name, *obj ? "true" : "false");
215
-
216
- return true;
217
-}
218
-
219
-static bool hmp_output_type_str(Visitor *v, const char *name, char **obj,
220
- Error **errp)
221
-{
222
- /* Skip already printed or unused fields */
223
- if (!*obj || g_str_equal(name, "id") || g_str_equal(name, "type")) {
224
- return true;
225
- }
226
-
227
- /* Do not print stub name for StringList elements */
228
- if (g_str_equal(name, "str")) {
229
- hmp_output_append_formatted(v, "%s", *obj);
230
- } else {
231
- hmp_output_append_formatted(v, "%s=%s", name, *obj);
232
- }
233
-
234
- return true;
235
-}
236
-
237
-static bool hmp_output_type_number(Visitor *v, const char *name,
238
- double *obj, Error **errp)
239
-{
240
- hmp_output_append_formatted(v, "%s=%.17g", name, *obj);
241
-
242
- return true;
243
-}
244
-
245
-/* TODO: remove this function? */
246
-static bool hmp_output_type_any(Visitor *v, const char *name,
247
- QObject **obj, Error **errp)
248
-{
249
- return true;
250
-}
251
-
252
-static bool hmp_output_type_null(Visitor *v, const char *name,
253
- QNull **obj, Error **errp)
254
-{
255
- hmp_output_append_formatted(v, "%s=NULL", name);
256
-
257
- return true;
258
-}
259
-
260
-static void hmp_output_complete(Visitor *v, void *opaque)
261
-{
262
- HMPOutputVisitor *ov = to_hov(v);
263
-
264
- *ov->result = g_string_free(ov->buffer, false);
265
- ov->buffer = NULL;
266
-}
267
-
268
-static void hmp_output_free(Visitor *v)
269
-{
270
- HMPOutputVisitor *ov = to_hov(v);
271
-
272
- if (ov->buffer) {
273
- g_string_free(ov->buffer, true);
274
- }
275
- g_free(v);
276
-}
277
-
278
-Visitor *hmp_output_visitor_new(char **result)
279
-{
280
- HMPOutputVisitor *v;
281
-
282
- v = g_malloc0(sizeof(*v));
283
-
284
- v->visitor.type = VISITOR_OUTPUT;
285
- v->visitor.start_struct = hmp_output_start_struct;
286
- v->visitor.end_struct = hmp_output_end_struct;
287
- v->visitor.start_list = hmp_output_start_list;
288
- v->visitor.next_list = hmp_output_next_list;
289
- v->visitor.end_list = hmp_output_end_list;
290
- v->visitor.type_int64 = hmp_output_type_int64;
291
- v->visitor.type_uint64 = hmp_output_type_uint64;
292
- v->visitor.type_bool = hmp_output_type_bool;
293
- v->visitor.type_str = hmp_output_type_str;
294
- v->visitor.type_number = hmp_output_type_number;
295
- v->visitor.type_any = hmp_output_type_any;
296
- v->visitor.type_null = hmp_output_type_null;
297
- v->visitor.complete = hmp_output_complete;
298
- v->visitor.free = hmp_output_free;
299
-
300
- v->result = result;
301
- v->buffer = g_string_new("");
302
- v->is_continue = false;
303
-
304
- return &v->visitor;
305
-}
306
diff --git a/qapi/meson.build b/qapi/meson.build
307
index XXXXXXX..XXXXXXX 100644
308
--- a/qapi/meson.build
309
+++ b/qapi/meson.build
310
@@ -XXX,XX +XXX,XX @@ util_ss.add(files(
311
'qobject-output-visitor.c',
312
'string-input-visitor.c',
313
'string-output-visitor.c',
314
- 'hmp-output-visitor.c',
315
))
316
if have_system or have_tools
317
util_ss.add(files(
44
--
318
--
45
2.7.4
319
2.7.4
46
320
47
321
diff view generated by jsdifflib
1
From: Keqian Zhu <zhukeqian1@huawei.com>
1
Several issues has been reported for query-netdev info
2
series. Consider it's late in the rc, this reverts commit
3
commit 59b5437eb732d6b103a9bc279c3482c834d1eff9.
2
4
3
Fixes: 63c4db4c2e6d (net: relocate paths to helpers and scripts)
4
Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
5
Signed-off-by: Jason Wang <jasowang@redhat.com>
5
Signed-off-by: Jason Wang <jasowang@redhat.com>
6
---
6
---
7
net/tap.c | 3 ++-
7
hw/net/xen_nic.c | 5 +++--
8
1 file changed, 2 insertions(+), 1 deletion(-)
8
include/net/net.h | 2 +-
9
net/l2tpv3.c | 3 ++-
10
net/net.c | 14 ++++++--------
11
net/slirp.c | 5 +++--
12
net/socket.c | 43 +++++++++++++++++++------------------------
13
net/tap-win32.c | 3 ++-
14
net/tap.c | 13 ++++++++-----
15
net/vde.c | 3 ++-
16
net/vhost-user.c | 3 ++-
17
net/vhost-vdpa.c | 2 +-
18
11 files changed, 49 insertions(+), 47 deletions(-)
9
19
20
diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/net/xen_nic.c
23
+++ b/hw/net/xen_nic.c
24
@@ -XXX,XX +XXX,XX @@ static int net_init(struct XenLegacyDevice *xendev)
25
netdev->nic = qemu_new_nic(&net_xen_info, &netdev->conf,
26
"xen", NULL, netdev);
27
28
- qemu_get_queue(netdev->nic)->info_str = g_strdup_printf(
29
- "nic: xenbus vif macaddr=%s", netdev->mac);
30
+ snprintf(qemu_get_queue(netdev->nic)->info_str,
31
+ sizeof(qemu_get_queue(netdev->nic)->info_str),
32
+ "nic: xenbus vif macaddr=%s", netdev->mac);
33
34
/* fill info */
35
xenstore_write_be_int(&netdev->xendev, "feature-rx-copy", 1);
36
diff --git a/include/net/net.h b/include/net/net.h
37
index XXXXXXX..XXXXXXX 100644
38
--- a/include/net/net.h
39
+++ b/include/net/net.h
40
@@ -XXX,XX +XXX,XX @@ struct NetClientState {
41
NetQueue *incoming_queue;
42
char *model;
43
char *name;
44
- char *info_str;
45
+ char info_str[256];
46
NetdevInfo *stored_config;
47
unsigned receive_disabled : 1;
48
NetClientDestructor *destructor;
49
diff --git a/net/l2tpv3.c b/net/l2tpv3.c
50
index XXXXXXX..XXXXXXX 100644
51
--- a/net/l2tpv3.c
52
+++ b/net/l2tpv3.c
53
@@ -XXX,XX +XXX,XX @@ int net_init_l2tpv3(const Netdev *netdev,
54
QAPI_CLONE_MEMBERS(NetdevL2TPv3Options,
55
&nc->stored_config->u.l2tpv3, l2tpv3);
56
57
- s->nc.info_str = g_strdup_printf("l2tpv3: connected");
58
+ snprintf(s->nc.info_str, sizeof(s->nc.info_str),
59
+ "l2tpv3: connected");
60
return 0;
61
outerr:
62
qemu_del_net_client(nc);
63
diff --git a/net/net.c b/net/net.c
64
index XXXXXXX..XXXXXXX 100644
65
--- a/net/net.c
66
+++ b/net/net.c
67
@@ -XXX,XX +XXX,XX @@ char *qemu_mac_strdup_printf(const uint8_t *macaddr)
68
69
void qemu_format_nic_info_str(NetClientState *nc, uint8_t macaddr[6])
70
{
71
- g_free(nc->info_str);
72
- nc->info_str = g_strdup_printf(
73
- "model=%s,macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
74
- nc->model,
75
- macaddr[0], macaddr[1], macaddr[2],
76
- macaddr[3], macaddr[4], macaddr[5]);
77
+ snprintf(nc->info_str, sizeof(nc->info_str),
78
+ "model=%s,macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
79
+ nc->model,
80
+ macaddr[0], macaddr[1], macaddr[2],
81
+ macaddr[3], macaddr[4], macaddr[5]);
82
}
83
84
static int mac_table[256] = {0};
85
@@ -XXX,XX +XXX,XX @@ static void qemu_free_net_client(NetClientState *nc)
86
}
87
g_free(nc->name);
88
g_free(nc->model);
89
- g_free(nc->info_str);
90
qapi_free_NetdevInfo(nc->stored_config);
91
if (nc->destructor) {
92
nc->destructor(nc);
93
@@ -XXX,XX +XXX,XX @@ void print_net_client(Monitor *mon, NetClientState *nc)
94
monitor_printf(mon, "%s: index=%d,type=%s,%s\n", nc->name,
95
nc->queue_index,
96
NetClientDriver_str(nc->info->type),
97
- nc->info_str ? nc->info_str : "");
98
+ nc->info_str);
99
if (!QTAILQ_EMPTY(&nc->filters)) {
100
monitor_printf(mon, "filters:\n");
101
}
102
diff --git a/net/slirp.c b/net/slirp.c
103
index XXXXXXX..XXXXXXX 100644
104
--- a/net/slirp.c
105
+++ b/net/slirp.c
106
@@ -XXX,XX +XXX,XX @@ static int net_slirp_init(NetClientState *peer, const char *model,
107
stored->tftp_server_name = g_strdup(tftp_server_name);
108
}
109
110
- nc->info_str = g_strdup_printf("net=%s,restrict=%s", inet_ntoa(net),
111
- restricted ? "on" : "off");
112
+ snprintf(nc->info_str, sizeof(nc->info_str),
113
+ "net=%s,restrict=%s", inet_ntoa(net),
114
+ restricted ? "on" : "off");
115
116
s = DO_UPCAST(SlirpState, nc, nc);
117
118
diff --git a/net/socket.c b/net/socket.c
119
index XXXXXXX..XXXXXXX 100644
120
--- a/net/socket.c
121
+++ b/net/socket.c
122
@@ -XXX,XX +XXX,XX @@ static void net_socket_send(void *opaque)
123
s->fd = -1;
124
net_socket_rs_init(&s->rs, net_socket_rs_finalize, false);
125
s->nc.link_down = true;
126
- g_free(s->nc.info_str);
127
- s->nc.info_str = g_new0(char, 1);
128
+ memset(s->nc.info_str, 0, sizeof(s->nc.info_str));
129
130
return;
131
}
132
@@ -XXX,XX +XXX,XX @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer,
133
stored->mcast = g_strdup(mcast);
134
135
s->dgram_dst = saddr;
136
- nc->info_str = g_strdup_printf("socket: fd=%d (cloned mcast=%s:%d)",
137
- fd, inet_ntoa(saddr.sin_addr),
138
- ntohs(saddr.sin_port));
139
+ snprintf(nc->info_str, sizeof(nc->info_str),
140
+ "socket: fd=%d (cloned mcast=%s:%d)",
141
+ fd, inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
142
} else {
143
if (sa_type == SOCKET_ADDRESS_TYPE_UNIX) {
144
s->dgram_dst.sin_family = AF_UNIX;
145
}
146
147
- nc->info_str = g_strdup_printf("socket: fd=%d %s",
148
- fd, SocketAddressType_str(sa_type));
149
+ snprintf(nc->info_str, sizeof(nc->info_str),
150
+ "socket: fd=%d %s", fd, SocketAddressType_str(sa_type));
151
}
152
153
return s;
154
@@ -XXX,XX +XXX,XX @@ static NetSocketState *net_socket_fd_init_stream(NetClientState *peer,
155
156
nc = qemu_new_net_client(&net_socket_info, peer, model, name);
157
158
- nc->info_str = g_strdup_printf("socket: fd=%d", fd);
159
+ snprintf(nc->info_str, sizeof(nc->info_str), "socket: fd=%d", fd);
160
161
s = DO_UPCAST(NetSocketState, nc, nc);
162
163
@@ -XXX,XX +XXX,XX @@ static void net_socket_accept(void *opaque)
164
stored->has_fd = true;
165
stored->fd = g_strdup_printf("%d", fd);
166
167
- g_free(s->nc.info_str);
168
- s->nc.info_str = g_strdup_printf("socket: connection from %s:%d",
169
- inet_ntoa(saddr.sin_addr),
170
- ntohs(saddr.sin_port));
171
+ snprintf(s->nc.info_str, sizeof(s->nc.info_str),
172
+ "socket: connection from %s:%d",
173
+ inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
174
}
175
176
static int net_socket_listen_init(NetClientState *peer,
177
@@ -XXX,XX +XXX,XX @@ static int net_socket_connect_init(NetClientState *peer,
178
stored->has_connect = true;
179
stored->connect = g_strdup(host_str);
180
181
- g_free(s->nc.info_str);
182
- s->nc.info_str = g_strdup_printf("socket: connect to %s:%d",
183
- inet_ntoa(saddr.sin_addr),
184
- ntohs(saddr.sin_port));
185
+ snprintf(s->nc.info_str, sizeof(s->nc.info_str),
186
+ "socket: connect to %s:%d",
187
+ inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
188
return 0;
189
}
190
191
@@ -XXX,XX +XXX,XX @@ static int net_socket_mcast_init(NetClientState *peer,
192
stored->localaddr = g_strdup(localaddr_str);
193
}
194
195
- g_free(s->nc.info_str);
196
- s->nc.info_str = g_strdup_printf("socket: mcast=%s:%d",
197
- inet_ntoa(saddr.sin_addr),
198
- ntohs(saddr.sin_port));
199
+ snprintf(s->nc.info_str, sizeof(s->nc.info_str),
200
+ "socket: mcast=%s:%d",
201
+ inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
202
return 0;
203
204
}
205
@@ -XXX,XX +XXX,XX @@ static int net_socket_udp_init(NetClientState *peer,
206
stored->has_udp = true;
207
stored->udp = g_strdup(rhost);
208
209
- g_free(s->nc.info_str);
210
- s->nc.info_str = g_strdup_printf("socket: udp=%s:%d",
211
- inet_ntoa(raddr.sin_addr),
212
- ntohs(raddr.sin_port));
213
+ snprintf(s->nc.info_str, sizeof(s->nc.info_str),
214
+ "socket: udp=%s:%d",
215
+ inet_ntoa(raddr.sin_addr), ntohs(raddr.sin_port));
216
return 0;
217
}
218
219
diff --git a/net/tap-win32.c b/net/tap-win32.c
220
index XXXXXXX..XXXXXXX 100644
221
--- a/net/tap-win32.c
222
+++ b/net/tap-win32.c
223
@@ -XXX,XX +XXX,XX @@ static int tap_win32_init(NetClientState *peer, const char *model,
224
stored->has_ifname = true;
225
stored->ifname = g_strdup(ifname);
226
227
- s->nc.info_str = g_strdup_printf("tap: ifname=%s", ifname);
228
+ snprintf(s->nc.info_str, sizeof(s->nc.info_str),
229
+ "tap: ifname=%s", ifname);
230
231
s->handle = handle;
232
10
diff --git a/net/tap.c b/net/tap.c
233
diff --git a/net/tap.c b/net/tap.c
11
index XXXXXXX..XXXXXXX 100644
234
index XXXXXXX..XXXXXXX 100644
12
--- a/net/tap.c
235
--- a/net/tap.c
13
+++ b/net/tap.c
236
+++ b/net/tap.c
14
@@ -XXX,XX +XXX,XX @@ free_fail:
237
@@ -XXX,XX +XXX,XX @@ int net_init_bridge(const Netdev *netdev, const char *name,
15
script = default_script = get_relocated_path(DEFAULT_NETWORK_SCRIPT);
238
stored->helper = g_strdup(helper);
239
}
240
241
- s->nc.info_str = g_strdup_printf("helper=%s,br=%s", helper, br);
242
+ snprintf(s->nc.info_str, sizeof(s->nc.info_str), "helper=%s,br=%s", helper,
243
+ br);
244
245
return 0;
246
}
247
@@ -XXX,XX +XXX,XX @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
248
g_free(tmp_s);
16
}
249
}
17
if (!downscript) {
250
18
- downscript = default_downscript = get_relocated_path(DEFAULT_NETWORK_SCRIPT);
251
- s->nc.info_str = g_strdup_printf("fd=%d", fd);
19
+ downscript = default_downscript =
252
+ snprintf(s->nc.info_str, sizeof(s->nc.info_str), "fd=%d", fd);
20
+ get_relocated_path(DEFAULT_NETWORK_DOWN_SCRIPT);
253
} else if (tap->has_helper) {
254
if (!stored->has_helper) {
255
stored->has_helper = true;
256
@@ -XXX,XX +XXX,XX @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
257
g_strdup(DEFAULT_BRIDGE_INTERFACE);
21
}
258
}
22
259
23
if (tap->has_ifname) {
260
- s->nc.info_str = g_strdup_printf("helper=%s", tap->helper);
261
+ snprintf(s->nc.info_str, sizeof(s->nc.info_str), "helper=%s",
262
+ tap->helper);
263
} else {
264
if (ifname && !stored->has_ifname) {
265
stored->has_ifname = true;
266
@@ -XXX,XX +XXX,XX @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
267
stored->downscript = g_strdup(downscript);
268
}
269
270
- s->nc.info_str = g_strdup_printf("ifname=%s,script=%s,downscript=%s",
271
- ifname, script, downscript);
272
+ snprintf(s->nc.info_str, sizeof(s->nc.info_str),
273
+ "ifname=%s,script=%s,downscript=%s", ifname, script,
274
+ downscript);
275
276
if (strcmp(downscript, "no") != 0) {
277
snprintf(s->down_script, sizeof(s->down_script), "%s", downscript);
278
diff --git a/net/vde.c b/net/vde.c
279
index XXXXXXX..XXXXXXX 100644
280
--- a/net/vde.c
281
+++ b/net/vde.c
282
@@ -XXX,XX +XXX,XX @@ static int net_vde_init(NetClientState *peer, const char *model,
283
284
nc = qemu_new_net_client(&net_vde_info, peer, model, name);
285
286
- nc->info_str = g_strdup_printf("sock=%s,fd=%d", sock, vde_datafd(vde));
287
+ snprintf(nc->info_str, sizeof(nc->info_str), "sock=%s,fd=%d",
288
+ sock, vde_datafd(vde));
289
290
s = DO_UPCAST(VDEState, nc, nc);
291
292
diff --git a/net/vhost-user.c b/net/vhost-user.c
293
index XXXXXXX..XXXXXXX 100644
294
--- a/net/vhost-user.c
295
+++ b/net/vhost-user.c
296
@@ -XXX,XX +XXX,XX @@ static int net_vhost_user_init(NetClientState *peer, const char *device,
297
user = g_new0(struct VhostUserState, 1);
298
for (i = 0; i < queues; i++) {
299
nc = qemu_new_net_client(&net_vhost_user_info, peer, device, name);
300
- nc->info_str = g_strdup_printf("vhost-user%d to %s", i, chr->label);
301
+ snprintf(nc->info_str, sizeof(nc->info_str), "vhost-user%d to %s",
302
+ i, chr->label);
303
nc->queue_index = i;
304
if (!nc0) {
305
nc0 = nc;
306
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
307
index XXXXXXX..XXXXXXX 100644
308
--- a/net/vhost-vdpa.c
309
+++ b/net/vhost-vdpa.c
310
@@ -XXX,XX +XXX,XX @@ static int net_vhost_vdpa_init(NetClientState *peer, const char *device,
311
stored->has_queues = true;
312
stored->queues = 1; /* TODO: change when support multiqueue */
313
314
- nc->info_str = g_strdup_printf(TYPE_VHOST_VDPA);
315
+ snprintf(nc->info_str, sizeof(nc->info_str), TYPE_VHOST_VDPA);
316
nc->queue_index = 0;
317
s = DO_UPCAST(VhostVDPAState, nc, nc);
318
vdpa_device_fd = qemu_open_old(vhostdev, O_RDWR);
24
--
319
--
25
2.7.4
320
2.7.4
26
321
27
322
diff view generated by jsdifflib
New patch
1
Several issues has been reported for query-netdev series. Consider
2
it's late in the rc, this reverts commit
3
3c3b656885473ef0d699290ba966177f17839aa5.
1
4
5
Signed-off-by: Jason Wang <jasowang@redhat.com>
6
---
7
tests/qtest/meson.build | 3 -
8
tests/qtest/test-query-netdev.c | 120 ----------------------------------------
9
2 files changed, 123 deletions(-)
10
delete mode 100644 tests/qtest/test-query-netdev.c
11
12
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
13
index XXXXXXX..XXXXXXX 100644
14
--- a/tests/qtest/meson.build
15
+++ b/tests/qtest/meson.build
16
@@ -XXX,XX +XXX,XX @@ qtests_generic = \
17
if config_host.has_key('CONFIG_MODULES')
18
qtests_generic += [ 'modules-test' ]
19
endif
20
-if slirp.found()
21
- qtests_generic += [ 'test-query-netdev' ]
22
-endif
23
24
qtests_pci = \
25
(config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : []) + \
26
diff --git a/tests/qtest/test-query-netdev.c b/tests/qtest/test-query-netdev.c
27
deleted file mode 100644
28
index XXXXXXX..XXXXXXX
29
--- a/tests/qtest/test-query-netdev.c
30
+++ /dev/null
31
@@ -XXX,XX +XXX,XX @@
32
-/*
33
- * QTest testcase for the query-netdev
34
- *
35
- * Copyright Yandex N.V., 2019
36
- *
37
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
38
- * See the COPYING file in the top-level directory.
39
- *
40
- */
41
-
42
-#include "qemu/osdep.h"
43
-
44
-#include "libqos/libqtest.h"
45
-#include "qapi/qmp/qdict.h"
46
-#include "qapi/qmp/qlist.h"
47
-
48
-/*
49
- * Events can get in the way of responses we are actually waiting for.
50
- */
51
-GCC_FMT_ATTR(2, 3)
52
-static QObject *wait_command(QTestState *who, const char *command, ...)
53
-{
54
- va_list ap;
55
- QDict *response;
56
- QObject *result;
57
-
58
- va_start(ap, command);
59
- qtest_qmp_vsend(who, command, ap);
60
- va_end(ap);
61
-
62
- response = qtest_qmp_receive(who);
63
-
64
- result = qdict_get(response, "return");
65
- g_assert(result);
66
- qobject_ref(result);
67
- qobject_unref(response);
68
-
69
- return result;
70
-}
71
-
72
-static void qmp_query_netdev_no_error(QTestState *qts, size_t netdevs_count)
73
-{
74
- QObject *resp;
75
- QList *netdevs;
76
-
77
- resp = wait_command(qts, "{'execute': 'query-netdev'}");
78
-
79
- netdevs = qobject_to(QList, resp);
80
- g_assert(netdevs);
81
- g_assert(qlist_size(netdevs) == netdevs_count);
82
-
83
- qobject_unref(resp);
84
-}
85
-
86
-static void test_query_netdev(void)
87
-{
88
- const char *arch = qtest_get_arch();
89
- QObject *resp;
90
- QTestState *state;
91
-
92
- /* Choosing machine for platforms without default one */
93
- if (g_str_equal(arch, "arm") ||
94
- g_str_equal(arch, "aarch64")) {
95
- state = qtest_init(
96
- "-nodefaults "
97
- "-M virt "
98
- "-netdev user,id=slirp0");
99
- } else if (g_str_equal(arch, "tricore")) {
100
- state = qtest_init(
101
- "-nodefaults "
102
- "-M tricore_testboard "
103
- "-netdev user,id=slirp0");
104
- } else if (g_str_equal(arch, "avr")) {
105
- state = qtest_init(
106
- "-nodefaults "
107
- "-M mega2560 "
108
- "-netdev user,id=slirp0");
109
- } else if (g_str_equal(arch, "rx")) {
110
- state = qtest_init(
111
- "-nodefaults "
112
- "-M gdbsim-r5f562n8 "
113
- "-netdev user,id=slirp0");
114
- } else {
115
- state = qtest_init(
116
- "-nodefaults "
117
- "-netdev user,id=slirp0");
118
- }
119
- g_assert(state);
120
-
121
- qmp_query_netdev_no_error(state, 1);
122
-
123
- resp = wait_command(state,
124
- "{'execute': 'netdev_add', 'arguments': {"
125
- " 'id': 'slirp1',"
126
- " 'type': 'user'}}");
127
- qobject_unref(resp);
128
-
129
- qmp_query_netdev_no_error(state, 2);
130
-
131
- resp = wait_command(state,
132
- "{'execute': 'netdev_del', 'arguments': {"
133
- " 'id': 'slirp1'}}");
134
- qobject_unref(resp);
135
-
136
- qmp_query_netdev_no_error(state, 1);
137
-
138
- qtest_quit(state);
139
-}
140
-
141
-int main(int argc, char **argv)
142
-{
143
- int ret = 0;
144
- g_test_init(&argc, &argv, NULL);
145
-
146
- qtest_add_func("/net/qapi/query_netdev", test_query_netdev);
147
-
148
- ret = g_test_run();
149
-
150
- return ret;
151
-}
152
--
153
2.7.4
154
155
diff view generated by jsdifflib
1
From: Paolo Bonzini <pbonzini@redhat.com>
1
Several issues has been reported for query-netdev series. Consider
2
it's late in the rc, this reverts commit
3
d32ad10a14d46dfe9304e3ed5858a11dcd5c71a0.
2
4
3
"netdev_add help" is causing QEMU to exit because the code that
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
8
"netdev_add help" is not fixed by this patch; that is left for
9
later work.
10
11
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12
Signed-off-by: Jason Wang <jasowang@redhat.com>
5
Signed-off-by: Jason Wang <jasowang@redhat.com>
13
---
6
---
14
include/net/net.h | 1 +
7
include/net/net.h | 3 --
15
monitor/hmp-cmds.c | 6 +++++
8
net/l2tpv3.c | 7 ----
16
net/net.c | 68 +++++++++++++++++++++++++++---------------------------
9
net/net.c | 30 +-------------
17
3 files changed, 41 insertions(+), 34 deletions(-)
10
net/netmap.c | 7 ----
11
net/slirp.c | 122 ------------------------------------------------------
12
net/socket.c | 71 -------------------------------
13
net/tap-win32.c | 9 ----
14
net/tap.c | 103 +++------------------------------------------
15
net/vde.c | 22 ----------
16
net/vhost-user.c | 18 ++------
17
net/vhost-vdpa.c | 14 -------
18
qapi/net.json | 80 -----------------------------------
19
12 files changed, 9 insertions(+), 477 deletions(-)
18
20
19
diff --git a/include/net/net.h b/include/net/net.h
21
diff --git a/include/net/net.h b/include/net/net.h
20
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
21
--- a/include/net/net.h
23
--- a/include/net/net.h
22
+++ b/include/net/net.h
24
+++ b/include/net/net.h
23
@@ -XXX,XX +XXX,XX @@ extern const char *host_net_devices[];
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 @@
25
@@ -XXX,XX +XXX,XX @@
36
#include "qemu/option.h"
26
#include "qapi/qapi-types-net.h"
37
#include "qemu/timer.h"
27
#include "net/queue.h"
38
#include "qemu/sockets.h"
28
#include "hw/qdev-properties-system.h"
39
+#include "qemu/help_option.h"
29
-#include "qapi/clone-visitor.h"
40
#include "monitor/monitor-internal.h"
30
-#include "qapi/qapi-visit-net.h"
41
#include "qapi/error.h"
31
42
#include "qapi/clone-visitor.h"
32
#define MAC_FMT "%02X:%02X:%02X:%02X:%02X:%02X"
43
@@ -XXX,XX +XXX,XX @@ void hmp_netdev_add(Monitor *mon, const QDict *qdict)
33
#define MAC_ARG(x) ((uint8_t *)(x))[0], ((uint8_t *)(x))[1], \
44
{
34
@@ -XXX,XX +XXX,XX @@ struct NetClientState {
45
Error *err = NULL;
35
char *model;
46
QemuOpts *opts;
36
char *name;
47
+ const char *type = qdict_get_try_str(qdict, "type");
37
char info_str[256];
48
38
- NetdevInfo *stored_config;
49
+ if (type && is_help_option(type)) {
39
unsigned receive_disabled : 1;
50
+ show_netdevs();
40
NetClientDestructor *destructor;
51
+ return;
41
unsigned int queue_index;
52
+ }
42
diff --git a/net/l2tpv3.c b/net/l2tpv3.c
53
opts = qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict, &err);
43
index XXXXXXX..XXXXXXX 100644
54
if (err) {
44
--- a/net/l2tpv3.c
55
goto out;
45
+++ b/net/l2tpv3.c
46
@@ -XXX,XX +XXX,XX @@ int net_init_l2tpv3(const Netdev *netdev,
47
48
l2tpv3_read_poll(s, true);
49
50
- /* Store startup parameters */
51
- nc->stored_config = g_new0(NetdevInfo, 1);
52
- nc->stored_config->type = NET_BACKEND_L2TPV3;
53
-
54
- QAPI_CLONE_MEMBERS(NetdevL2TPv3Options,
55
- &nc->stored_config->u.l2tpv3, l2tpv3);
56
-
57
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
58
"l2tpv3: connected");
59
return 0;
56
diff --git a/net/net.c b/net/net.c
60
diff --git a/net/net.c b/net/net.c
57
index XXXXXXX..XXXXXXX 100644
61
index XXXXXXX..XXXXXXX 100644
58
--- a/net/net.c
62
--- a/net/net.c
59
+++ b/net/net.c
63
+++ b/net/net.c
60
@@ -XXX,XX +XXX,XX @@
64
@@ -XXX,XX +XXX,XX @@
61
#include "qemu/config-file.h"
65
#include "monitor/monitor.h"
62
#include "qemu/ctype.h"
66
#include "qemu/help_option.h"
63
#include "qemu/iov.h"
67
#include "qapi/qapi-commands-net.h"
64
+#include "qemu/qemu-print.h"
68
+#include "qapi/qapi-visit-net.h"
65
#include "qemu/main-loop.h"
69
#include "qapi/qmp/qdict.h"
66
#include "qemu/option.h"
70
#include "qapi/qmp/qerror.h"
67
#include "qapi/error.h"
71
#include "qemu/error-report.h"
68
@@ -XXX,XX +XXX,XX @@ static int net_client_init1(const Netdev *netdev, bool is_netdev, Error **errp)
72
@@ -XXX,XX +XXX,XX @@ static void qemu_free_net_client(NetClientState *nc)
73
}
74
g_free(nc->name);
75
g_free(nc->model);
76
- qapi_free_NetdevInfo(nc->stored_config);
77
if (nc->destructor) {
78
nc->destructor(nc);
79
}
80
@@ -XXX,XX +XXX,XX @@ RxFilterInfoList *qmp_query_rx_filter(bool has_name, const char *name,
81
return filter_list;
82
}
83
84
-NetdevInfoList *qmp_query_netdev(Error **errp)
85
-{
86
- NetdevInfoList *list = NULL;
87
- NetClientState *nc;
88
-
89
- QTAILQ_FOREACH(nc, &net_clients, next) {
90
- /*
91
- * Only look at netdevs (backend network devices), not for each queue
92
- * or NIC / hubport
93
- */
94
- if (nc->stored_config) {
95
- NetdevInfo *element = QAPI_CLONE(NetdevInfo, nc->stored_config);
96
-
97
- g_free(element->id); /* Need to dealloc empty id after clone */
98
- element->id = g_strdup(nc->name);
99
-
100
- element->has_peer_id = nc->peer != NULL;
101
- if (element->has_peer_id) {
102
- element->peer_id = g_strdup(nc->peer->name);
103
- }
104
-
105
- QAPI_LIST_PREPEND(list, element);
106
- }
107
- }
108
-
109
- return list;
110
-}
111
-
112
void hmp_info_network(Monitor *mon, const QDict *qdict)
113
{
114
NetClientState *nc, *peer;
115
diff --git a/net/netmap.c b/net/netmap.c
116
index XXXXXXX..XXXXXXX 100644
117
--- a/net/netmap.c
118
+++ b/net/netmap.c
119
@@ -XXX,XX +XXX,XX @@ int net_init_netmap(const Netdev *netdev,
120
pstrcpy(s->ifname, sizeof(s->ifname), netmap_opts->ifname);
121
netmap_read_poll(s, true); /* Initially only poll for reads. */
122
123
- /* Store startup parameters */
124
- nc->stored_config = g_new0(NetdevInfo, 1);
125
- nc->stored_config->type = NET_BACKEND_NETMAP;
126
-
127
- QAPI_CLONE_MEMBERS(NetdevNetmapOptions,
128
- &nc->stored_config->u.netmap, netmap_opts);
129
-
69
return 0;
130
return 0;
70
}
131
}
71
132
72
-static void show_netdevs(void)
133
diff --git a/net/slirp.c b/net/slirp.c
73
+void show_netdevs(void)
134
index XXXXXXX..XXXXXXX 100644
135
--- a/net/slirp.c
136
+++ b/net/slirp.c
137
@@ -XXX,XX +XXX,XX @@ static int net_slirp_init(NetClientState *peer, const char *model,
138
int shift;
139
char *end;
140
struct slirp_config_str *config;
141
- NetdevUserOptions *stored;
142
- StringList **stored_hostfwd;
143
- StringList **stored_guestfwd;
144
145
if (!ipv4 && (vnetwork || vhost || vnameserver)) {
146
error_setg(errp, "IPv4 disabled but netmask/host/dns provided");
147
@@ -XXX,XX +XXX,XX @@ static int net_slirp_init(NetClientState *peer, const char *model,
148
149
nc = qemu_new_net_client(&net_slirp_info, peer, model, name);
150
151
- /* Store startup parameters */
152
- nc->stored_config = g_new0(NetdevInfo, 1);
153
- nc->stored_config->type = NET_BACKEND_USER;
154
- stored = &nc->stored_config->u.user;
155
-
156
- if (vhostname) {
157
- stored->has_hostname = true;
158
- stored->hostname = g_strdup(vhostname);
159
- }
160
-
161
- stored->has_q_restrict = true;
162
- stored->q_restrict = restricted;
163
-
164
- stored->has_ipv4 = true;
165
- stored->ipv4 = ipv4;
166
-
167
- stored->has_ipv6 = true;
168
- stored->ipv6 = ipv6;
169
-
170
- if (ipv4) {
171
- uint8_t *net_bytes = (uint8_t *)&net;
172
- uint8_t *mask_bytes = (uint8_t *)&mask;
173
-
174
- stored->has_net = true;
175
- stored->net = g_strdup_printf("%d.%d.%d.%d/%d.%d.%d.%d",
176
- net_bytes[0], net_bytes[1],
177
- net_bytes[2], net_bytes[3],
178
- mask_bytes[0], mask_bytes[1],
179
- mask_bytes[2], mask_bytes[3]);
180
-
181
- stored->has_host = true;
182
- stored->host = g_strdup(inet_ntoa(host));
183
- }
184
-
185
- if (tftp_export) {
186
- stored->has_tftp = true;
187
- stored->tftp = g_strdup(tftp_export);
188
- }
189
-
190
- if (bootfile) {
191
- stored->has_bootfile = true;
192
- stored->bootfile = g_strdup(bootfile);
193
- }
194
-
195
- if (vdhcp_start) {
196
- stored->has_dhcpstart = true;
197
- stored->dhcpstart = g_strdup(vdhcp_start);
198
- }
199
-
200
- if (ipv4) {
201
- stored->has_dns = true;
202
- stored->dns = g_strdup(inet_ntoa(dns));
203
- }
204
-
205
- if (dnssearch) {
206
- stored->has_dnssearch = true;
207
- StringList **stored_list = &stored->dnssearch;
208
-
209
- for (int i = 0; dnssearch[i]; i++) {
210
- String *element = g_new0(String, 1);
211
-
212
- element->str = g_strdup(dnssearch[i]);
213
- QAPI_LIST_APPEND(stored_list, element);
214
- }
215
- }
216
-
217
- if (vdomainname) {
218
- stored->has_domainname = true;
219
- stored->domainname = g_strdup(vdomainname);
220
- }
221
-
222
- if (ipv6) {
223
- char addrstr[INET6_ADDRSTRLEN];
224
- const char *res;
225
-
226
- stored->has_ipv6_prefix = true;
227
- stored->ipv6_prefix = g_strdup(vprefix6);
228
-
229
- stored->has_ipv6_prefixlen = true;
230
- stored->ipv6_prefixlen = vprefix6_len;
231
-
232
- res = inet_ntop(AF_INET6, &ip6_host,
233
- addrstr, sizeof(addrstr));
234
-
235
- stored->has_ipv6_host = true;
236
- stored->ipv6_host = g_strdup(res);
237
-
238
- res = inet_ntop(AF_INET6, &ip6_dns,
239
- addrstr, sizeof(addrstr));
240
-
241
- stored->has_ipv6_dns = true;
242
- stored->ipv6_dns = g_strdup(res);
243
- }
244
-
245
- if (smb_export) {
246
- stored->has_smb = true;
247
- stored->smb = g_strdup(smb_export);
248
- }
249
-
250
- if (vsmbserver) {
251
- stored->has_smbserver = true;
252
- stored->smbserver = g_strdup(vsmbserver);
253
- }
254
-
255
- if (tftp_server_name) {
256
- stored->has_tftp_server_name = true;
257
- stored->tftp_server_name = g_strdup(tftp_server_name);
258
- }
259
-
260
snprintf(nc->info_str, sizeof(nc->info_str),
261
"net=%s,restrict=%s", inet_ntoa(net),
262
restricted ? "on" : "off");
263
@@ -XXX,XX +XXX,XX @@ static int net_slirp_init(NetClientState *peer, const char *model,
264
s->poll_notifier.notify = net_slirp_poll_notify;
265
main_loop_poll_add_notifier(&s->poll_notifier);
266
267
- stored_hostfwd = &stored->hostfwd;
268
- stored_guestfwd = &stored->guestfwd;
269
-
270
for (config = slirp_configs; config; config = config->next) {
271
- String *element = g_new0(String, 1);
272
-
273
- element->str = g_strdup(config->str);
274
if (config->flags & SLIRP_CFG_HOSTFWD) {
275
if (slirp_hostfwd(s, config->str, errp) < 0) {
276
goto error;
277
}
278
- stored->has_hostfwd = true;
279
- QAPI_LIST_APPEND(stored_hostfwd, element);
280
} else {
281
if (slirp_guestfwd(s, config->str, errp) < 0) {
282
goto error;
283
}
284
- stored->has_guestfwd = true;
285
- QAPI_LIST_APPEND(stored_guestfwd, element);
286
}
287
}
288
#ifndef _WIN32
289
diff --git a/net/socket.c b/net/socket.c
290
index XXXXXXX..XXXXXXX 100644
291
--- a/net/socket.c
292
+++ b/net/socket.c
293
@@ -XXX,XX +XXX,XX @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer,
294
NetSocketState *s;
295
SocketAddress *sa;
296
SocketAddressType sa_type;
297
- NetdevSocketOptions *stored;
298
299
sa = socket_local_address(fd, errp);
300
if (!sa) {
301
@@ -XXX,XX +XXX,XX @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer,
302
net_socket_rs_init(&s->rs, net_socket_rs_finalize, false);
303
net_socket_read_poll(s, true);
304
305
- /* Store startup parameters */
306
- nc->stored_config = g_new0(NetdevInfo, 1);
307
- nc->stored_config->type = NET_BACKEND_SOCKET;
308
- stored = &nc->stored_config->u.socket;
309
-
310
- stored->has_fd = true;
311
- stored->fd = g_strdup_printf("%d", fd);
312
-
313
/* mcast: save bound address as dst */
314
if (is_connected && mcast != NULL) {
315
- stored->has_mcast = true;
316
- stored->mcast = g_strdup(mcast);
317
-
318
s->dgram_dst = saddr;
319
snprintf(nc->info_str, sizeof(nc->info_str),
320
"socket: fd=%d (cloned mcast=%s:%d)",
321
@@ -XXX,XX +XXX,XX @@ static NetSocketState *net_socket_fd_init_stream(NetClientState *peer,
74
{
322
{
75
int idx;
323
NetClientState *nc;
76
const char *available_netdevs[] = {
324
NetSocketState *s;
77
@@ -XXX,XX +XXX,XX @@ static void show_netdevs(void)
325
- NetdevSocketOptions *stored;
78
#endif
326
79
};
327
nc = qemu_new_net_client(&net_socket_info, peer, model, name);
80
328
81
- printf("Available netdev backend types:\n");
329
@@ -XXX,XX +XXX,XX @@ static NetSocketState *net_socket_fd_init_stream(NetClientState *peer,
82
+ qemu_printf("Available netdev backend types:\n");
330
} else {
83
for (idx = 0; idx < ARRAY_SIZE(available_netdevs); idx++) {
331
qemu_set_fd_handler(s->fd, NULL, net_socket_connect, s);
84
- puts(available_netdevs[idx]);
85
+ qemu_printf("%s\n", available_netdevs[idx]);
86
}
332
}
333
-
334
- /* Store startup parameters */
335
- nc->stored_config = g_new0(NetdevInfo, 1);
336
- nc->stored_config->type = NET_BACKEND_SOCKET;
337
- stored = &nc->stored_config->u.socket;
338
-
339
- stored->has_fd = true;
340
- stored->fd = g_strdup_printf("%d", fd);
341
-
342
return s;
87
}
343
}
88
344
89
@@ -XXX,XX +XXX,XX @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
345
@@ -XXX,XX +XXX,XX @@ static void net_socket_accept(void *opaque)
90
int ret = -1;
346
struct sockaddr_in saddr;
91
Visitor *v = opts_visitor_new(opts);
347
socklen_t len;
92
348
int fd;
93
- const char *type = qemu_opt_get(opts, "type");
349
- NetdevSocketOptions *stored;
94
-
350
95
- if (is_netdev && type && is_help_option(type)) {
351
for(;;) {
96
- show_netdevs();
352
len = sizeof(saddr);
97
- exit(0);
353
@@ -XXX,XX +XXX,XX @@ static void net_socket_accept(void *opaque)
98
- } else {
354
s->fd = fd;
99
- /* Parse convenience option format ip6-net=fec0::0[/64] */
355
s->nc.link_down = false;
100
- const char *ip6_net = qemu_opt_get(opts, "ipv6-net");
356
net_socket_connect(s);
101
+ /* Parse convenience option format ip6-net=fec0::0[/64] */
357
-
102
+ const char *ip6_net = qemu_opt_get(opts, "ipv6-net");
358
- /* Store additional startup parameters (extend net_socket_listen_init) */
103
359
- stored = &s->nc.stored_config->u.socket;
104
- if (ip6_net) {
360
-
105
- char *prefix_addr;
361
- stored->has_fd = true;
106
- unsigned long prefix_len = 64; /* Default 64bit prefix length. */
362
- stored->fd = g_strdup_printf("%d", fd);
107
+ if (ip6_net) {
363
-
108
+ char *prefix_addr;
364
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
109
+ unsigned long prefix_len = 64; /* Default 64bit prefix length. */
365
"socket: connection from %s:%d",
110
366
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
111
- substrings = g_strsplit(ip6_net, "/", 2);
367
@@ -XXX,XX +XXX,XX @@ static int net_socket_listen_init(NetClientState *peer,
112
- if (!substrings || !substrings[0]) {
368
NetSocketState *s;
113
- error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "ipv6-net",
369
struct sockaddr_in saddr;
114
- "a valid IPv6 prefix");
370
int fd, ret;
115
- goto out;
371
- NetdevSocketOptions *stored;
116
- }
372
117
+ substrings = g_strsplit(ip6_net, "/", 2);
373
if (parse_host_port(&saddr, host_str, errp) < 0) {
118
+ if (!substrings || !substrings[0]) {
374
return -1;
119
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "ipv6-net",
375
@@ -XXX,XX +XXX,XX @@ static int net_socket_listen_init(NetClientState *peer,
120
+ "a valid IPv6 prefix");
376
net_socket_rs_init(&s->rs, net_socket_rs_finalize, false);
121
+ goto out;
377
122
+ }
378
qemu_set_fd_handler(s->listen_fd, net_socket_accept, NULL, s);
123
379
-
124
- prefix_addr = substrings[0];
380
- /* Store startup parameters */
125
+ prefix_addr = substrings[0];
381
- nc->stored_config = g_new0(NetdevInfo, 1);
126
382
- nc->stored_config->type = NET_BACKEND_SOCKET;
127
- /* Handle user-specified prefix length. */
383
- stored = &nc->stored_config->u.socket;
128
- if (substrings[1] &&
384
-
129
- qemu_strtoul(substrings[1], NULL, 10, &prefix_len))
385
- stored->has_listen = true;
130
- {
386
- stored->listen = g_strdup(host_str);
131
- error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
387
-
132
- "ipv6-prefixlen", "a number");
388
return 0;
133
- goto out;
389
}
134
- }
390
135
-
391
@@ -XXX,XX +XXX,XX @@ static int net_socket_connect_init(NetClientState *peer,
136
- qemu_opt_set(opts, "ipv6-prefix", prefix_addr, &error_abort);
392
NetSocketState *s;
137
- qemu_opt_set_number(opts, "ipv6-prefixlen", prefix_len,
393
int fd, connected, ret;
138
- &error_abort);
394
struct sockaddr_in saddr;
139
- qemu_opt_unset(opts, "ipv6-net");
395
- NetdevSocketOptions *stored;
140
+ /* Handle user-specified prefix length. */
396
141
+ if (substrings[1] &&
397
if (parse_host_port(&saddr, host_str, errp) < 0) {
142
+ qemu_strtoul(substrings[1], NULL, 10, &prefix_len))
398
return -1;
143
+ {
399
@@ -XXX,XX +XXX,XX @@ static int net_socket_connect_init(NetClientState *peer,
144
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
400
return -1;
145
+ "ipv6-prefixlen", "a number");
401
}
146
+ goto out;
402
403
- /* Store additional startup parameters (extend net_socket_fd_init) */
404
- stored = &s->nc.stored_config->u.socket;
405
-
406
- stored->has_connect = true;
407
- stored->connect = g_strdup(host_str);
408
-
409
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
410
"socket: connect to %s:%d",
411
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
412
@@ -XXX,XX +XXX,XX @@ static int net_socket_mcast_init(NetClientState *peer,
413
int fd;
414
struct sockaddr_in saddr;
415
struct in_addr localaddr, *param_localaddr;
416
- NetdevSocketOptions *stored;
417
418
if (parse_host_port(&saddr, host_str, errp) < 0) {
419
return -1;
420
@@ -XXX,XX +XXX,XX @@ static int net_socket_mcast_init(NetClientState *peer,
421
422
s->dgram_dst = saddr;
423
424
- /* Store additional startup parameters (extend net_socket_fd_init) */
425
- stored = &s->nc.stored_config->u.socket;
426
-
427
- if (!stored->has_mcast) {
428
- stored->has_mcast = true;
429
- stored->mcast = g_strdup(host_str);
430
- }
431
-
432
- if (localaddr_str) {
433
- stored->has_localaddr = true;
434
- stored->localaddr = g_strdup(localaddr_str);
435
- }
436
-
437
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
438
"socket: mcast=%s:%d",
439
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
440
@@ -XXX,XX +XXX,XX @@ static int net_socket_udp_init(NetClientState *peer,
441
NetSocketState *s;
442
int fd, ret;
443
struct sockaddr_in laddr, raddr;
444
- NetdevSocketOptions *stored;
445
446
if (parse_host_port(&laddr, lhost, errp) < 0) {
447
return -1;
448
@@ -XXX,XX +XXX,XX @@ static int net_socket_udp_init(NetClientState *peer,
449
450
s->dgram_dst = raddr;
451
452
- /* Store additional startup parameters (extend net_socket_fd_init) */
453
- stored = &s->nc.stored_config->u.socket;
454
-
455
- stored->has_localaddr = true;
456
- stored->localaddr = g_strdup(lhost);
457
-
458
- stored->has_udp = true;
459
- stored->udp = g_strdup(rhost);
460
-
461
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
462
"socket: udp=%s:%d",
463
inet_ntoa(raddr.sin_addr), ntohs(raddr.sin_port));
464
diff --git a/net/tap-win32.c b/net/tap-win32.c
465
index XXXXXXX..XXXXXXX 100644
466
--- a/net/tap-win32.c
467
+++ b/net/tap-win32.c
468
@@ -XXX,XX +XXX,XX @@ static int tap_win32_init(NetClientState *peer, const char *model,
469
NetClientState *nc;
470
TAPState *s;
471
tap_win32_overlapped_t *handle;
472
- NetdevTapOptions *stored;
473
474
if (tap_win32_open(&handle, ifname) < 0) {
475
printf("tap: Could not open '%s'\n", ifname);
476
@@ -XXX,XX +XXX,XX @@ static int tap_win32_init(NetClientState *peer, const char *model,
477
478
s = DO_UPCAST(TAPState, nc, nc);
479
480
- /* Store startup parameters */
481
- nc->stored_config = g_new0(NetdevInfo, 1);
482
- nc->stored_config->type = NET_BACKEND_TAP;
483
- stored = &nc->stored_config->u.tap;
484
-
485
- stored->has_ifname = true;
486
- stored->ifname = g_strdup(ifname);
487
-
488
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
489
"tap: ifname=%s", ifname);
490
491
diff --git a/net/tap.c b/net/tap.c
492
index XXXXXXX..XXXXXXX 100644
493
--- a/net/tap.c
494
+++ b/net/tap.c
495
@@ -XXX,XX +XXX,XX @@ int net_init_bridge(const Netdev *netdev, const char *name,
496
const char *helper, *br;
497
TAPState *s;
498
int fd, vnet_hdr;
499
- NetdevBridgeOptions *stored;
500
501
assert(netdev->type == NET_CLIENT_DRIVER_BRIDGE);
502
bridge = &netdev->u.bridge;
503
@@ -XXX,XX +XXX,XX @@ int net_init_bridge(const Netdev *netdev, const char *name,
504
}
505
s = net_tap_fd_init(peer, "bridge", name, fd, vnet_hdr);
506
507
- /* Store startup parameters */
508
- s->nc.stored_config = g_new0(NetdevInfo, 1);
509
- s->nc.stored_config->type = NET_BACKEND_BRIDGE;
510
- stored = &s->nc.stored_config->u.bridge;
511
-
512
- if (br) {
513
- stored->has_br = true;
514
- stored->br = g_strdup(br);
515
- }
516
-
517
- if (helper) {
518
- stored->has_helper = true;
519
- stored->helper = g_strdup(helper);
520
- }
521
-
522
snprintf(s->nc.info_str, sizeof(s->nc.info_str), "helper=%s,br=%s", helper,
523
br);
524
525
@@ -XXX,XX +XXX,XX @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
526
const char *model, const char *name,
527
const char *ifname, const char *script,
528
const char *downscript, const char *vhostfdname,
529
- int vnet_hdr, int fd, NetdevInfo **common_stored,
530
- Error **errp)
531
+ int vnet_hdr, int fd, Error **errp)
532
{
533
Error *err = NULL;
534
TAPState *s = net_tap_fd_init(peer, model, name, fd, vnet_hdr);
535
int vhostfd;
536
- NetdevTapOptions *stored;
537
538
tap_set_sndbuf(s->fd, tap, &err);
539
if (err) {
540
@@ -XXX,XX +XXX,XX @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
541
return;
542
}
543
544
- /* Store startup parameters */
545
- if (!*common_stored) {
546
- *common_stored = g_new0(NetdevInfo, 1);
547
- (*common_stored)->type = NET_BACKEND_TAP;
548
- s->nc.stored_config = *common_stored;
549
- }
550
- stored = &(*common_stored)->u.tap;
551
-
552
- if (tap->has_sndbuf && !stored->has_sndbuf) {
553
- stored->has_sndbuf = true;
554
- stored->sndbuf = tap->sndbuf;
555
- }
556
-
557
- if (vnet_hdr && !stored->has_vnet_hdr) {
558
- stored->has_vnet_hdr = true;
559
- stored->vnet_hdr = true;
560
- }
561
-
562
if (tap->has_fd || tap->has_fds) {
563
- if (!stored->has_fds) {
564
- stored->has_fds = true;
565
- stored->fds = g_strdup_printf("%d", fd);
566
- } else {
567
- char *tmp_s = stored->fds;
568
- stored->fds = g_strdup_printf("%s:%d", stored->fds, fd);
569
- g_free(tmp_s);
570
- }
571
-
572
snprintf(s->nc.info_str, sizeof(s->nc.info_str), "fd=%d", fd);
573
} else if (tap->has_helper) {
574
- if (!stored->has_helper) {
575
- stored->has_helper = true;
576
- stored->helper = g_strdup(tap->helper);
577
- }
578
-
579
- if (!stored->has_br) {
580
- stored->has_br = true;
581
- stored->br = tap->has_br ? g_strdup(tap->br) :
582
- g_strdup(DEFAULT_BRIDGE_INTERFACE);
583
- }
584
-
585
snprintf(s->nc.info_str, sizeof(s->nc.info_str), "helper=%s",
586
tap->helper);
587
} else {
588
- if (ifname && !stored->has_ifname) {
589
- stored->has_ifname = true;
590
- stored->ifname = g_strdup(ifname);
591
- }
592
-
593
- if (script && !stored->has_script) {
594
- stored->has_script = true;
595
- stored->script = g_strdup(script);
596
- }
597
-
598
- if (downscript && !stored->has_downscript) {
599
- stored->has_downscript = true;
600
- stored->downscript = g_strdup(downscript);
601
- }
602
-
603
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
604
"ifname=%s,script=%s,downscript=%s", ifname, script,
605
downscript);
606
@@ -XXX,XX +XXX,XX @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
607
vhostfdname || (tap->has_vhostforce && tap->vhostforce)) {
608
VhostNetOptions options;
609
610
- stored->has_vhost = true;
611
- stored->vhost = true;
612
-
613
- if (tap->has_vhostforce && tap->vhostforce) {
614
- stored->has_vhostforce = true;
615
- stored->vhostforce = true;
616
- }
617
-
618
options.backend_type = VHOST_BACKEND_TYPE_KERNEL;
619
options.net_backend = &s->nc;
620
if (tap->has_poll_us) {
621
- stored->has_poll_us = true;
622
- stored->poll_us = tap->poll_us;
623
-
624
options.busyloop_timeout = tap->poll_us;
625
} else {
626
options.busyloop_timeout = 0;
627
@@ -XXX,XX +XXX,XX @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
147
}
628
}
148
+
629
options.opaque = (void *)(uintptr_t)vhostfd;
149
+ qemu_opt_set(opts, "ipv6-prefix", prefix_addr, &error_abort);
630
150
+ qemu_opt_set_number(opts, "ipv6-prefixlen", prefix_len,
631
- if (!stored->has_vhostfds) {
151
+ &error_abort);
632
- stored->has_vhostfds = true;
152
+ qemu_opt_unset(opts, "ipv6-net");
633
- stored->vhostfds = g_strdup_printf("%d", vhostfd);
634
- } else {
635
- char *tmp_s = stored->vhostfds;
636
- stored->vhostfds = g_strdup_printf("%s:%d", stored->fds, vhostfd);
637
- g_free(tmp_s);
638
- }
639
-
640
s->vhost_net = vhost_net_init(&options);
641
if (!s->vhost_net) {
642
if (tap->has_vhostforce && tap->vhostforce) {
643
@@ -XXX,XX +XXX,XX @@ int net_init_tap(const Netdev *netdev, const char *name,
644
const char *vhostfdname;
645
char ifname[128];
646
int ret = 0;
647
- NetdevInfo *common_stored = NULL; /* will store configuration */
648
649
assert(netdev->type == NET_CLIENT_DRIVER_TAP);
650
tap = &netdev->u.tap;
651
@@ -XXX,XX +XXX,XX @@ int net_init_tap(const Netdev *netdev, const char *name,
652
653
net_init_tap_one(tap, peer, "tap", name, NULL,
654
script, downscript,
655
- vhostfdname, vnet_hdr, fd, &common_stored, &err);
656
+ vhostfdname, vnet_hdr, fd, &err);
657
if (err) {
658
error_propagate(errp, err);
659
close(fd);
660
@@ -XXX,XX +XXX,XX @@ int net_init_tap(const Netdev *netdev, const char *name,
661
net_init_tap_one(tap, peer, "tap", name, ifname,
662
script, downscript,
663
tap->has_vhostfds ? vhost_fds[i] : NULL,
664
- vnet_hdr, fd, &common_stored, &err);
665
+ vnet_hdr, fd, &err);
666
if (err) {
667
error_propagate(errp, err);
668
ret = -1;
669
@@ -XXX,XX +XXX,XX @@ free_fail:
670
671
net_init_tap_one(tap, peer, "bridge", name, ifname,
672
script, downscript, vhostfdname,
673
- vnet_hdr, fd, &common_stored, &err);
674
+ vnet_hdr, fd, &err);
675
if (err) {
676
error_propagate(errp, err);
677
close(fd);
678
@@ -XXX,XX +XXX,XX @@ free_fail:
679
net_init_tap_one(tap, peer, "tap", name, ifname,
680
i >= 1 ? "no" : script,
681
i >= 1 ? "no" : downscript,
682
- vhostfdname, vnet_hdr, fd,
683
- &common_stored, &err);
684
+ vhostfdname, vnet_hdr, fd, &err);
685
if (err) {
686
error_propagate(errp, err);
687
close(fd);
688
diff --git a/net/vde.c b/net/vde.c
689
index XXXXXXX..XXXXXXX 100644
690
--- a/net/vde.c
691
+++ b/net/vde.c
692
@@ -XXX,XX +XXX,XX @@ static int net_vde_init(NetClientState *peer, const char *model,
693
VDECONN *vde;
694
char *init_group = (char *)group;
695
char *init_sock = (char *)sock;
696
- NetdevVdeOptions *stored;
697
698
struct vde_open_args args = {
699
.port = port,
700
@@ -XXX,XX +XXX,XX @@ static int net_vde_init(NetClientState *peer, const char *model,
701
702
qemu_set_fd_handler(vde_datafd(s->vde), vde_to_qemu, NULL, s);
703
704
- /* Store startup parameters */
705
- nc->stored_config = g_new0(NetdevInfo, 1);
706
- nc->stored_config->type = NET_BACKEND_VDE;
707
- stored = &nc->stored_config->u.vde;
708
-
709
- if (sock) {
710
- stored->has_sock = true;
711
- stored->sock = g_strdup(sock);
712
- }
713
-
714
- stored->has_port = true;
715
- stored->port = port;
716
-
717
- if (group) {
718
- stored->has_group = true;
719
- stored->group = g_strdup(group);
720
- }
721
-
722
- stored->has_mode = true;
723
- stored->mode = mode;
724
-
725
return 0;
726
}
727
728
diff --git a/net/vhost-user.c b/net/vhost-user.c
729
index XXXXXXX..XXXXXXX 100644
730
--- a/net/vhost-user.c
731
+++ b/net/vhost-user.c
732
@@ -XXX,XX +XXX,XX @@ static void net_vhost_user_event(void *opaque, QEMUChrEvent event)
733
}
734
735
static int net_vhost_user_init(NetClientState *peer, const char *device,
736
- const char *name, const char *chardev,
737
- Chardev *chr, int queues)
738
+ const char *name, Chardev *chr,
739
+ int queues)
740
{
741
Error *err = NULL;
742
NetClientState *nc, *nc0 = NULL;
743
NetVhostUserState *s = NULL;
744
VhostUserState *user;
745
int i;
746
- NetdevVhostUserOptions *stored;
747
748
assert(name);
749
assert(queues > 0);
750
@@ -XXX,XX +XXX,XX @@ static int net_vhost_user_init(NetClientState *peer, const char *device,
751
752
assert(s->vhost_net);
753
754
- /* Store startup parameters */
755
- nc0->stored_config = g_new0(NetdevInfo, 1);
756
- nc0->stored_config->type = NET_BACKEND_VHOST_USER;
757
- stored = &nc0->stored_config->u.vhost_user;
758
-
759
- stored->chardev = g_strdup(chardev);
760
-
761
- stored->has_queues = true;
762
- stored->queues = queues;
763
-
764
return 0;
765
766
err:
767
@@ -XXX,XX +XXX,XX @@ int net_init_vhost_user(const Netdev *netdev, const char *name,
768
return -1;
153
}
769
}
154
770
155
/* Create an ID for -net if the user did not specify one */
771
- return net_vhost_user_init(peer, "vhost_user", name,
156
@@ -XXX,XX +XXX,XX @@ static int net_init_client(void *dummy, QemuOpts *opts, Error **errp)
772
- vhost_user_opts->chardev, chr, queues);
157
773
+ return net_vhost_user_init(peer, "vhost_user", name, chr, queues);
158
static int net_init_netdev(void *dummy, QemuOpts *opts, Error **errp)
159
{
160
+ const char *type = qemu_opt_get(opts, "type");
161
+
162
+ if (type && is_help_option(type)) {
163
+ show_netdevs();
164
+ exit(0);
165
+ }
166
return net_client_init(opts, true, errp);
167
}
774
}
168
775
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
776
index XXXXXXX..XXXXXXX 100644
777
--- a/net/vhost-vdpa.c
778
+++ b/net/vhost-vdpa.c
779
@@ -XXX,XX +XXX,XX @@ static int net_vhost_vdpa_init(NetClientState *peer, const char *device,
780
VhostVDPAState *s;
781
int vdpa_device_fd = -1;
782
int ret = 0;
783
- NetdevVhostVDPAOptions *stored;
784
-
785
assert(name);
786
nc = qemu_new_net_client(&net_vhost_vdpa_info, peer, device, name);
787
-
788
- /* Store startup parameters */
789
- nc->stored_config = g_new0(NetdevInfo, 1);
790
- nc->stored_config->type = NET_BACKEND_VHOST_VDPA;
791
- stored = &nc->stored_config->u.vhost_vdpa;
792
-
793
- stored->has_vhostdev = true;
794
- stored->vhostdev = g_strdup(vhostdev);
795
-
796
- stored->has_queues = true;
797
- stored->queues = 1; /* TODO: change when support multiqueue */
798
-
799
snprintf(nc->info_str, sizeof(nc->info_str), TYPE_VHOST_VDPA);
800
nc->queue_index = 0;
801
s = DO_UPCAST(VhostVDPAState, nc, nc);
802
diff --git a/qapi/net.json b/qapi/net.json
803
index XXXXXXX..XXXXXXX 100644
804
--- a/qapi/net.json
805
+++ b/qapi/net.json
806
@@ -XXX,XX +XXX,XX @@
807
##
808
{ 'event': 'FAILOVER_NEGOTIATED',
809
'data': {'device-id': 'str'} }
810
-
811
-##
812
-# @NetBackend:
813
-#
814
-# Available netdev backend drivers.
815
-#
816
-# Since: 6.0
817
-##
818
-{ 'enum': 'NetBackend',
819
- 'data': [ 'bridge', 'l2tpv3', 'netmap', 'socket', 'tap', 'user', 'vde',
820
- 'vhost-user', 'vhost-vdpa' ] }
821
-
822
-##
823
-# @NetdevInfo:
824
-#
825
-# Configuration of a network backend device (netdev).
826
-#
827
-# @id: Device identifier.
828
-#
829
-# @type: Specify the driver used for interpreting remaining arguments.
830
-#
831
-# @peer-id: The connected frontend network device name (absent if no frontend
832
-# is connected).
833
-#
834
-# Since: 6.0
835
-##
836
-{ 'union': 'NetdevInfo',
837
- 'base': { 'id': 'str',
838
- 'type': 'NetBackend',
839
- '*peer-id': 'str' },
840
- 'discriminator': 'type',
841
- 'data': {
842
- 'bridge': 'NetdevBridgeOptions',
843
- 'l2tpv3': 'NetdevL2TPv3Options',
844
- 'netmap': 'NetdevNetmapOptions',
845
- 'socket': 'NetdevSocketOptions',
846
- 'tap': 'NetdevTapOptions',
847
- 'user': 'NetdevUserOptions',
848
- 'vde': 'NetdevVdeOptions',
849
- 'vhost-user': 'NetdevVhostUserOptions',
850
- 'vhost-vdpa': 'NetdevVhostVDPAOptions' } }
851
-
852
-##
853
-# @query-netdev:
854
-#
855
-# Get a list of @NetdevInfo for all virtual network backend devices (netdevs).
856
-#
857
-# Returns: a list of @NetdevInfo describing each netdev.
858
-#
859
-# Since: 6.0
860
-#
861
-# Example:
862
-#
863
-# -> { "execute": "query-netdev" }
864
-# <- { "return": [
865
-# {
866
-# "ipv6": true,
867
-# "ipv4": true,
868
-# "host": "10.0.2.2",
869
-# "ipv6-dns": "fec0::3",
870
-# "ipv6-prefix": "fec0::",
871
-# "net": "10.0.2.0/255.255.255.0",
872
-# "ipv6-host": "fec0::2",
873
-# "type": "user",
874
-# "peer-id": "net0",
875
-# "dns": "10.0.2.3",
876
-# "hostfwd": [
877
-# {
878
-# "str": "tcp::20004-:22"
879
-# }
880
-# ],
881
-# "ipv6-prefixlen": 64,
882
-# "id": "netdev0",
883
-# "restrict": false
884
-# }
885
-# ]
886
-# }
887
-#
888
-##
889
-{ 'command': 'query-netdev', 'returns': ['NetdevInfo'] }
169
--
890
--
170
2.7.4
891
2.7.4
171
892
172
893
diff view generated by jsdifflib
1
From: Prasad J Pandit <pjp@fedoraproject.org>
1
Commit 969e50b61a28 ("net: Pad short frames to minimum size before
2
sending from SLiRP/TAP") tries to pad frames but try to recyle the
3
local array that is used for padding to tap thread. This patch fixes
4
this by recyling the original buffer.
2
5
3
While receiving packets via e1000e_write_packet_to_guest() routine,
6
Fixes: 969e50b61a28 ("net: Pad short frames to minimum size before sending from SLiRP/TAP")
4
'desc_offset' is advanced only when RX descriptor is processed. And
7
Tested-by: Howard Spoelstra <hsp.cat7@gmail.com>
5
RX descriptor is not processed if it has NULL buffer address.
8
Tested-by: Bin Meng <bmeng.cn@gmail.com>
6
This may lead to an infinite loop condition. Increament 'desc_offset'
9
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
7
to process next descriptor in the ring to avoid infinite loop.
8
9
Reported-by: Cheol-woo Myung <330cjfdn@gmail.com>
10
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
10
Signed-off-by: Jason Wang <jasowang@redhat.com>
12
---
11
---
13
hw/net/e1000e_core.c | 8 ++++----
12
net/tap-win32.c | 6 ++++--
14
1 file changed, 4 insertions(+), 4 deletions(-)
13
1 file changed, 4 insertions(+), 2 deletions(-)
15
14
16
diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
15
diff --git a/net/tap-win32.c b/net/tap-win32.c
17
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/net/e1000e_core.c
17
--- a/net/tap-win32.c
19
+++ b/hw/net/e1000e_core.c
18
+++ b/net/tap-win32.c
20
@@ -XXX,XX +XXX,XX @@ e1000e_write_packet_to_guest(E1000ECore *core, struct NetRxPkt *pkt,
19
@@ -XXX,XX +XXX,XX @@ static ssize_t tap_receive(NetClientState *nc, const uint8_t *buf, size_t size)
21
(const char *) &fcs_pad, e1000x_fcs_len(core->mac));
20
static void tap_win32_send(void *opaque)
22
}
21
{
23
}
22
TAPState *s = opaque;
24
- desc_offset += desc_size;
23
- uint8_t *buf;
25
- if (desc_offset >= total_size) {
24
+ uint8_t *buf, *orig_buf;
26
- is_last = true;
25
int max_size = 4096;
27
- }
26
int size;
28
} else { /* as per intel docs; skip descriptors with null buf addr */
27
uint8_t min_pkt[ETH_ZLEN];
29
trace_e1000e_rx_null_descriptor();
28
@@ -XXX,XX +XXX,XX @@ static void tap_win32_send(void *opaque)
29
30
size = tap_win32_read(s->handle, &buf, max_size);
31
if (size > 0) {
32
+ orig_buf = buf;
33
+
34
if (!s->nc.peer->do_not_pad) {
35
if (eth_pad_short_frame(min_pkt, &min_pktsz, buf, size)) {
36
buf = min_pkt;
37
@@ -XXX,XX +XXX,XX @@ static void tap_win32_send(void *opaque)
30
}
38
}
31
+ desc_offset += desc_size;
39
32
+ if (desc_offset >= total_size) {
40
qemu_send_packet(&s->nc, buf, size);
33
+ is_last = true;
41
- tap_win32_free_buffer(s->handle, buf);
34
+ }
42
+ tap_win32_free_buffer(s->handle, orig_buf);
35
43
}
36
e1000e_write_rx_descr(core, desc, is_last ? core->rx_pkt : NULL,
44
}
37
rss_info, do_ps ? ps_hdr_len : 0, &bastate.written);
45
38
--
46
--
39
2.7.4
47
2.7.4
40
48
41
49
diff view generated by jsdifflib