aboutsummaryrefslogtreecommitdiff
path: root/chardev/char-socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'chardev/char-socket.c')
-rw-r--r--chardev/char-socket.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index 1a371b91ac..a916ef4012 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -1012,21 +1012,25 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend,
SocketAddressLegacy *addr;
ChardevSocket *sock;
+ if ((!!path + !!host) != 1) {
+ error_setg(errp,
+ "Exactly one of 'path' 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");
- return;
- }
+ g_assert_not_reached();
}
sock = backend->u.socket.data = g_new0(ChardevSocket, 1);
@@ -1052,7 +1056,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) {
@@ -1065,6 +1069,8 @@ 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 {
+ g_assert_not_reached();
}
sock->addr = addr;
}