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
char-console.c
char-fd.c
char-fe.c
char-file.c
char-hmp-cmds.c
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
char-null.c
char-parallel.c
char-pipe.c
char-pty.c chardev: add path option for pty backend 2024-10-09 12:13:05 +04:00
char-ringbuf.c
char-serial.c
char-socket.c chardev: introduce 'reconnect-ms' and deprecate 'reconnect' 2024-10-09 12:07:54 +04:00
char-stdio.c
char-udp.c
char-win-stdio.c chardev/char-win-stdio.c: restore old console mode 2024-07-22 22:25:46 +04:00
char-win.c
char.c chardev: add path option for pty backend 2024-10-09 12:13:05 +04:00
chardev-internal.h
meson.build
msmouse.c util/fifo8: Rename fifo8_pop_buf() -> fifo8_pop_bufptr() 2024-07-23 22:34:54 +02:00
spice.c
testdev.c
trace-events chardev: add tracing of socket error conditions 2024-07-24 10:39:10 +01:00
trace.h
wctablet.c