Commit 17262bf41f for qemu.org
commit 17262bf41fd566370e39cd53958a6acf9ad9ebde
Author: Denis V. Lunev <den@openvz.org>
Date: Thu Nov 5 12:17:49 2026 +0100
migration/cpr: document the BQL as the cpr fd table lock
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 <den@openvz.org>
Cc: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Fabiano Rosas <farosas@suse.de>
Cc: Mark Kanda <mark.kanda@oracle.com>
Cc: Ben Chaney <bchaney@akamai.com>
Cc: Steve Sistare <steven.sistare@oracle.com>
Acked-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
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);