All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Richard W.M. Jones" <rjones@redhat.com>,
	Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>,
	qemu-block@nongnu.org
Subject: [Qemu-devel] [PULL for-4.1 06/36] block/ssh: Do not report read/write/flush errors to the user
Date: Thu, 18 Apr 2019 22:51:05 +0200	[thread overview]
Message-ID: <20190418205135.6686-7-armbru@redhat.com> (raw)
In-Reply-To: <20190418205135.6686-1-armbru@redhat.com>

Callbacks ssh_co_readv(), ssh_co_writev(), ssh_co_flush() report
errors to the user with error_printf().  They shouldn't, it's their
caller's job.  Replace by a suitable trace point.  While there, drop
the unreachable !s->sftp case.

Perhaps we should convert this part of the block driver interface to
Error, so block drivers can pass more detail to their callers.  Not
today.

Cc: "Richard W.M. Jones" <rjones@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Max Reitz <mreitz@redhat.com>
Cc: qemu-block@nongnu.org
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190417190641.26814-3-armbru@redhat.com>
---
 block/ssh.c        | 38 +++++++++++++-------------------------
 block/trace-events |  3 +++
 2 files changed, 16 insertions(+), 25 deletions(-)

diff --git a/block/ssh.c b/block/ssh.c
index 190ef95300..859249113d 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -159,31 +159,19 @@ sftp_error_setg(Error **errp, BDRVSSHState *s, const char *fs, ...)
     g_free(msg);
 }
 
-static void GCC_FMT_ATTR(2, 3)
-sftp_error_report(BDRVSSHState *s, const char *fs, ...)
+static void sftp_error_trace(BDRVSSHState *s, const char *op)
 {
-    va_list args;
+    char *ssh_err;
+    int ssh_err_code;
+    unsigned long sftp_err_code;
 
-    va_start(args, fs);
-    error_vprintf(fs, args);
+    /* This is not an errno.  See <libssh2.h>. */
+    ssh_err_code = libssh2_session_last_error(s->session,
+                                              &ssh_err, NULL, 0);
+    /* See <libssh2_sftp.h>. */
+    sftp_err_code = libssh2_sftp_last_error((s)->sftp);
 
-    if ((s)->sftp) {
-        char *ssh_err;
-        int ssh_err_code;
-        unsigned long sftp_err_code;
-
-        /* This is not an errno.  See <libssh2.h>. */
-        ssh_err_code = libssh2_session_last_error(s->session,
-                                                  &ssh_err, NULL, 0);
-        /* See <libssh2_sftp.h>. */
-        sftp_err_code = libssh2_sftp_last_error((s)->sftp);
-
-        error_printf(": %s (libssh2 error code: %d, sftp error code: %lu)",
-                     ssh_err, ssh_err_code, sftp_err_code);
-    }
-
-    va_end(args);
-    error_printf("\n");
+    trace_sftp_error(op, ssh_err, ssh_err_code, sftp_err_code);
 }
 
 static int parse_uri(const char *filename, QDict *options, Error **errp)
@@ -1035,7 +1023,7 @@ static coroutine_fn int ssh_read(BDRVSSHState *s, BlockDriverState *bs,
             goto again;
         }
         if (r < 0) {
-            sftp_error_report(s, "read failed");
+            sftp_error_trace(s, "read");
             s->offset = -1;
             return -EIO;
         }
@@ -1105,7 +1093,7 @@ static int ssh_write(BDRVSSHState *s, BlockDriverState *bs,
             goto again;
         }
         if (r < 0) {
-            sftp_error_report(s, "write failed");
+            sftp_error_trace(s, "write");
             s->offset = -1;
             return -EIO;
         }
@@ -1188,7 +1176,7 @@ static coroutine_fn int ssh_flush(BDRVSSHState *s, BlockDriverState *bs)
         return 0;
     }
     if (r < 0) {
-        sftp_error_report(s, "fsync failed");
+        sftp_error_trace(s, "fsync");
         return -EIO;
     }
 
diff --git a/block/trace-events b/block/trace-events
index 7335a42540..79ccd8d824 100644
--- a/block/trace-events
+++ b/block/trace-events
@@ -208,3 +208,6 @@ sheepdog_co_rw_vector_new(uint64_t oid) "new oid 0x%" PRIx64
 sheepdog_snapshot_create_info(const char *sn_name, const char *id, const char *name, int64_t size, int is_snapshot) "sn_info: name %s id_str %s s: name %s vm_state_size %" PRId64 " " "is_snapshot %d"
 sheepdog_snapshot_create(const char *sn_name, const char *id) "%s %s"
 sheepdog_snapshot_create_inode(const char *name, uint32_t snap, uint32_t vdi) "s->inode: name %s snap_id 0x%" PRIx32 " vdi 0x%" PRIx32
+
+# ssh.c
+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)"
-- 
2.17.2

WARNING: multiple messages have this Message-ID (diff)
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	"Richard W.M. Jones" <rjones@redhat.com>,
	qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PULL for-4.1 06/36] block/ssh: Do not report read/write/flush errors to the user
Date: Thu, 18 Apr 2019 22:51:05 +0200	[thread overview]
Message-ID: <20190418205135.6686-7-armbru@redhat.com> (raw)
Message-ID: <20190418205105.dFecGEIQPLnQmj3ymWN4rn0H8ICRAdpLxhLzw0vwNRk@z> (raw)
In-Reply-To: <20190418205135.6686-1-armbru@redhat.com>

Callbacks ssh_co_readv(), ssh_co_writev(), ssh_co_flush() report
errors to the user with error_printf().  They shouldn't, it's their
caller's job.  Replace by a suitable trace point.  While there, drop
the unreachable !s->sftp case.

Perhaps we should convert this part of the block driver interface to
Error, so block drivers can pass more detail to their callers.  Not
today.

Cc: "Richard W.M. Jones" <rjones@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Max Reitz <mreitz@redhat.com>
Cc: qemu-block@nongnu.org
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190417190641.26814-3-armbru@redhat.com>
---
 block/ssh.c        | 38 +++++++++++++-------------------------
 block/trace-events |  3 +++
 2 files changed, 16 insertions(+), 25 deletions(-)

diff --git a/block/ssh.c b/block/ssh.c
index 190ef95300..859249113d 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -159,31 +159,19 @@ sftp_error_setg(Error **errp, BDRVSSHState *s, const char *fs, ...)
     g_free(msg);
 }
 
-static void GCC_FMT_ATTR(2, 3)
-sftp_error_report(BDRVSSHState *s, const char *fs, ...)
+static void sftp_error_trace(BDRVSSHState *s, const char *op)
 {
-    va_list args;
+    char *ssh_err;
+    int ssh_err_code;
+    unsigned long sftp_err_code;
 
-    va_start(args, fs);
-    error_vprintf(fs, args);
+    /* This is not an errno.  See <libssh2.h>. */
+    ssh_err_code = libssh2_session_last_error(s->session,
+                                              &ssh_err, NULL, 0);
+    /* See <libssh2_sftp.h>. */
+    sftp_err_code = libssh2_sftp_last_error((s)->sftp);
 
-    if ((s)->sftp) {
-        char *ssh_err;
-        int ssh_err_code;
-        unsigned long sftp_err_code;
-
-        /* This is not an errno.  See <libssh2.h>. */
-        ssh_err_code = libssh2_session_last_error(s->session,
-                                                  &ssh_err, NULL, 0);
-        /* See <libssh2_sftp.h>. */
-        sftp_err_code = libssh2_sftp_last_error((s)->sftp);
-
-        error_printf(": %s (libssh2 error code: %d, sftp error code: %lu)",
-                     ssh_err, ssh_err_code, sftp_err_code);
-    }
-
-    va_end(args);
-    error_printf("\n");
+    trace_sftp_error(op, ssh_err, ssh_err_code, sftp_err_code);
 }
 
 static int parse_uri(const char *filename, QDict *options, Error **errp)
@@ -1035,7 +1023,7 @@ static coroutine_fn int ssh_read(BDRVSSHState *s, BlockDriverState *bs,
             goto again;
         }
         if (r < 0) {
-            sftp_error_report(s, "read failed");
+            sftp_error_trace(s, "read");
             s->offset = -1;
             return -EIO;
         }
@@ -1105,7 +1093,7 @@ static int ssh_write(BDRVSSHState *s, BlockDriverState *bs,
             goto again;
         }
         if (r < 0) {
-            sftp_error_report(s, "write failed");
+            sftp_error_trace(s, "write");
             s->offset = -1;
             return -EIO;
         }
@@ -1188,7 +1176,7 @@ static coroutine_fn int ssh_flush(BDRVSSHState *s, BlockDriverState *bs)
         return 0;
     }
     if (r < 0) {
-        sftp_error_report(s, "fsync failed");
+        sftp_error_trace(s, "fsync");
         return -EIO;
     }
 
diff --git a/block/trace-events b/block/trace-events
index 7335a42540..79ccd8d824 100644
--- a/block/trace-events
+++ b/block/trace-events
@@ -208,3 +208,6 @@ sheepdog_co_rw_vector_new(uint64_t oid) "new oid 0x%" PRIx64
 sheepdog_snapshot_create_info(const char *sn_name, const char *id, const char *name, int64_t size, int is_snapshot) "sn_info: name %s id_str %s s: name %s vm_state_size %" PRId64 " " "is_snapshot %d"
 sheepdog_snapshot_create(const char *sn_name, const char *id) "%s %s"
 sheepdog_snapshot_create_inode(const char *name, uint32_t snap, uint32_t vdi) "s->inode: name %s snap_id 0x%" PRIx32 " vdi 0x%" PRIx32
+
+# ssh.c
+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)"
-- 
2.17.2



  parent reply	other threads:[~2019-04-18 20:51 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-18 20:50 [Qemu-devel] [PULL for-4.1 00/36] Error reporting & monitor patches for 2019-04-18 Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 01/36] qemu-io: Use error_[gs]et_progname() Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 02/36] log: Make glib logging go through QEMU Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 03/36] error: Fix error_report_err(), warn_report_err() hint printing Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 04/36] util/error: do not free error on error_abort Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 05/36] qemu-img: Use error_vreport() in error_exit() Markus Armbruster
2019-04-18 20:51   ` Markus Armbruster
2019-04-18 20:51 ` Markus Armbruster [this message]
2019-04-18 20:51   ` [Qemu-devel] [PULL for-4.1 06/36] block/ssh: Do not report read/write/flush errors to the user Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 07/36] loader-fit: Wean off error_printf() Markus Armbruster
2019-04-18 20:51   ` Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 08/36] mips/boston: Report errors with error_report(), not error_printf() Markus Armbruster
2019-04-18 20:51   ` Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 09/36] pci: Report fatal " Markus Armbruster
2019-04-18 20:51   ` Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 10/36] hpet: Report warnings with warn_report(), " Markus Armbruster
2019-04-18 20:51   ` Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 11/36] vfio: " Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 12/36] s390x/kvm: " Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 13/36] vl: Make -machine $TYPE, help and -accel help print to stdout Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 14/36] monitor error: Make printf()-like functions return a value Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 15/36] qemu-print: New qemu_printf(), qemu_vprintf() etc Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 16/36] blockdev: Make -drive format=help print to stdout Markus Armbruster
2019-04-18 20:51   ` Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 17/36] char: Make -chardev help " Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 18/36] char-pty: Print "char device redirected" message " Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 19/36] monitor: Simplify how -device/device_add print help Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 20/36] include: Include fprintf-fn.h only where needed Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 21/36] trace: Simplify how st_print_trace_file_status() prints Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 22/36] tcg: Simplify how dump_opcount_info() prints Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 23/36] tcg: Simplify how dump_exec_info() prints Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 24/36] tcg: Simplify how dump_drift_info() prints Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 25/36] qsp: Simplify how qsp_report() prints Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 26/36] block/qapi: Clean up how we print to monitor or stdout Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 27/36] memory: Clean up how mtree_info() prints Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 28/36] target: Simplify how the TARGET_cpu_list() print Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 29/36] target: Clean up how the dump_mmu() print Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 30/36] target/i386: Simplify how x86_cpu_dump_local_apic_state() prints Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 31/36] qom/cpu: Simplify how CPUClass::dump_statistics() prints Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 32/36] qemu-print: New qemu_fprintf(), qemu_vfprintf() Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 33/36] qom/cpu: Simplify how CPUClass:cpu_dump_state() prints Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 34/36] monitor: Clean up how monitor_disas() funnels output to monitor Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 35/36] disas: Rename include/disas/bfd.h back to include/disas/dis-asm.h Markus Armbruster
2019-04-18 20:51 ` [Qemu-devel] [PULL for-4.1 36/36] include: Move fprintf_function to disas/ Markus Armbruster
2019-04-18 21:30 ` [Qemu-devel] [PULL for-4.1 00/36] Error reporting & monitor patches for 2019-04-18 no-reply
2019-04-24 12:15 ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190418205135.6686-7-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rjones@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.