chardev: forbid 'wait' option with client sockets
The 'wait'/'nowait' parameter is used to tell server sockets whether to
block until a client is accepted during initialization. Client chardevs
have always silently ignored this option. Various tests were mistakenly
passing this option for their client chardevs.
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20190211182442.8542-6-berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index 743b7b1..728342d 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -1047,6 +1047,12 @@
error_setg(errp, "%s", "Websocket client is not implemented");
return false;
}
+ if (sock->has_wait) {
+ error_setg(errp, "%s",
+ "'wait' option is incompatible with "
+ "socket in client connect mode");
+ return false;
+ }
}
return true;
@@ -1220,7 +1226,11 @@
sock->tn3270 = is_tn3270;
sock->has_websocket = true;
sock->websocket = is_websock;
- sock->has_wait = true;
+ /*
+ * We have different default to QMP for 'wait' when 'server'
+ * is set, hence we can't just check for existence of 'wait'
+ */
+ sock->has_wait = qemu_opt_find(opts, "wait") || is_listen;
sock->wait = is_waitconnect;
sock->has_reconnect = qemu_opt_find(opts, "reconnect");
sock->reconnect = reconnect;