1
0
mirror of https://gitlab.com/qemu-project/qemu synced 2024-07-03 08:19:15 +00:00
qemu/tests
Fabiano Rosas 87d67fadb9 monitor: Stop removing non-duplicated fds
monitor_fdsets_cleanup() currently has three responsibilities:

1- Remove the fds that have been marked for removal(->removed=true) by
   qmp_remove_fd(). This is overly complicated, but ok.

2- Remove any file descriptors that have been passed into QEMU and
   never duplicated[1,2]. A file descriptor without duplicates
   indicates that no part of QEMU has made use of it. This is
   problematic because the current implementation does it only if the
   guest is not running and the monitor is closed.

3- Remove/free fdsets that have become empty due to the above
   removals. This is ok.

The scenario described in (2) is starting to show some cracks now that
we're trying to consume fds from the migration code:

- Doing cleanup every time the last monitor connection closes works to
  reap unused fds, but also has the side effect of forcing the
  management layer to pass the file descriptors again in case of a
  disconnect/re-connect, if that happened to be the only monitor
  connection.

  Another side effect is that removing an fd with qmp_remove_fd() is
  effectively delayed until the last monitor connection closes.

  The usage of mon_refcount is also problematic because it's racy.

- Checking runstate_is_running() skips the cleanup unless the VM is
  running and avoids premature cleanup of the fds, but also has the
  side effect of blocking the legitimate removal of an fd via
  qmp_remove_fd() if the VM happens to be in another state.

  This affects qmp_remove_fd() and qmp_query_fdsets() in particular
  because requesting a removal at a bad time (guest stopped) might
  cause an fd to never be removed, or to be removed at a much later
  point in time, causing the query command to continue showing the
  supposedly removed fd/fdset.

Note that file descriptors that *have* been duplicated are owned by
the code that uses them and will be removed after qemu_close() is
called. Therefore we've decided that the best course of action to
avoid the undesired side-effects is to stop managing non-duplicated
file descriptors.

1- efb87c1697 ("monitor: Clean up fd sets on monitor disconnect")
2- ebe52b592d ("monitor: Prevent removing fd from set during init")

Reviewed-by: Peter Xu <peterx@redhat.com>
[fix logic mistake: s/fdset_free/fdset_free_if_empty]
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2024-06-21 09:44:53 -03:00
..
avocado hw/i386/pc: Remove PCMachineClass::enforce_aligned_dimm 2024-06-19 12:40:49 +02:00
bench tests/bench: Add bufferiszero-bench 2024-05-03 08:03:35 -07:00
data tests: acpi: update expected SSDT.dimmpxm blob 2024-03-18 08:42:46 -04:00
decode tests/: spelling fixes 2023-09-08 13:08:52 +03:00
docker test: Remove libibumad dependence 2024-06-12 10:21:49 +02:00
fp tests/fp: Bump fp-test-mulAdd test timeout to 3 minutes 2024-01-12 13:23:48 +00:00
guest-debug tests: Gently exit from GDB when tests complete 2024-05-17 16:49:04 +02:00
image-fuzzer
include
keys
lcitool test: Remove libibumad dependence 2024-06-12 10:21:49 +02:00
migration tests/qtest/migration-test: Use custom asm bios for ppc64 2024-06-14 14:01:23 -03:00
multiboot
perf/block/qcow2
plugin tests/plugin/inline: add test for conditional callback 2024-05-16 08:55:23 +01:00
qapi-schema qapi: Rename visitor parameter @variants to @alternatives 2024-05-06 12:38:27 +02:00
qemu-iotests iotests: test NBD+TLS+iothread 2024-06-03 09:17:11 -05:00
qtest monitor: Stop removing non-duplicated fds 2024-06-21 09:44:53 -03:00
rocker
tcg tests/tcg/s390x: Allow specifying extra QEMU options on the command line 2024-06-12 12:12:28 +02:00
tsan block: remove AioContext locking 2023-12-21 22:49:27 +01:00
uefi-test-tools tests/: spelling fixes 2023-09-08 13:08:52 +03:00
unit * Fix loongarch64 avocado test 2024-06-13 07:51:58 -07:00
vm tests/vm: remove plain centos image 2024-06-06 10:25:51 +01:00
vmstate-static-checker-data
dbus-vmstate-daemon.sh
Makefile.include tests: respect --enable/--disable-download for Avocado 2023-11-24 12:07:47 +01:00
meson.build tests: only build plugins if TCG is enabled 2024-04-18 11:17:27 +02:00
test-qht-par.c
vhost-user-bridge.c