qemu/chardev
Octavian Purdila b74cb8761c chardev: add path option for pty backend
Add path option to the pty char backend which will create a symbolic
link to the given path that points to the allocated PTY.

This avoids having to make QMP or HMP monitor queries to find out what
the new PTY device path is.

Based on patch from Paulo Neves:

https://patchew.org/QEMU/1548509635-15776-1-git-send-email-ptsneves@gmail.com/

Tested with the following invocations that the link is created and
removed when qemu stops:

  qemu-system-x86_64 -nodefaults -mon chardev=compat_monitor \
  -chardev pty,path=test,id=compat_monitor0

  qemu-system-x86_64 -nodefaults -monitor pty:test

  # check QMP invocation with path set
  qemu-system-x86_64 -nodefaults -qmp tcp:localhost:4444,server=on,wait=off
  nc localhost 4444
  > {"execute": "qmp_capabilities"}
  > {"execute": "chardev-add", "arguments": {"id": "bar", "backend": {
      "type": "pty", "data": {"path": "test" }}}}

  # check QMP invocation with path not set
  qemu-system-x86_64 -nodefaults -qmp tcp:localhost:4444,server=on,wait=off
  nc localhost 4444
  > {"execute": "qmp_capabilities"}
  > {"execute": "chardev-add", "arguments": {"id": "bar", "backend": {
      "type": "pty", "data": {}}}}

Also tested that when a link path is not passed invocations still work, e.g.:

  qemu-system-x86_64 -monitor pty

Co-authored-by: Paulo Neves <ptsneves@gmail.com>
Signed-off-by: Paulo Neves <ptsneves@gmail.com>
[OP: rebase and address original patch review comments]
Signed-off-by: Octavian Purdila <tavip@google.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20240806010735.2450555-1-tavip@google.com>
2024-10-09 12:13:05 +04:00
..
baum.c replace TABs with spaces 2023-03-20 12:43:50 +01:00
char-console.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
char-fd.c Refactoring: refactor TFR() macro to RETRY_ON_EINTR() 2023-01-09 13:50:47 +01:00
char-fe.c error: Drop superfluous #include "qapi/qmp/qerror.h" 2024-04-24 09:50:58 +02:00
char-file.c chardev: Allow setting file chardev input file on the command line 2023-04-20 06:50:11 +02:00
char-hmp-cmds.c char: Move HMP commands from monitor/ to chardev/ 2023-02-04 07:56:54 +01:00
char-io.c Revert "qemu-char: do not operate on sources from finalize callbacks" 2024-07-16 10:45:06 +02:00
char-mux.c chardev: don't exit() straight away on C-a x 2021-11-04 10:32:01 +00:00
char-null.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
char-parallel.c chardev/parallel: Don't close stdin on inappropriate device 2024-02-14 07:44:38 +01:00
char-pipe.c Refactoring: refactor TFR() macro to RETRY_ON_EINTR() 2023-01-09 13:50:47 +01:00
char-pty.c chardev: add path option for pty backend 2024-10-09 12:13:05 +04:00
char-ringbuf.c Use DECLARE_*CHECKER* macros 2020-09-09 09:27:09 -04:00
char-serial.c chardev: replace qemu_set_nonblock() 2022-05-03 15:51:52 +04:00
char-socket.c chardev: introduce 'reconnect-ms' and deprecate 'reconnect' 2024-10-09 12:07:54 +04:00
char-stdio.c char-stdio: Restore blocking mode of stdout on exit 2024-07-03 21:54:41 +02:00
char-udp.c qapi chardev: Elide redundant has_FOO in generated C 2022-12-14 20:04:47 +01:00
char-win-stdio.c chardev/char-win-stdio.c: restore old console mode 2024-07-22 22:25:46 +04:00
char-win.c chardev: Improve error report by calling error_setg_win32() 2020-03-09 13:36:15 +01:00
char.c chardev: add path option for pty backend 2024-10-09 12:13:05 +04:00
chardev-internal.h Clean up decorations and whitespace around header guards 2022-05-11 16:50:32 +02:00
meson.build chardev/parallel: Don't close stdin on inappropriate device 2024-02-14 07:44:38 +01:00
msmouse.c util/fifo8: Rename fifo8_pop_buf() -> fifo8_pop_bufptr() 2024-07-23 22:34:54 +02:00
spice.c ui/spice: Require spice-server >= 0.14.0 2023-01-19 13:30:01 +01:00
testdev.c Use DECLARE_*CHECKER* macros 2020-09-09 09:27:09 -04:00
trace-events chardev: add tracing of socket error conditions 2024-07-24 10:39:10 +01:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
wctablet.c ui/input: Constify QemuInputHandler structure 2023-10-19 23:13:28 +02:00