24fa7da3 | 21-Feb-2019 |
Marc-André Lureau <marcandre.lureau@redhat.com> |
char: move SpiceChardev and open_spice_port() to spice.h header
This will allow easier subclassing of SpiceChardev, in upcoming "display: add -display spice-app launching external application" patch
char: move SpiceChardev and open_spice_port() to spice.h header
This will allow easier subclassing of SpiceChardev, in upcoming "display: add -display spice-app launching external application" patch.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Tested-by: Victor Toso <victortoso@redhat.com> Message-id: 20190221110703.5775-7-marcandre.lureau@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
show more ...
|
a2dc3c8e | 21-Feb-2019 |
Marc-André Lureau <marcandre.lureau@redhat.com> |
char/spice: discard write() if backend is disconnected
Most chardev backend handle write() as discarded data if underlying system is disconnected. For unknown historical reasons, the Spice backend h
char/spice: discard write() if backend is disconnected
Most chardev backend handle write() as discarded data if underlying system is disconnected. For unknown historical reasons, the Spice backend has "reliable" write: it will wait until the client end is reconnected to do further successful write().
To decide whether it make sense to wait until the client is reconnected (or queue the writes), let's review Spice chardev usage and handling of a disconnected client:
* spice vdagent The agents reopen the virtio port on disconnect. In qemu side, virtio_serial_close() will also discard pending data.
* usb redirection A disconnect creates a device disconnection.
* smartcard emulation Data is discarded in passthru_apdu_from_guest().
(Spice doesn't explicitly open the smartcard char device until upcoming 0.14.2, commit 69a5cfc74131ec0459f2eb5a231139f5a69a8037)
* spice webdavd The daemon will restart the service, and reopen the virtio port.
* spice ports (serial console, qemu monitor..) Depends on the associated device or usage.
- serial, may be throttled or discarded on write, depending on device
- QMP/HMP monitor have some CLOSED event handling, but want to flush the write, which will finish when a new client connects.
On disconnect/reconnect, the client starts with fresh sessions. If it is a seamless migration, the client disconnects after the source migrated. The handling of source disconnect in qemu is thus irrelevant for the Spice session migration.
For all these use cases, it is better to discard writes when the client is disconnected, and require the vm-side device/agent to behave correctly on CHR_EVENT_CLOSED, to stop reading and writing from the spice chardev.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Tested-by: Victor Toso <victortoso@redhat.com> Message-id: 20190221110703.5775-3-marcandre.lureau@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
show more ...
|
f7ea2038 | 06-Feb-2019 |
Marc-André Lureau <marcandre.lureau@redhat.com> |
char-pty: remove write_lock usage
The lock usage was described with its introduction in commit 9005b2a7589540a3733b3abdcfbccfe7746cd1a1. It was necessary because PTY write() shares more state than G
char-pty: remove write_lock usage
The lock usage was described with its introduction in commit 9005b2a7589540a3733b3abdcfbccfe7746cd1a1. It was necessary because PTY write() shares more state than GIOChannel with other operations.
This made char-pty a bit different from other chardev, that only lock around the write operation. This was apparent in commit 7b3621f47a990c5099c6385728347f69a8d0e55c, which introduced an idle source to avoid the lock.
By removing the PTY chardev state sharing on write() with previous patch, we can remove the lock and the idle source.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20190206174328.9736-7-marcandre.lureau@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
f8278c7d | 06-Feb-2019 |
Marc-André Lureau <marcandre.lureau@redhat.com> |
char-pty: remove the check for connection on write
This doesn't help much compared to the 1 second poll PTY timer. I can't think of a use case where this would help.
However, we can simplify the co
char-pty: remove the check for connection on write
This doesn't help much compared to the 1 second poll PTY timer. I can't think of a use case where this would help.
However, we can simplify the code around chr_write(): the write lock is no longer needed for other char-pty callbacks (see following patch).
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20190206174328.9736-6-marcandre.lureau@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
3d9e2322 | 06-Feb-2019 |
Marc-André Lureau <marcandre.lureau@redhat.com> |
char: update the mux handlers in class callback
Instead of handling mux chardev in a special way in qemu_chr_fe_set_handlers(), we may use the chr_update_read_handler class callback instead.
Signed
char: update the mux handlers in class callback
Instead of handling mux chardev in a special way in qemu_chr_fe_set_handlers(), we may use the chr_update_read_handler class callback instead.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20190206174328.9736-2-marcandre.lureau@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
129263c6 | 13-Feb-2019 |
Philippe Mathieu-Daudé <philmd@redhat.com> |
chardev/wctablet: Fix a typo
The correct name is Wacom. Fix the typo which is present since 378af96155d.
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Philippe Mathieu
chardev/wctablet: Fix a typo
The correct name is Wacom. Fix the typo which is present since 378af96155d.
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20190213123446.1768-1-philmd@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
show more ...
|
4ad6f6cb | 13-Feb-2019 |
Paolo Bonzini <pbonzini@redhat.com> |
char: allow specifying a GMainContext at opening time
This will be needed by vhost-user-test, when each test switches to its own GMainLoop and GMainContext. Otherwise, for a reconnecting socket the
char: allow specifying a GMainContext at opening time
This will be needed by vhost-user-test, when each test switches to its own GMainLoop and GMainContext. Otherwise, for a reconnecting socket the initial connection will happen on the default GMainContext, and no one will be listening on it.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20190202110834.24880-1-pbonzini@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
show more ...
|
211ef6c4 | 11-Feb-2019 |
Daniel P. Berrangé <berrange@redhat.com> |
chardev: ensure termios is fully initialized
valgrind on the test-char.c code reports that 'struct termios' contains uninitialized memory.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Me
chardev: ensure termios is fully initialized
valgrind on the test-char.c code reports that 'struct termios' contains uninitialized memory.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20190211182442.8542-17-berrange@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
show more ...
|
4b47373a | 11-Feb-2019 |
Daniel P. Berrangé <berrange@redhat.com> |
chardev: fix race with client connections in tcp_chr_wait_connected
When the 'reconnect' option is given for a client connection, the qmp_chardev_open_socket_client method will run an asynchronous c
chardev: fix race with client connections in tcp_chr_wait_connected
When the 'reconnect' option is given for a client connection, the qmp_chardev_open_socket_client method will run an asynchronous connection attempt. The QIOChannel socket executes this is a single use background thread, so the connection will succeed immediately (assuming the server is listening). The chardev, however, won't get the result from this background thread until the main loop starts running and processes idle callbacks.
Thus when tcp_chr_wait_connected is run s->ioc will be NULL, but the state will be TCP_CHARDEV_STATE_CONNECTING, and there may already be an established connection that will be associated with the chardev by the pending idle callback. tcp_chr_wait_connected doesn't check the state, only s->ioc, so attempts to establish another connection synchronously.
If the server allows multiple connections this is unhelpful but not a fatal problem as the duplicate connection will get ignored by the tcp_chr_new_client method when it sees the state is already connected.
If the server only supports a single connection, however, the tcp_chr_wait_connected method will hang forever because the server will not accept its synchronous connection attempt until the first connection is closed.
To deal with this tcp_chr_wait_connected needs to synchronize with the completion of the background connection task. To do this it needs to create the QIOTask directly and use the qio_task_wait_thread method. This will cancel the pending idle callback and directly dispatch the task completion callback, allowing the connection to be associated with the chardev. If the background connection failed, it can still attempt a new synchronous connection.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20190211182442.8542-15-berrange@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
show more ...
|
d1885e54 | 11-Feb-2019 |
Daniel P. Berrangé <berrange@redhat.com> |
chardev: disallow TLS/telnet/websocket with tcp_chr_wait_connected
In the previous commit
commit 1dc8a6695c731abb7461c637b2512c3670d82be4 Author: Marc-André Lureau <marcandre.lureau@redhat.
chardev: disallow TLS/telnet/websocket with tcp_chr_wait_connected
In the previous commit
commit 1dc8a6695c731abb7461c637b2512c3670d82be4 Author: Marc-André Lureau <marcandre.lureau@redhat.com> Date: Tue Aug 16 12:33:32 2016 +0400
char: fix waiting for TLS and telnet connection
the tcp_chr_wait_connected() method was changed to check for a non-NULL 's->ioc' as a sign that there is already a connection present, as opposed to checking the "connected" flag to supposedly fix handling of TLS/telnet connections.
The original code would repeatedly call tcp_chr_wait_connected creating many connections as 'connected' would never become true. The changed code would still repeatedly call tcp_chr_wait_connected busy waiting because s->ioc is set but the chardev will never see CHR_EVENT_OPENED. IOW, the code is still broken with TLS/telnet, but in a different way.
Checking for a non-NULL 's->ioc' does not mean that a CHR_EVENT_OPENED will be ready for a TLS/telnet connection. These protocols (and the websocket protocol) all require the main loop to be running in order to complete the protocol handshake before emitting CHR_EVENT_OPENED. The tcp_chr_wait_connected() method is only used during early startup before a main loop is running, so TLS/telnet/websock connections can never complete initialization.
Making this work would require changing tcp_chr_wait_connected to run a main loop. This is quite complex since we must not allow GSource's that other parts of QEMU have registered to run yet. The current callers of tcp_chr_wait_connected do not require use of the TLS/telnet/websocket protocols, so the simplest option is to just forbid this combination completely for now.
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20190211182442.8542-14-berrange@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
show more ...
|
25d93b6a | 11-Feb-2019 |
Daniel P. Berrangé <berrange@redhat.com> |
chardev: honour the reconnect setting in tcp_chr_wait_connected
If establishing a client connection fails, the tcp_chr_wait_connected method should sleep for the reconnect timeout and then retry the
chardev: honour the reconnect setting in tcp_chr_wait_connected
If establishing a client connection fails, the tcp_chr_wait_connected method should sleep for the reconnect timeout and then retry the attempt. This ensures the callers don't immediately abort with an error when the initial connection fails.
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20190211182442.8542-13-berrange@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
show more ...
|
32423cca | 11-Feb-2019 |
Daniel P. Berrangé <berrange@redhat.com> |
chardev: use a state machine for socket connection state
The socket connection state is indicated via the 'bool connected' field in the SocketChardev struct. This variable is somewhat misleading tho
chardev: use a state machine for socket connection state
The socket connection state is indicated via the 'bool connected' field in the SocketChardev struct. This variable is somewhat misleading though, as it is only set to true once the connection has completed all required handshakes (eg for TLS, telnet or websockets). IOW there is a period of time in which the socket is connected, but the "connected" flag is still false.
The socket chardev really has three states that it can be in, disconnected, connecting and connected and those should be tracked explicitly.
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20190211182442.8542-12-berrange@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
show more ...
|
b5e18e51 | 11-Feb-2019 |
Daniel P. Berrangé <berrange@redhat.com> |
chardev: split up qmp_chardev_open_socket connection code
In qmp_chardev_open_socket the code for connecting client chardevs is split across two conditionals far apart with some server chardev code
chardev: split up qmp_chardev_open_socket connection code
In qmp_chardev_open_socket the code for connecting client chardevs is split across two conditionals far apart with some server chardev code in the middle. Split up the method so that code for client connection setup is separate from code for server connection setup.
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20190211182442.8542-11-berrange@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
show more ...
|
efae0b92 | 11-Feb-2019 |
Daniel P. Berrangé <berrange@redhat.com> |
chardev: split tcp_chr_wait_connected into two methods
The tcp_chr_wait_connected method can deal with either server or client chardevs, but some callers only care about one of these possibilities.
chardev: split tcp_chr_wait_connected into two methods
The tcp_chr_wait_connected method can deal with either server or client chardevs, but some callers only care about one of these possibilities. The tcp_chr_wait_connected method will also need some refactoring to reliably deal with its primary goal of allowing a device frontend to wait for an established connection, which will interfere with other callers.
Split it into two methods, one responsible for server initiated connections, the other responsible for client initiated connections. In doing this split the tcp_char_connect_async() method is renamed to become consistent with naming of the new methods.
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20190211182442.8542-10-berrange@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
show more ...
|
e154fd79 | 11-Feb-2019 |
Daniel P. Berrangé <berrange@redhat.com> |
chardev: remove unused 'sioc' variable & cleanup paths
The 'sioc' variable in qmp_chardev_open_socket was unused since
commit 3e7d4d20d3a528b1ed10b1dc3d83119bfb0c5f24 Author: Peter Xu <peterx@r
chardev: remove unused 'sioc' variable & cleanup paths
The 'sioc' variable in qmp_chardev_open_socket was unused since
commit 3e7d4d20d3a528b1ed10b1dc3d83119bfb0c5f24 Author: Peter Xu <peterx@redhat.com> Date: Tue Mar 6 13:33:17 2018 +0800
chardev: use chardev's gcontext for async connect
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-9-berrange@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
show more ...
|
0bf62dc8 | 11-Feb-2019 |
Daniel P. Berrangé <berrange@redhat.com> |
chardev: ensure qemu_chr_parse_compat reports missing driver error
If no valid char driver was identified the qemu_chr_parse_compat method was silent, leaving callers no clue what failed.
Signed-of
chardev: ensure qemu_chr_parse_compat reports missing driver error
If no valid char driver was identified the qemu_chr_parse_compat method was silent, leaving callers no clue what failed.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20190211182442.8542-8-berrange@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
show more ...
|
5981c3a2 | 11-Feb-2019 |
Daniel P. Berrangé <berrange@redhat.com> |
chardev: remove many local variables in qemu_chr_parse_socket
Now that all validation is separated off into a separate method, we can directly populate the ChardevSocket struct from the QemuOpts val
chardev: remove many local variables in qemu_chr_parse_socket
Now that all validation is separated off into a separate method, we can directly populate the ChardevSocket struct from the QemuOpts values, avoiding many local variables.
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20190211182442.8542-7-berrange@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
show more ...
|
767abe7f | 11-Feb-2019 |
Daniel P. Berrangé <berrange@redhat.com> |
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
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>
show more ...
|
4a0582f6 | 11-Feb-2019 |
Daniel P. Berrangé <berrange@redhat.com> |
chardev: forbid 'reconnect' option with server sockets
The 'reconnect' option is used to give the sleep time, in seconds, before a client socket attempts to re-establish a connection to the server.
chardev: forbid 'reconnect' option with server sockets
The 'reconnect' option is used to give the sleep time, in seconds, before a client socket attempts to re-establish a connection to the server. It does not make sense to set this for server sockets, as they will always accept a new client connection immediately after the previous one went away.
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-5-berrange@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
show more ...
|
1645984b | 11-Feb-2019 |
Daniel P. Berrangé <berrange@redhat.com> |
chardev: fix validation of options for QMP created chardevs
The TLS creds option is not valid with certain address types. The user config was only checked for errors when parsing legacy QemuOpts, th
chardev: fix validation of options for QMP created chardevs
The TLS creds option is not valid with certain address types. The user config was only checked for errors when parsing legacy QemuOpts, thus the user could pass unsupported values via QMP.
Pull all code for validating options out into a new method qmp_chardev_validate_socket, that is called from the main qmp_chardev_open_socket method. This adds a missing check for rejecting TLS creds with the vsock address type.
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20190211182442.8542-4-berrange@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
show more ...
|