aboutsummaryrefslogtreecommitdiff
path: root/chardev
diff options
context:
space:
mode:
Diffstat (limited to 'chardev')
-rw-r--r--chardev/char-socket.c34
-rw-r--r--chardev/char.c3
2 files changed, 28 insertions, 9 deletions
diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index 36a8fcc194..d92c5aee73 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -706,8 +706,7 @@ static void tcp_chr_tls_handshake(QIOTask *task,
if (qio_task_propagate_error(task, NULL)) {
tcp_chr_disconnect(chr);
} else {
- /* tn3270 does not support TLS yet */
- if (s->do_telnetopt && !s->is_tn3270) {
+ if (s->do_telnetopt) {
tcp_chr_telnet_init(chr);
} else {
tcp_chr_connect(chr);
@@ -1060,25 +1059,36 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend,
const char *path = qemu_opt_get(opts, "path");
const char *host = qemu_opt_get(opts, "host");
const char *port = qemu_opt_get(opts, "port");
+ const char *fd = qemu_opt_get(opts, "fd");
const char *tls_creds = qemu_opt_get(opts, "tls-creds");
SocketAddressLegacy *addr;
ChardevSocket *sock;
+ if ((!!path + !!fd + !!host) != 1) {
+ error_setg(errp,
+ "Exactly one of 'path', 'fd' or 'host' required");
+ return;
+ }
+
backend->type = CHARDEV_BACKEND_KIND_SOCKET;
- if (!path) {
- if (!host) {
- error_setg(errp, "chardev: socket: no host given");
+ if (path) {
+ if (tls_creds) {
+ error_setg(errp, "TLS can only be used over TCP socket");
return;
}
+ } else if (host) {
if (!port) {
error_setg(errp, "chardev: socket: no port given");
return;
}
- } else {
- if (tls_creds) {
- error_setg(errp, "TLS can only be used over TCP socket");
+ } else if (fd) {
+ /* We don't know what host to validate against when in client mode */
+ if (tls_creds && !is_listen) {
+ error_setg(errp, "TLS can not be used with pre-opened client FD");
return;
}
+ } else {
+ g_assert_not_reached();
}
sock = backend->u.socket.data = g_new0(ChardevSocket, 1);
@@ -1104,7 +1114,7 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend,
addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
q_unix = addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
q_unix->path = g_strdup(path);
- } else {
+ } else if (host) {
addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
addr->u.inet.data = g_new(InetSocketAddress, 1);
*addr->u.inet.data = (InetSocketAddress) {
@@ -1117,6 +1127,12 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend,
.has_ipv6 = qemu_opt_get(opts, "ipv6"),
.ipv6 = qemu_opt_get_bool(opts, "ipv6", 0),
};
+ } else if (fd) {
+ addr->type = SOCKET_ADDRESS_LEGACY_KIND_FD;
+ addr->u.fd.data = g_new(String, 1);
+ addr->u.fd.data->str = g_strdup(fd);
+ } else {
+ g_assert_not_reached();
}
sock->addr = addr;
}
diff --git a/chardev/char.c b/chardev/char.c
index a6250cac80..76d866e6fe 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -799,6 +799,9 @@ QemuOptsList qemu_chardev_opts = {
.name = "port",
.type = QEMU_OPT_STRING,
},{
+ .name = "fd",
+ .type = QEMU_OPT_STRING,
+ },{
.name = "localaddr",
.type = QEMU_OPT_STRING,
},{