On 5.11.2026 12:17, Denis V. Lunev wrote:
From: Denis V. Lunev <[email protected]>

Every user of the cpr fd table runs under the BQL: device realize and
unrealize, backend creation, RAM block allocation and freeing (the
latter also from RCU callbacks, which take the BQL), vfio MSI-X vector
setup from vCPU threads, and the cpr state save, load and cpr-exec walk
on the main thread. The table has no lock of its own and depends on
that, but nothing says so.

Say it at the declarations. The obvious way to break it is a socket
chardev preserved across CPR: its connection hooks run in the chardev's
GMainContext, which for the monitor is the QMP iothread, and that thread
must not take the BQL or out-of-band commands stop working. Such a user
needs the table to grow a lock of its own, and has to keep the saved
table and the preserved fds in agreement when a connection comes or goes
during cpr-exec. Both belong with the series that adds it.

Signed-off-by: Denis V. Lunev <[email protected]>
Cc: Maciej S. Szmigiero <[email protected]>
Cc: Peter Xu <[email protected]>
Cc: Fabiano Rosas <[email protected]>
Cc: Mark Kanda <[email protected]>
Cc: Ben Chaney <[email protected]>
Cc: Steve Sistare <[email protected]>
---
v2: replace the lock with a comment, as discussed on v1:
https://lore.kernel.org/qemu-devel/[email protected]/

  include/migration/cpr.h | 1 +
  1 file changed, 1 insertion(+)

diff --git a/include/migration/cpr.h b/include/migration/cpr.h
index 3ad084d5ba..5ac46b6207 100644
--- a/include/migration/cpr.h
+++ b/include/migration/cpr.h
@@ -28,6 +28,7 @@ typedef struct CprState {
extern CprState cpr_state; +/* The cpr fd table, including cpr_walk_fd(), is protected by the BQL. */
  bool cpr_save_fd(const char *name, int id, int fd, Error **errp);
  void cpr_delete_fd(const char *name, int id);
  int cpr_find_fd(const char *name, int id);

base-commit: f29ccc287a6cfdd51d3a4fd17fbe9af3310a0ac5

Acked-by: Maciej S. Szmigiero <[email protected]>

Thanks,
Maciej


Reply via email to