|
|
b38b0f |
From 2deb556f99ae439125674fa3c6d77424048fd30c Mon Sep 17 00:00:00 2001
|
|
|
b38b0f |
From: Pino Toscano <ptoscano@redhat.com>
|
|
|
b38b0f |
Date: Mon, 8 Jul 2019 15:25:53 +0100
|
|
|
b38b0f |
Subject: [PATCH 07/39] block/ssh: Do not report read/write/flush errors to the
|
|
|
b38b0f |
user
|
|
|
b38b0f |
MIME-Version: 1.0
|
|
|
b38b0f |
Content-Type: text/plain; charset=UTF-8
|
|
|
b38b0f |
Content-Transfer-Encoding: 8bit
|
|
|
b38b0f |
|
|
|
b38b0f |
RH-Author: Pino Toscano <ptoscano@redhat.com>
|
|
|
b38b0f |
Message-id: <20190708152601.21123-3-ptoscano@redhat.com>
|
|
|
b38b0f |
Patchwork-id: 89418
|
|
|
b38b0f |
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH v3 02/10] block/ssh: Do not report read/write/flush errors to the user
|
|
|
b38b0f |
Bugzilla: 1513367
|
|
|
b38b0f |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
b38b0f |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
b38b0f |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
b38b0f |
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
|
|
|
b38b0f |
|
|
|
b38b0f |
From: Markus Armbruster <armbru@redhat.com>
|
|
|
b38b0f |
|
|
|
b38b0f |
Callbacks ssh_co_readv(), ssh_co_writev(), ssh_co_flush() report
|
|
|
b38b0f |
errors to the user with error_printf(). They shouldn't, it's their
|
|
|
b38b0f |
caller's job. Replace by a suitable trace point. While there, drop
|
|
|
b38b0f |
the unreachable !s->sftp case.
|
|
|
b38b0f |
|
|
|
b38b0f |
Perhaps we should convert this part of the block driver interface to
|
|
|
b38b0f |
Error, so block drivers can pass more detail to their callers. Not
|
|
|
b38b0f |
today.
|
|
|
b38b0f |
|
|
|
b38b0f |
Cc: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
b38b0f |
Cc: Kevin Wolf <kwolf@redhat.com>
|
|
|
b38b0f |
Cc: Max Reitz <mreitz@redhat.com>
|
|
|
b38b0f |
Cc: qemu-block@nongnu.org
|
|
|
b38b0f |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
|
|
|
b38b0f |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
b38b0f |
Message-Id: <20190417190641.26814-3-armbru@redhat.com>
|
|
|
b38b0f |
(cherry picked from commit 6b3048cee0e0eccd27b62954ecc57c4a1bceb976)
|
|
|
b38b0f |
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
b38b0f |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
b38b0f |
---
|
|
|
b38b0f |
block/ssh.c | 38 +++++++++++++-------------------------
|
|
|
b38b0f |
block/trace-events | 3 +++
|
|
|
b38b0f |
2 files changed, 16 insertions(+), 25 deletions(-)
|
|
|
b38b0f |
|
|
|
b38b0f |
diff --git a/block/ssh.c b/block/ssh.c
|
|
|
b38b0f |
index dfb3e3c..89abce0 100644
|
|
|
b38b0f |
--- a/block/ssh.c
|
|
|
b38b0f |
+++ b/block/ssh.c
|
|
|
b38b0f |
@@ -159,31 +159,19 @@ sftp_error_setg(Error **errp, BDRVSSHState *s, const char *fs, ...)
|
|
|
b38b0f |
g_free(msg);
|
|
|
b38b0f |
}
|
|
|
b38b0f |
|
|
|
b38b0f |
-static void GCC_FMT_ATTR(2, 3)
|
|
|
b38b0f |
-sftp_error_report(BDRVSSHState *s, const char *fs, ...)
|
|
|
b38b0f |
+static void sftp_error_trace(BDRVSSHState *s, const char *op)
|
|
|
b38b0f |
{
|
|
|
b38b0f |
- va_list args;
|
|
|
b38b0f |
-
|
|
|
b38b0f |
- va_start(args, fs);
|
|
|
b38b0f |
- error_vprintf(fs, args);
|
|
|
b38b0f |
+ char *ssh_err;
|
|
|
b38b0f |
+ int ssh_err_code;
|
|
|
b38b0f |
+ unsigned long sftp_err_code;
|
|
|
b38b0f |
|
|
|
b38b0f |
- if ((s)->sftp) {
|
|
|
b38b0f |
- char *ssh_err;
|
|
|
b38b0f |
- int ssh_err_code;
|
|
|
b38b0f |
- unsigned long sftp_err_code;
|
|
|
b38b0f |
+ /* This is not an errno. See <libssh2.h>. */
|
|
|
b38b0f |
+ ssh_err_code = libssh2_session_last_error(s->session,
|
|
|
b38b0f |
+ &ssh_err, NULL, 0);
|
|
|
b38b0f |
+ /* See <libssh2_sftp.h>. */
|
|
|
b38b0f |
+ sftp_err_code = libssh2_sftp_last_error((s)->sftp);
|
|
|
b38b0f |
|
|
|
b38b0f |
- /* This is not an errno. See <libssh2.h>. */
|
|
|
b38b0f |
- ssh_err_code = libssh2_session_last_error(s->session,
|
|
|
b38b0f |
- &ssh_err, NULL, 0);
|
|
|
b38b0f |
- /* See <libssh2_sftp.h>. */
|
|
|
b38b0f |
- sftp_err_code = libssh2_sftp_last_error((s)->sftp);
|
|
|
b38b0f |
-
|
|
|
b38b0f |
- error_printf(": %s (libssh2 error code: %d, sftp error code: %lu)",
|
|
|
b38b0f |
- ssh_err, ssh_err_code, sftp_err_code);
|
|
|
b38b0f |
- }
|
|
|
b38b0f |
-
|
|
|
b38b0f |
- va_end(args);
|
|
|
b38b0f |
- error_printf("\n");
|
|
|
b38b0f |
+ trace_sftp_error(op, ssh_err, ssh_err_code, sftp_err_code);
|
|
|
b38b0f |
}
|
|
|
b38b0f |
|
|
|
b38b0f |
static int parse_uri(const char *filename, QDict *options, Error **errp)
|
|
|
b38b0f |
@@ -1035,7 +1023,7 @@ static coroutine_fn int ssh_read(BDRVSSHState *s, BlockDriverState *bs,
|
|
|
b38b0f |
goto again;
|
|
|
b38b0f |
}
|
|
|
b38b0f |
if (r < 0) {
|
|
|
b38b0f |
- sftp_error_report(s, "read failed");
|
|
|
b38b0f |
+ sftp_error_trace(s, "read");
|
|
|
b38b0f |
s->offset = -1;
|
|
|
b38b0f |
return -EIO;
|
|
|
b38b0f |
}
|
|
|
b38b0f |
@@ -1105,7 +1093,7 @@ static int ssh_write(BDRVSSHState *s, BlockDriverState *bs,
|
|
|
b38b0f |
goto again;
|
|
|
b38b0f |
}
|
|
|
b38b0f |
if (r < 0) {
|
|
|
b38b0f |
- sftp_error_report(s, "write failed");
|
|
|
b38b0f |
+ sftp_error_trace(s, "write");
|
|
|
b38b0f |
s->offset = -1;
|
|
|
b38b0f |
return -EIO;
|
|
|
b38b0f |
}
|
|
|
b38b0f |
@@ -1186,7 +1174,7 @@ static coroutine_fn int ssh_flush(BDRVSSHState *s, BlockDriverState *bs)
|
|
|
b38b0f |
return 0;
|
|
|
b38b0f |
}
|
|
|
b38b0f |
if (r < 0) {
|
|
|
b38b0f |
- sftp_error_report(s, "fsync failed");
|
|
|
b38b0f |
+ sftp_error_trace(s, "fsync");
|
|
|
b38b0f |
return -EIO;
|
|
|
b38b0f |
}
|
|
|
b38b0f |
|
|
|
b38b0f |
diff --git a/block/trace-events b/block/trace-events
|
|
|
b38b0f |
index 4c69548..23c9963 100644
|
|
|
b38b0f |
--- a/block/trace-events
|
|
|
b38b0f |
+++ b/block/trace-events
|
|
|
b38b0f |
@@ -167,3 +167,6 @@ ssh_write(int64_t offset, size_t size) "offset=%" PRIi64 " size=%zu"
|
|
|
b38b0f |
ssh_write_buf(void *buf, size_t size) "sftp_write buf=%p size=%zu"
|
|
|
b38b0f |
ssh_write_return(ssize_t ret) "sftp_write returned %zd"
|
|
|
b38b0f |
ssh_seek(int64_t offset) "seeking to offset=%" PRIi64
|
|
|
b38b0f |
+
|
|
|
b38b0f |
+# ssh.c
|
|
|
b38b0f |
+sftp_error(const char *op, const char *ssh_err, int ssh_err_code, unsigned long sftp_err_code) "%s failed: %s (libssh2 error code: %d, sftp error code: %lu)"
|
|
|
b38b0f |
--
|
|
|
b38b0f |
1.8.3.1
|
|
|
b38b0f |
|