From fdd0468f6da2e8bd7ac1414a0150efc471fa1291 Mon Sep 17 00:00:00 2001 From: qihao_yewu Date: Fri, 1 Aug 2025 01:49:10 -0400 Subject: [PATCH] ssh: Do not switch session to non-blocking mode cheery-pick from 6d52a53e7bd886e7852a6be9694901a23752c88f The libssh does not handle non-blocking mode in SFTP correctly. The driver code already changes the mode to blocking for the SFTP initialization, but for some reason changes to non-blocking mode. This used to work accidentally until libssh in 0.11 branch merged the patch to avoid infinite looping in case of network errors: https://gitlab.com/libssh/libssh-mirror/-/merge_requests/498 Since then, the ssh driver in qemu fails to read files over SFTP as the first SFTP messages exchanged after switching the session to non-blocking mode return SSH_AGAIN, but that message is lost int the SFTP internals and interpretted as SSH_ERROR, which is returned to the caller: https://gitlab.com/libssh/libssh-mirror/-/issues/280 This is indeed an issue in libssh that we should address in the long term, but it will require more work on the internals. For now, the SFTP is not supported in non-blocking mode. Fixes: https://gitlab.com/libssh/libssh-mirror/-/issues/280 Signed-off-by: Jakub Jelen Signed-off-by: Richard W.M. Jones Message-ID: <20241113125526.2495731-1-rjones@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf (cherry picked from commit fbdea3d6c13d5a75895c287a004c6f1a6bf6c164) Signed-off-by: Michael Tokarev Signed-off-by: qihao_yewu --- block/ssh.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/block/ssh.c b/block/ssh.c index 2748253d4a..b2da9bb4c8 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -860,9 +860,6 @@ static int ssh_file_open(BlockDriverState *bs, QDict *options, int bdrv_flags, goto err; } - /* Go non-blocking. */ - ssh_set_blocking(s->session, 0); - if (s->attrs->type == SSH_FILEXFER_TYPE_REGULAR) { bs->supported_truncate_flags = BDRV_REQ_ZERO_WRITE; } -- Gitee