|
|
b38b0f |
From f087aa3581b13254e4de34784631f1852a9ddbec Mon Sep 17 00:00:00 2001
|
|
|
b38b0f |
From: Pino Toscano <ptoscano@redhat.com>
|
|
|
b38b0f |
Date: Mon, 8 Jul 2019 15:25:52 +0100
|
|
|
b38b0f |
Subject: [PATCH 06/39] block/ssh: Convert from DPRINTF() macro to trace events
|
|
|
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-2-ptoscano@redhat.com>
|
|
|
b38b0f |
Patchwork-id: 89415
|
|
|
b38b0f |
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH v3 01/10] block/ssh: Convert from DPRINTF() macro to trace events
|
|
|
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: Laurent Vivier <lvivier@redhat.com>
|
|
|
b38b0f |
|
|
|
b38b0f |
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
b38b0f |
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
|
|
|
b38b0f |
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
b38b0f |
Message-id: 20181213162727.17438-2-lvivier@redhat.com
|
|
|
b38b0f |
[mreitz: Fixed type of ssh_{read,write}_return's parameter to be ssize_t
|
|
|
b38b0f |
instead of size_t]
|
|
|
b38b0f |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
b38b0f |
(cherry picked from commit 023908a24de4f264dbcd22352e8a304424005bd4)
|
|
|
b38b0f |
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
|
|
|
b38b0f |
|
|
|
b38b0f |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
b38b0f |
---
|
|
|
b38b0f |
block/ssh.c | 46 +++++++++++++++++-----------------------------
|
|
|
b38b0f |
block/trace-events | 17 +++++++++++++++++
|
|
|
b38b0f |
2 files changed, 34 insertions(+), 29 deletions(-)
|
|
|
b38b0f |
|
|
|
b38b0f |
diff --git a/block/ssh.c b/block/ssh.c
|
|
|
b38b0f |
index 6a55d82..dfb3e3c 100644
|
|
|
b38b0f |
--- a/block/ssh.c
|
|
|
b38b0f |
+++ b/block/ssh.c
|
|
|
b38b0f |
@@ -41,27 +41,17 @@
|
|
|
b38b0f |
#include "qapi/qmp/qstring.h"
|
|
|
b38b0f |
#include "qapi/qobject-input-visitor.h"
|
|
|
b38b0f |
#include "qapi/qobject-output-visitor.h"
|
|
|
b38b0f |
+#include "trace.h"
|
|
|
b38b0f |
|
|
|
b38b0f |
-/* DEBUG_SSH=1 enables the DPRINTF (debugging printf) statements in
|
|
|
b38b0f |
- * this block driver code.
|
|
|
b38b0f |
- *
|
|
|
b38b0f |
+/*
|
|
|
b38b0f |
* TRACE_LIBSSH2=<bitmask> enables tracing in libssh2 itself. Note
|
|
|
b38b0f |
* that this requires that libssh2 was specially compiled with the
|
|
|
b38b0f |
* `./configure --enable-debug' option, so most likely you will have
|
|
|
b38b0f |
* to compile it yourself. The meaning of <bitmask> is described
|
|
|
b38b0f |
* here: http://www.libssh2.org/libssh2_trace.html
|
|
|
b38b0f |
*/
|
|
|
b38b0f |
-#define DEBUG_SSH 0
|
|
|
b38b0f |
#define TRACE_LIBSSH2 0 /* or try: LIBSSH2_TRACE_SFTP */
|
|
|
b38b0f |
|
|
|
b38b0f |
-#define DPRINTF(fmt, ...) \
|
|
|
b38b0f |
- do { \
|
|
|
b38b0f |
- if (DEBUG_SSH) { \
|
|
|
b38b0f |
- fprintf(stderr, "ssh: %-15s " fmt "\n", \
|
|
|
b38b0f |
- __func__, ##__VA_ARGS__); \
|
|
|
b38b0f |
- } \
|
|
|
b38b0f |
- } while (0)
|
|
|
b38b0f |
-
|
|
|
b38b0f |
typedef struct BDRVSSHState {
|
|
|
b38b0f |
/* Coroutine. */
|
|
|
b38b0f |
CoMutex lock;
|
|
|
b38b0f |
@@ -336,7 +326,7 @@ static int check_host_key_knownhosts(BDRVSSHState *s,
|
|
|
b38b0f |
switch (r) {
|
|
|
b38b0f |
case LIBSSH2_KNOWNHOST_CHECK_MATCH:
|
|
|
b38b0f |
/* OK */
|
|
|
b38b0f |
- DPRINTF("host key OK: %s", found->key);
|
|
|
b38b0f |
+ trace_ssh_check_host_key_knownhosts(found->key);
|
|
|
b38b0f |
break;
|
|
|
b38b0f |
case LIBSSH2_KNOWNHOST_CHECK_MISMATCH:
|
|
|
b38b0f |
ret = -EINVAL;
|
|
|
b38b0f |
@@ -721,8 +711,7 @@ static int connect_to_ssh(BDRVSSHState *s, BlockdevOptionsSsh *opts,
|
|
|
b38b0f |
}
|
|
|
b38b0f |
|
|
|
b38b0f |
/* Open the remote file. */
|
|
|
b38b0f |
- DPRINTF("opening file %s flags=0x%x creat_mode=0%o",
|
|
|
b38b0f |
- opts->path, ssh_flags, creat_mode);
|
|
|
b38b0f |
+ trace_ssh_connect_to_ssh(opts->path, ssh_flags, creat_mode);
|
|
|
b38b0f |
s->sftp_handle = libssh2_sftp_open(s->sftp, opts->path, ssh_flags,
|
|
|
b38b0f |
creat_mode);
|
|
|
b38b0f |
if (!s->sftp_handle) {
|
|
|
b38b0f |
@@ -890,7 +879,7 @@ static int coroutine_fn ssh_co_create_opts(const char *filename, QemuOpts *opts,
|
|
|
b38b0f |
/* Get desired file size. */
|
|
|
b38b0f |
ssh_opts->size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),
|
|
|
b38b0f |
BDRV_SECTOR_SIZE);
|
|
|
b38b0f |
- DPRINTF("total_size=%" PRIi64, ssh_opts->size);
|
|
|
b38b0f |
+ trace_ssh_co_create_opts(ssh_opts->size);
|
|
|
b38b0f |
|
|
|
b38b0f |
uri_options = qdict_new();
|
|
|
b38b0f |
ret = parse_uri(filename, uri_options, errp);
|
|
|
b38b0f |
@@ -946,7 +935,7 @@ static void restart_coroutine(void *opaque)
|
|
|
b38b0f |
BDRVSSHState *s = bs->opaque;
|
|
|
b38b0f |
AioContext *ctx = bdrv_get_aio_context(bs);
|
|
|
b38b0f |
|
|
|
b38b0f |
- DPRINTF("co=%p", restart->co);
|
|
|
b38b0f |
+ trace_ssh_restart_coroutine(restart->co);
|
|
|
b38b0f |
aio_set_fd_handler(ctx, s->sock, false, NULL, NULL, NULL, NULL);
|
|
|
b38b0f |
|
|
|
b38b0f |
aio_co_wake(restart->co);
|
|
|
b38b0f |
@@ -974,13 +963,12 @@ static coroutine_fn void co_yield(BDRVSSHState *s, BlockDriverState *bs)
|
|
|
b38b0f |
wr_handler = restart_coroutine;
|
|
|
b38b0f |
}
|
|
|
b38b0f |
|
|
|
b38b0f |
- DPRINTF("s->sock=%d rd_handler=%p wr_handler=%p", s->sock,
|
|
|
b38b0f |
- rd_handler, wr_handler);
|
|
|
b38b0f |
+ trace_ssh_co_yield(s->sock, rd_handler, wr_handler);
|
|
|
b38b0f |
|
|
|
b38b0f |
aio_set_fd_handler(bdrv_get_aio_context(bs), s->sock,
|
|
|
b38b0f |
false, rd_handler, wr_handler, NULL, &restart);
|
|
|
b38b0f |
qemu_coroutine_yield();
|
|
|
b38b0f |
- DPRINTF("s->sock=%d - back", s->sock);
|
|
|
b38b0f |
+ trace_ssh_co_yield_back(s->sock);
|
|
|
b38b0f |
}
|
|
|
b38b0f |
|
|
|
b38b0f |
/* SFTP has a function `libssh2_sftp_seek64' which seeks to a position
|
|
|
b38b0f |
@@ -1003,7 +991,7 @@ static void ssh_seek(BDRVSSHState *s, int64_t offset, int flags)
|
|
|
b38b0f |
bool force = (flags & SSH_SEEK_FORCE) != 0;
|
|
|
b38b0f |
|
|
|
b38b0f |
if (force || op_read != s->offset_op_read || offset != s->offset) {
|
|
|
b38b0f |
- DPRINTF("seeking to offset=%" PRIi64, offset);
|
|
|
b38b0f |
+ trace_ssh_seek(offset);
|
|
|
b38b0f |
libssh2_sftp_seek64(s->sftp_handle, offset);
|
|
|
b38b0f |
s->offset = offset;
|
|
|
b38b0f |
s->offset_op_read = op_read;
|
|
|
b38b0f |
@@ -1019,7 +1007,7 @@ static coroutine_fn int ssh_read(BDRVSSHState *s, BlockDriverState *bs,
|
|
|
b38b0f |
char *buf, *end_of_vec;
|
|
|
b38b0f |
struct iovec *i;
|
|
|
b38b0f |
|
|
|
b38b0f |
- DPRINTF("offset=%" PRIi64 " size=%zu", offset, size);
|
|
|
b38b0f |
+ trace_ssh_read(offset, size);
|
|
|
b38b0f |
|
|
|
b38b0f |
ssh_seek(s, offset, SSH_SEEK_READ);
|
|
|
b38b0f |
|
|
|
b38b0f |
@@ -1038,9 +1026,9 @@ static coroutine_fn int ssh_read(BDRVSSHState *s, BlockDriverState *bs,
|
|
|
b38b0f |
*/
|
|
|
b38b0f |
for (got = 0; got < size; ) {
|
|
|
b38b0f |
again:
|
|
|
b38b0f |
- DPRINTF("sftp_read buf=%p size=%zu", buf, end_of_vec - buf);
|
|
|
b38b0f |
+ trace_ssh_read_buf(buf, end_of_vec - buf);
|
|
|
b38b0f |
r = libssh2_sftp_read(s->sftp_handle, buf, end_of_vec - buf);
|
|
|
b38b0f |
- DPRINTF("sftp_read returned %zd", r);
|
|
|
b38b0f |
+ trace_ssh_read_return(r);
|
|
|
b38b0f |
|
|
|
b38b0f |
if (r == LIBSSH2_ERROR_EAGAIN || r == LIBSSH2_ERROR_TIMEOUT) {
|
|
|
b38b0f |
co_yield(s, bs);
|
|
|
b38b0f |
@@ -1094,7 +1082,7 @@ static int ssh_write(BDRVSSHState *s, BlockDriverState *bs,
|
|
|
b38b0f |
char *buf, *end_of_vec;
|
|
|
b38b0f |
struct iovec *i;
|
|
|
b38b0f |
|
|
|
b38b0f |
- DPRINTF("offset=%" PRIi64 " size=%zu", offset, size);
|
|
|
b38b0f |
+ trace_ssh_write(offset, size);
|
|
|
b38b0f |
|
|
|
b38b0f |
ssh_seek(s, offset, SSH_SEEK_WRITE);
|
|
|
b38b0f |
|
|
|
b38b0f |
@@ -1108,9 +1096,9 @@ static int ssh_write(BDRVSSHState *s, BlockDriverState *bs,
|
|
|
b38b0f |
|
|
|
b38b0f |
for (written = 0; written < size; ) {
|
|
|
b38b0f |
again:
|
|
|
b38b0f |
- DPRINTF("sftp_write buf=%p size=%zu", buf, end_of_vec - buf);
|
|
|
b38b0f |
+ trace_ssh_write_buf(buf, end_of_vec - buf);
|
|
|
b38b0f |
r = libssh2_sftp_write(s->sftp_handle, buf, end_of_vec - buf);
|
|
|
b38b0f |
- DPRINTF("sftp_write returned %zd", r);
|
|
|
b38b0f |
+ trace_ssh_write_return(r);
|
|
|
b38b0f |
|
|
|
b38b0f |
if (r == LIBSSH2_ERROR_EAGAIN || r == LIBSSH2_ERROR_TIMEOUT) {
|
|
|
b38b0f |
co_yield(s, bs);
|
|
|
b38b0f |
@@ -1185,7 +1173,7 @@ static coroutine_fn int ssh_flush(BDRVSSHState *s, BlockDriverState *bs)
|
|
|
b38b0f |
{
|
|
|
b38b0f |
int r;
|
|
|
b38b0f |
|
|
|
b38b0f |
- DPRINTF("fsync");
|
|
|
b38b0f |
+ trace_ssh_flush();
|
|
|
b38b0f |
again:
|
|
|
b38b0f |
r = libssh2_sftp_fsync(s->sftp_handle);
|
|
|
b38b0f |
if (r == LIBSSH2_ERROR_EAGAIN || r == LIBSSH2_ERROR_TIMEOUT) {
|
|
|
b38b0f |
@@ -1236,7 +1224,7 @@ static int64_t ssh_getlength(BlockDriverState *bs)
|
|
|
b38b0f |
|
|
|
b38b0f |
/* Note we cannot make a libssh2 call here. */
|
|
|
b38b0f |
length = (int64_t) s->attrs.filesize;
|
|
|
b38b0f |
- DPRINTF("length=%" PRIi64, length);
|
|
|
b38b0f |
+ trace_ssh_getlength(length);
|
|
|
b38b0f |
|
|
|
b38b0f |
return length;
|
|
|
b38b0f |
}
|
|
|
b38b0f |
diff --git a/block/trace-events b/block/trace-events
|
|
|
b38b0f |
index c35287b..4c69548 100644
|
|
|
b38b0f |
--- a/block/trace-events
|
|
|
b38b0f |
+++ b/block/trace-events
|
|
|
b38b0f |
@@ -150,3 +150,20 @@ nvme_free_req_queue_wait(void *q) "q %p"
|
|
|
b38b0f |
nvme_cmd_map_qiov(void *s, void *cmd, void *req, void *qiov, int entries) "s %p cmd %p req %p qiov %p entries %d"
|
|
|
b38b0f |
nvme_cmd_map_qiov_pages(void *s, int i, uint64_t page) "s %p page[%d] 0x%"PRIx64
|
|
|
b38b0f |
nvme_cmd_map_qiov_iov(void *s, int i, void *page, int pages) "s %p iov[%d] %p pages %d"
|
|
|
b38b0f |
+
|
|
|
b38b0f |
+# block/ssh.c
|
|
|
b38b0f |
+ssh_restart_coroutine(void *co) "co=%p"
|
|
|
b38b0f |
+ssh_flush(void) "fsync"
|
|
|
b38b0f |
+ssh_check_host_key_knownhosts(const char *key) "host key OK: %s"
|
|
|
b38b0f |
+ssh_connect_to_ssh(char *path, int flags, int mode) "opening file %s flags=0x%x creat_mode=0%o"
|
|
|
b38b0f |
+ssh_co_yield(int sock, void *rd_handler, void *wr_handler) "s->sock=%d rd_handler=%p wr_handler=%p"
|
|
|
b38b0f |
+ssh_co_yield_back(int sock) "s->sock=%d - back"
|
|
|
b38b0f |
+ssh_getlength(int64_t length) "length=%" PRIi64
|
|
|
b38b0f |
+ssh_co_create_opts(uint64_t size) "total_size=%" PRIu64
|
|
|
b38b0f |
+ssh_read(int64_t offset, size_t size) "offset=%" PRIi64 " size=%zu"
|
|
|
b38b0f |
+ssh_read_buf(void *buf, size_t size) "sftp_read buf=%p size=%zu"
|
|
|
b38b0f |
+ssh_read_return(ssize_t ret) "sftp_read returned %zd"
|
|
|
b38b0f |
+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 |
1.8.3.1
|
|
|
b38b0f |
|