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