On Tue, Jun 10, 2025 at 10:08:49AM -0500, Jaehoon Kim wrote:
> When the source VM attempts to connect to the destination VM's Unix
> domain socket (cpr.sock) during a cpr-transfer test, race conditions can
> occur if the socket file isn't ready. This can lead to connection
> failures when running tests.
>
> This patch creates and listens on the socket in advance, and passes the
> pre-listened FD directly. This avoids timing issues and improves the
> reliability of CPR tests.
>
> Reviewed-by: Jason J. Herne <[email protected]>
> Signed-off-by: Jaehoon Kim <[email protected]>
>
> ---
> Changes since v1:
> - In v1, the patch added a wait loop to poll the existence of the socket
> file (cpr_validate_socket_path()).
>
> - This version instead creates the socket beforehand and passes its FD
> to the destination QEMU, eliminating the race condition entirely.
>
> - Commit title and message changed accordingly.
> ---
> migration/cpr-transfer.c | 3 +-
> tests/qtest/migration/cpr-tests.c | 72 ++++++++++++++++++++++++++++++-
> 2 files changed, 72 insertions(+), 3 deletions(-)
>
> diff --git a/migration/cpr-transfer.c b/migration/cpr-transfer.c
> index e1f140359c..7c9de70bad 100644
> --- a/migration/cpr-transfer.c
> +++ b/migration/cpr-transfer.c
> @@ -46,7 +46,8 @@ QEMUFile *cpr_transfer_input(MigrationChannel *channel,
> Error **errp)
> MigrationAddress *addr = channel->addr;
>
> if (addr->transport == MIGRATION_ADDRESS_TYPE_SOCKET &&
> - addr->u.socket.type == SOCKET_ADDRESS_TYPE_UNIX) {
> + (addr->u.socket.type == SOCKET_ADDRESS_TYPE_UNIX ||
> + addr->u.socket.type == SOCKET_ADDRESS_TYPE_FD)) {
>
> g_autoptr(QIOChannelSocket) sioc = NULL;
> SocketAddress *saddr = &addr->u.socket;
This will likely cause a crash in tracing code that is below this diff:
trace_cpr_transfer_input(addr->u.socket.u.q_unix.path);
q_unix.path is NOT valid to access with TYPE_FD.
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|