mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 08:43:55 -06:00
chardev: add udp support to qapi
This patch adds 'udp' support to qapi. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
1da48c658a
commit
3ecc059dcd
4 changed files with 67 additions and 19 deletions
|
@ -949,6 +949,31 @@ int socket_listen(SocketAddress *addr, Error **errp)
|
|||
return fd;
|
||||
}
|
||||
|
||||
int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp)
|
||||
{
|
||||
QemuOpts *opts;
|
||||
int fd;
|
||||
|
||||
opts = qemu_opts_create_nofail(&dummy_opts);
|
||||
switch (remote->kind) {
|
||||
case SOCKET_ADDRESS_KIND_INET:
|
||||
qemu_opt_set(opts, "host", remote->inet->host);
|
||||
qemu_opt_set(opts, "port", remote->inet->port);
|
||||
if (local) {
|
||||
qemu_opt_set(opts, "localaddr", local->inet->host);
|
||||
qemu_opt_set(opts, "localport", local->inet->port);
|
||||
}
|
||||
fd = inet_dgram_opts(opts, errp);
|
||||
break;
|
||||
|
||||
default:
|
||||
error_setg(errp, "socket type unsupported for datagram");
|
||||
return -1;
|
||||
}
|
||||
qemu_opts_del(opts);
|
||||
return fd;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
static void socket_cleanup(void)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue