mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
qapi: net: add stream and dgram netdevs
Copied from socket netdev file and modified to use SocketAddress to be able to introduce new features like unix socket. "udp" and "mcast" are squashed into dgram netdev, multicast is detected according to the IP address type. "listen" and "connect" modes are managed by stream netdev. An optional parameter "server" defines the mode (off by default) The two new types need to be parsed the modern way with -netdev, because with the traditional way, the "type" field of netdev structure collides with the "type" field of SocketAddress and prevents the correct evaluation of the command line option. Moreover the traditional way doesn't allow to use the same type (SocketAddress) several times with the -netdev option (needed to specify "local" and "remote" addresses). The previous commit paved the way for parsing the modern way, but omitted one detail: how to pick modern vs. traditional, in netdev_is_modern(). We want to pick based on the value of parameter "type". But how to extract it from the option argument? Parsing the option argument, either the modern or the traditional way, extracts it for us, but only if parsing succeeds. If parsing fails, there is no good option. No matter which parser we pick, it'll be the wrong one for some arguments, and the error reporting will be confusing. Fortunately, the traditional parser accepts *anything* when called in a certain way. This maximizes our chance to extract the value of "type", and in turn minimizes the risk of confusing error reporting. Signed-off-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: Stefano Brivio <sbrivio@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
committed by
Jason Wang
parent
53b85d9574
commit
5166fe0ae4
+1
-1
@@ -1276,7 +1276,7 @@ ERST
|
||||
{
|
||||
.name = "netdev_add",
|
||||
.args_type = "netdev:O",
|
||||
.params = "[user|tap|socket|vde|bridge|hubport|netmap|vhost-user"
|
||||
.params = "[user|tap|socket|stream|dgram|vde|bridge|hubport|netmap|vhost-user"
|
||||
#ifdef CONFIG_VMNET
|
||||
"|vmnet-host|vmnet-shared|vmnet-bridged"
|
||||
#endif
|
||||
|
||||
@@ -40,6 +40,12 @@ int net_init_hubport(const Netdev *netdev, const char *name,
|
||||
int net_init_socket(const Netdev *netdev, const char *name,
|
||||
NetClientState *peer, Error **errp);
|
||||
|
||||
int net_init_stream(const Netdev *netdev, const char *name,
|
||||
NetClientState *peer, Error **errp);
|
||||
|
||||
int net_init_dgram(const Netdev *netdev, const char *name,
|
||||
NetClientState *peer, Error **errp);
|
||||
|
||||
int net_init_tap(const Netdev *netdev, const char *name,
|
||||
NetClientState *peer, Error **errp);
|
||||
|
||||
|
||||
+537
File diff suppressed because it is too large
Load Diff
@@ -313,6 +313,8 @@ void net_hub_check_clients(void)
|
||||
case NET_CLIENT_DRIVER_USER:
|
||||
case NET_CLIENT_DRIVER_TAP:
|
||||
case NET_CLIENT_DRIVER_SOCKET:
|
||||
case NET_CLIENT_DRIVER_STREAM:
|
||||
case NET_CLIENT_DRIVER_DGRAM:
|
||||
case NET_CLIENT_DRIVER_VDE:
|
||||
case NET_CLIENT_DRIVER_VHOST_USER:
|
||||
has_host_dev = 1;
|
||||
|
||||
@@ -13,6 +13,8 @@ softmmu_ss.add(files(
|
||||
'net.c',
|
||||
'queue.c',
|
||||
'socket.c',
|
||||
'stream.c',
|
||||
'dgram.c',
|
||||
'util.c',
|
||||
))
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include "qemu/qemu-print.h"
|
||||
#include "qemu/main-loop.h"
|
||||
#include "qemu/option.h"
|
||||
#include "qemu/keyval.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/opts-visitor.h"
|
||||
#include "sysemu/runstate.h"
|
||||
@@ -1021,6 +1022,8 @@ static int (* const net_client_init_fun[NET_CLIENT_DRIVER__MAX])(
|
||||
#endif
|
||||
[NET_CLIENT_DRIVER_TAP] = net_init_tap,
|
||||
[NET_CLIENT_DRIVER_SOCKET] = net_init_socket,
|
||||
[NET_CLIENT_DRIVER_STREAM] = net_init_stream,
|
||||
[NET_CLIENT_DRIVER_DGRAM] = net_init_dgram,
|
||||
#ifdef CONFIG_VDE
|
||||
[NET_CLIENT_DRIVER_VDE] = net_init_vde,
|
||||
#endif
|
||||
@@ -1112,6 +1115,8 @@ void show_netdevs(void)
|
||||
int idx;
|
||||
const char *available_netdevs[] = {
|
||||
"socket",
|
||||
"stream",
|
||||
"dgram",
|
||||
"hubport",
|
||||
"tap",
|
||||
#ifdef CONFIG_SLIRP
|
||||
@@ -1624,7 +1629,30 @@ void net_init_clients(void)
|
||||
*/
|
||||
bool netdev_is_modern(const char *optarg)
|
||||
{
|
||||
return false;
|
||||
QemuOpts *opts;
|
||||
bool is_modern;
|
||||
const char *type;
|
||||
static QemuOptsList dummy_opts = {
|
||||
.name = "netdev",
|
||||
.implied_opt_name = "type",
|
||||
.head = QTAILQ_HEAD_INITIALIZER(dummy_opts.head),
|
||||
.desc = { { } },
|
||||
};
|
||||
|
||||
if (optarg[0] == '{') {
|
||||
/* This is JSON, which means it's modern syntax */
|
||||
return true;
|
||||
}
|
||||
|
||||
opts = qemu_opts_create(&dummy_opts, NULL, false, &error_abort);
|
||||
qemu_opts_do_parse(opts, optarg, dummy_opts.implied_opt_name,
|
||||
&error_abort);
|
||||
type = qemu_opt_get(opts, "type");
|
||||
is_modern = !g_strcmp0(type, "stream") || !g_strcmp0(type, "dgram");
|
||||
|
||||
qemu_opts_reset(&dummy_opts);
|
||||
|
||||
return is_modern;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+425
@@ -0,0 +1,425 @@
|
||||
/*
|
||||
* QEMU System Emulator
|
||||
*
|
||||
* Copyright (c) 2003-2008 Fabrice Bellard
|
||||
* Copyright (c) 2022 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
|
||||
#include "net/net.h"
|
||||
#include "clients.h"
|
||||
#include "monitor/monitor.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "qemu/option.h"
|
||||
#include "qemu/sockets.h"
|
||||
#include "qemu/iov.h"
|
||||
#include "qemu/main-loop.h"
|
||||
#include "qemu/cutils.h"
|
||||
|
||||
typedef struct NetStreamState {
|
||||
NetClientState nc;
|
||||
int listen_fd;
|
||||
int fd;
|
||||
SocketReadState rs;
|
||||
unsigned int send_index; /* number of bytes sent*/
|
||||
bool read_poll; /* waiting to receive data? */
|
||||
bool write_poll; /* waiting to transmit data? */
|
||||
} NetStreamState;
|
||||
|
||||
static void net_stream_send(void *opaque);
|
||||
static void net_stream_accept(void *opaque);
|
||||
static void net_stream_writable(void *opaque);
|
||||
|
||||
static void net_stream_update_fd_handler(NetStreamState *s)
|
||||
{
|
||||
qemu_set_fd_handler(s->fd,
|
||||
s->read_poll ? net_stream_send : NULL,
|
||||
s->write_poll ? net_stream_writable : NULL,
|
||||
s);
|
||||
}
|
||||
|
||||
static void net_stream_read_poll(NetStreamState *s, bool enable)
|
||||
{
|
||||
s->read_poll = enable;
|
||||
net_stream_update_fd_handler(s);
|
||||
}
|
||||
|
||||
static void net_stream_write_poll(NetStreamState *s, bool enable)
|
||||
{
|
||||
s->write_poll = enable;
|
||||
net_stream_update_fd_handler(s);
|
||||
}
|
||||
|
||||
static void net_stream_writable(void *opaque)
|
||||
{
|
||||
NetStreamState *s = opaque;
|
||||
|
||||
net_stream_write_poll(s, false);
|
||||
|
||||
qemu_flush_queued_packets(&s->nc);
|
||||
}
|
||||
|
||||
static ssize_t net_stream_receive(NetClientState *nc, const uint8_t *buf,
|
||||
size_t size)
|
||||
{
|
||||
NetStreamState *s = DO_UPCAST(NetStreamState, nc, nc);
|
||||
uint32_t len = htonl(size);
|
||||
struct iovec iov[] = {
|
||||
{
|
||||
.iov_base = &len,
|
||||
.iov_len = sizeof(len),
|
||||
}, {
|
||||
.iov_base = (void *)buf,
|
||||
.iov_len = size,
|
||||
},
|
||||
};
|
||||
size_t remaining;
|
||||
ssize_t ret;
|
||||
|
||||
remaining = iov_size(iov, 2) - s->send_index;
|
||||
ret = iov_send(s->fd, iov, 2, s->send_index, remaining);
|
||||
|
||||
if (ret == -1 && errno == EAGAIN) {
|
||||
ret = 0; /* handled further down */
|
||||
}
|
||||
if (ret == -1) {
|
||||
s->send_index = 0;
|
||||
return -errno;
|
||||
}
|
||||
if (ret < (ssize_t)remaining) {
|
||||
s->send_index += ret;
|
||||
net_stream_write_poll(s, true);
|
||||
return 0;
|
||||
}
|
||||
s->send_index = 0;
|
||||
return size;
|
||||
}
|
||||
|
||||
static void net_stream_send_completed(NetClientState *nc, ssize_t len)
|
||||
{
|
||||
NetStreamState *s = DO_UPCAST(NetStreamState, nc, nc);
|
||||
|
||||
if (!s->read_poll) {
|
||||
net_stream_read_poll(s, true);
|
||||
}
|
||||
}
|
||||
|
||||
static void net_stream_rs_finalize(SocketReadState *rs)
|
||||
{
|
||||
NetStreamState *s = container_of(rs, NetStreamState, rs);
|
||||
|
||||
if (qemu_send_packet_async(&s->nc, rs->buf,
|
||||
rs->packet_len,
|
||||
net_stream_send_completed) == 0) {
|
||||
net_stream_read_poll(s, false);
|
||||
}
|
||||
}
|
||||
|
||||
static void net_stream_send(void *opaque)
|
||||
{
|
||||
NetStreamState *s = opaque;
|
||||
int size;
|
||||
int ret;
|
||||
uint8_t buf1[NET_BUFSIZE];
|
||||
const uint8_t *buf;
|
||||
|
||||
size = recv(s->fd, buf1, sizeof(buf1), 0);
|
||||
if (size < 0) {
|
||||
if (errno != EWOULDBLOCK) {
|
||||
goto eoc;
|
||||
}
|
||||
} else if (size == 0) {
|
||||
/* end of connection */
|
||||
eoc:
|
||||
net_stream_read_poll(s, false);
|
||||
net_stream_write_poll(s, false);
|
||||
if (s->listen_fd != -1) {
|
||||
qemu_set_fd_handler(s->listen_fd, net_stream_accept, NULL, s);
|
||||
}
|
||||
closesocket(s->fd);
|
||||
|
||||
s->fd = -1;
|
||||
net_socket_rs_init(&s->rs, net_stream_rs_finalize, false);
|
||||
s->nc.link_down = true;
|
||||
qemu_set_info_str(&s->nc, "");
|
||||
|
||||
return;
|
||||
}
|
||||
buf = buf1;
|
||||
|
||||
ret = net_fill_rstate(&s->rs, buf, size);
|
||||
|
||||
if (ret == -1) {
|
||||
goto eoc;
|
||||
}
|
||||
}
|
||||
|
||||
static void net_stream_cleanup(NetClientState *nc)
|
||||
{
|
||||
NetStreamState *s = DO_UPCAST(NetStreamState, nc, nc);
|
||||
if (s->fd != -1) {
|
||||
net_stream_read_poll(s, false);
|
||||
net_stream_write_poll(s, false);
|
||||
close(s->fd);
|
||||
s->fd = -1;
|
||||
}
|
||||
if (s->listen_fd != -1) {
|
||||
qemu_set_fd_handler(s->listen_fd, NULL, NULL, NULL);
|
||||
closesocket(s->listen_fd);
|
||||
s->listen_fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void net_stream_connect(void *opaque)
|
||||
{
|
||||
NetStreamState *s = opaque;
|
||||
net_stream_read_poll(s, true);
|
||||
}
|
||||
|
||||
static NetClientInfo net_stream_info = {
|
||||
.type = NET_CLIENT_DRIVER_STREAM,
|
||||
.size = sizeof(NetStreamState),
|
||||
.receive = net_stream_receive,
|
||||
.cleanup = net_stream_cleanup,
|
||||
};
|
||||
|
||||
static NetStreamState *net_stream_fd_init(NetClientState *peer,
|
||||
const char *model,
|
||||
const char *name,
|
||||
int fd, int is_connected)
|
||||
{
|
||||
NetClientState *nc;
|
||||
NetStreamState *s;
|
||||
|
||||
nc = qemu_new_net_client(&net_stream_info, peer, model, name);
|
||||
|
||||
qemu_set_info_str(nc, "fd=%d", fd);
|
||||
|
||||
s = DO_UPCAST(NetStreamState, nc, nc);
|
||||
|
||||
s->fd = fd;
|
||||
s->listen_fd = -1;
|
||||
net_socket_rs_init(&s->rs, net_stream_rs_finalize, false);
|
||||
|
||||
/* Disable Nagle algorithm on TCP sockets to reduce latency */
|
||||
socket_set_nodelay(fd);
|
||||
|
||||
if (is_connected) {
|
||||
net_stream_connect(s);
|
||||
} else {
|
||||
qemu_set_fd_handler(s->fd, NULL, net_stream_connect, s);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
static void net_stream_accept(void *opaque)
|
||||
{
|
||||
NetStreamState *s = opaque;
|
||||
struct sockaddr_in saddr;
|
||||
socklen_t len;
|
||||
int fd;
|
||||
|
||||
for (;;) {
|
||||
len = sizeof(saddr);
|
||||
fd = qemu_accept(s->listen_fd, (struct sockaddr *)&saddr, &len);
|
||||
if (fd < 0 && errno != EINTR) {
|
||||
return;
|
||||
} else if (fd >= 0) {
|
||||
qemu_set_fd_handler(s->listen_fd, NULL, NULL, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
s->fd = fd;
|
||||
s->nc.link_down = false;
|
||||
net_stream_connect(s);
|
||||
qemu_set_info_str(&s->nc, "connection from %s:%d",
|
||||
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
|
||||
}
|
||||
|
||||
static int net_stream_server_init(NetClientState *peer,
|
||||
const char *model,
|
||||
const char *name,
|
||||
SocketAddress *addr,
|
||||
Error **errp)
|
||||
{
|
||||
NetClientState *nc;
|
||||
NetStreamState *s;
|
||||
int fd, ret;
|
||||
|
||||
switch (addr->type) {
|
||||
case SOCKET_ADDRESS_TYPE_INET: {
|
||||
struct sockaddr_in saddr_in;
|
||||
|
||||
if (convert_host_port(&saddr_in, addr->u.inet.host, addr->u.inet.port,
|
||||
errp) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
fd = qemu_socket(PF_INET, SOCK_STREAM, 0);
|
||||
if (fd < 0) {
|
||||
error_setg_errno(errp, errno, "can't create stream socket");
|
||||
return -1;
|
||||
}
|
||||
qemu_socket_set_nonblock(fd);
|
||||
|
||||
socket_set_fast_reuse(fd);
|
||||
|
||||
ret = bind(fd, (struct sockaddr *)&saddr_in, sizeof(saddr_in));
|
||||
if (ret < 0) {
|
||||
error_setg_errno(errp, errno, "can't bind ip=%s to socket",
|
||||
inet_ntoa(saddr_in.sin_addr));
|
||||
closesocket(fd);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SOCKET_ADDRESS_TYPE_FD:
|
||||
fd = monitor_fd_param(monitor_cur(), addr->u.fd.str, errp);
|
||||
if (fd == -1) {
|
||||
return -1;
|
||||
}
|
||||
ret = qemu_socket_try_set_nonblock(fd);
|
||||
if (ret < 0) {
|
||||
error_setg_errno(errp, -ret, "%s: Can't use file descriptor %d",
|
||||
name, fd);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error_setg(errp, "only support inet or fd type");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = listen(fd, 0);
|
||||
if (ret < 0) {
|
||||
error_setg_errno(errp, errno, "can't listen on socket");
|
||||
closesocket(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
nc = qemu_new_net_client(&net_stream_info, peer, model, name);
|
||||
s = DO_UPCAST(NetStreamState, nc, nc);
|
||||
s->fd = -1;
|
||||
s->listen_fd = fd;
|
||||
s->nc.link_down = true;
|
||||
net_socket_rs_init(&s->rs, net_stream_rs_finalize, false);
|
||||
|
||||
qemu_set_fd_handler(s->listen_fd, net_stream_accept, NULL, s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int net_stream_client_init(NetClientState *peer,
|
||||
const char *model,
|
||||
const char *name,
|
||||
SocketAddress *addr,
|
||||
Error **errp)
|
||||
{
|
||||
NetStreamState *s;
|
||||
struct sockaddr_in saddr_in;
|
||||
int fd, connected, ret;
|
||||
|
||||
switch (addr->type) {
|
||||
case SOCKET_ADDRESS_TYPE_INET:
|
||||
if (convert_host_port(&saddr_in, addr->u.inet.host, addr->u.inet.port,
|
||||
errp) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
fd = qemu_socket(PF_INET, SOCK_STREAM, 0);
|
||||
if (fd < 0) {
|
||||
error_setg_errno(errp, errno, "can't create stream socket");
|
||||
return -1;
|
||||
}
|
||||
qemu_socket_set_nonblock(fd);
|
||||
|
||||
connected = 0;
|
||||
for (;;) {
|
||||
ret = connect(fd, (struct sockaddr *)&saddr_in, sizeof(saddr_in));
|
||||
if (ret < 0) {
|
||||
if (errno == EINTR || errno == EWOULDBLOCK) {
|
||||
/* continue */
|
||||
} else if (errno == EINPROGRESS ||
|
||||
errno == EALREADY ||
|
||||
errno == EINVAL) {
|
||||
break;
|
||||
} else {
|
||||
error_setg_errno(errp, errno, "can't connect socket");
|
||||
closesocket(fd);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
connected = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SOCKET_ADDRESS_TYPE_FD:
|
||||
fd = monitor_fd_param(monitor_cur(), addr->u.fd.str, errp);
|
||||
if (fd == -1) {
|
||||
return -1;
|
||||
}
|
||||
ret = qemu_socket_try_set_nonblock(fd);
|
||||
if (ret < 0) {
|
||||
error_setg_errno(errp, -ret, "%s: Can't use file descriptor %d",
|
||||
name, fd);
|
||||
return -1;
|
||||
}
|
||||
connected = 1;
|
||||
break;
|
||||
default:
|
||||
error_setg(errp, "only support inet or fd type");
|
||||
return -1;
|
||||
}
|
||||
|
||||
s = net_stream_fd_init(peer, model, name, fd, connected);
|
||||
|
||||
switch (addr->type) {
|
||||
case SOCKET_ADDRESS_TYPE_INET:
|
||||
qemu_set_info_str(&s->nc, "connect to %s:%d",
|
||||
inet_ntoa(saddr_in.sin_addr),
|
||||
ntohs(saddr_in.sin_port));
|
||||
break;
|
||||
case SOCKET_ADDRESS_TYPE_FD:
|
||||
qemu_set_info_str(&s->nc, "connect to fd %d", fd);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int net_init_stream(const Netdev *netdev, const char *name,
|
||||
NetClientState *peer, Error **errp)
|
||||
{
|
||||
const NetdevStreamOptions *sock;
|
||||
|
||||
assert(netdev->type == NET_CLIENT_DRIVER_STREAM);
|
||||
sock = &netdev->u.stream;
|
||||
|
||||
if (!sock->has_server || !sock->server) {
|
||||
return net_stream_client_init(peer, "stream", name, sock->addr, errp);
|
||||
}
|
||||
return net_stream_server_init(peer, "stream", name, sock->addr, errp);
|
||||
}
|
||||
+64
-2
@@ -7,6 +7,7 @@
|
||||
##
|
||||
|
||||
{ 'include': 'common.json' }
|
||||
{ 'include': 'sockets.json' }
|
||||
|
||||
##
|
||||
# @set_link:
|
||||
@@ -576,6 +577,60 @@
|
||||
'*isolated': 'bool' },
|
||||
'if': 'CONFIG_VMNET' }
|
||||
|
||||
##
|
||||
# @NetdevStreamOptions:
|
||||
#
|
||||
# Configuration info for stream socket netdev
|
||||
#
|
||||
# @addr: socket address to listen on (server=true)
|
||||
# or connect to (server=false)
|
||||
# @server: create server socket (default: false)
|
||||
#
|
||||
# Only SocketAddress types 'inet' and 'fd' are supported.
|
||||
#
|
||||
# Since: 7.2
|
||||
##
|
||||
{ 'struct': 'NetdevStreamOptions',
|
||||
'data': {
|
||||
'addr': 'SocketAddress',
|
||||
'*server': 'bool' } }
|
||||
|
||||
##
|
||||
# @NetdevDgramOptions:
|
||||
#
|
||||
# Configuration info for datagram socket netdev.
|
||||
#
|
||||
# @remote: remote address
|
||||
# @local: local address
|
||||
#
|
||||
# Only SocketAddress types 'inet' and 'fd' are supported.
|
||||
#
|
||||
# If remote address is present and it's a multicast address, local address
|
||||
# is optional. Otherwise local address is required and remote address is
|
||||
# optional.
|
||||
#
|
||||
# .. table:: Valid parameters combination table
|
||||
# :widths: auto
|
||||
#
|
||||
# ============= ======== =====
|
||||
# remote local okay?
|
||||
# ============= ======== =====
|
||||
# absent absent no
|
||||
# absent not fd no
|
||||
# absent fd yes
|
||||
# multicast absent yes
|
||||
# multicast present yes
|
||||
# not multicast absent no
|
||||
# not multicast present yes
|
||||
# ============= ======== =====
|
||||
#
|
||||
# Since: 7.2
|
||||
##
|
||||
{ 'struct': 'NetdevDgramOptions',
|
||||
'data': {
|
||||
'*local': 'SocketAddress',
|
||||
'*remote': 'SocketAddress' } }
|
||||
|
||||
##
|
||||
# @NetClientDriver:
|
||||
#
|
||||
@@ -587,10 +642,13 @@
|
||||
# @vmnet-host since 7.1
|
||||
# @vmnet-shared since 7.1
|
||||
# @vmnet-bridged since 7.1
|
||||
# @stream since 7.2
|
||||
# @dgram since 7.2
|
||||
##
|
||||
{ 'enum': 'NetClientDriver',
|
||||
'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde',
|
||||
'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vdpa',
|
||||
'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'stream',
|
||||
'dgram', 'vde', 'bridge', 'hubport', 'netmap', 'vhost-user',
|
||||
'vhost-vdpa',
|
||||
{ 'name': 'vmnet-host', 'if': 'CONFIG_VMNET' },
|
||||
{ 'name': 'vmnet-shared', 'if': 'CONFIG_VMNET' },
|
||||
{ 'name': 'vmnet-bridged', 'if': 'CONFIG_VMNET' }] }
|
||||
@@ -610,6 +668,8 @@
|
||||
# 'vmnet-host' - since 7.1
|
||||
# 'vmnet-shared' - since 7.1
|
||||
# 'vmnet-bridged' - since 7.1
|
||||
# 'stream' since 7.2
|
||||
# 'dgram' since 7.2
|
||||
##
|
||||
{ 'union': 'Netdev',
|
||||
'base': { 'id': 'str', 'type': 'NetClientDriver' },
|
||||
@@ -620,6 +680,8 @@
|
||||
'tap': 'NetdevTapOptions',
|
||||
'l2tpv3': 'NetdevL2TPv3Options',
|
||||
'socket': 'NetdevSocketOptions',
|
||||
'stream': 'NetdevStreamOptions',
|
||||
'dgram': 'NetdevDgramOptions',
|
||||
'vde': 'NetdevVdeOptions',
|
||||
'bridge': 'NetdevBridgeOptions',
|
||||
'hubport': 'NetdevHubPortOptions',
|
||||
|
||||
@@ -2772,6 +2772,18 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,
|
||||
"-netdev socket,id=str[,fd=h][,udp=host:port][,localaddr=host:port]\n"
|
||||
" configure a network backend to connect to another network\n"
|
||||
" using an UDP tunnel\n"
|
||||
"-netdev stream,id=str[,server=on|off],addr.type=inet,addr.host=host,addr.port=port\n"
|
||||
"-netdev stream,id=str[,server=on|off],addr.type=fd,addr.str=file-descriptor\n"
|
||||
" configure a network backend to connect to another network\n"
|
||||
" using a socket connection in stream mode.\n"
|
||||
"-netdev dgram,id=str,remote.type=inet,remote.host=maddr,remote.port=port[,local.type=inet,local.host=addr]\n"
|
||||
"-netdev dgram,id=str,remote.type=inet,remote.host=maddr,remote.port=port[,local.type=fd,local.str=file-descriptor]\n"
|
||||
" configure a network backend to connect to a multicast maddr and port\n"
|
||||
" use ``local.host=addr`` to specify the host address to send packets from\n"
|
||||
"-netdev dgram,id=str,local.type=inet,local.host=addr,local.port=port[,remote.type=inet,remote.host=addr,remote.port=port]\n"
|
||||
"-netdev dgram,id=str,local.type=fd,local.str=file-descriptor\n"
|
||||
" configure a network backend to connect to another network\n"
|
||||
" using an UDP tunnel\n"
|
||||
#ifdef CONFIG_VDE
|
||||
"-netdev vde,id=str[,sock=socketpath][,port=n][,group=groupname][,mode=octalmode]\n"
|
||||
" configure a network backend to connect to port 'n' of a vde switch\n"
|
||||
|
||||
Reference in New Issue
Block a user