diff options
Diffstat (limited to 'chardev')
-rw-r--r-- | chardev/char-socket.c | 15 | ||||
-rw-r--r-- | chardev/char.c | 3 |
2 files changed, 16 insertions, 2 deletions
diff --git a/chardev/char-socket.c b/chardev/char-socket.c index a916ef4012..0c8d6d430a 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -1008,13 +1008,14 @@ 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 + !!host) != 1) { + if ((!!path + !!fd + !!host) != 1) { error_setg(errp, - "Exactly one of 'path' or 'host' required"); + "Exactly one of 'path', 'fd' or 'host' required"); return; } @@ -1029,6 +1030,12 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend, error_setg(errp, "chardev: socket: no port given"); return; } + } 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(); } @@ -1069,6 +1076,10 @@ 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(); } diff --git a/chardev/char.c b/chardev/char.c index 5d7b079ef0..f7e0d37f24 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -808,6 +808,9 @@ QemuOptsList qemu_chardev_opts = { .name = "port", .type = QEMU_OPT_STRING, },{ + .name = "fd", + .type = QEMU_OPT_STRING, + },{ .name = "localaddr", .type = QEMU_OPT_STRING, },{ |