From: Stefan Hajnoczi <stefanha@gmail.com>
To: "Richard W.M. Jones" <rjones@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v7 1/2] block: Add support for Secure Shell (ssh) block device.
Date: Mon, 8 Apr 2013 16:41:48 +0200 [thread overview]
Message-ID: <20130408144148.GI4429@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <1365167273-28050-2-git-send-email-rjones@redhat.com>
On Fri, Apr 05, 2013 at 02:07:52PM +0100, Richard W.M. Jones wrote:
> +/* DEBUG_SSH=1 enables the DPRINTF (debugging printf) statements in
> + * this block driver code.
> + *
> + * TRACE_LIBSSH2=<bitmask> enables tracing in libssh2 itself. Note
> + * that this requires that libssh2 was specially compiled with the
> + * `./configure --enable-debug' option, so most likely you will have
> + * to compile it yourself. The meaning of <bitmask> is described
> + * here: http://www.libssh2.org/libssh2_trace.html
> + */
> +#define DEBUG_SSH 0
> +#define TRACE_LIBSSH2 0 /* or try: LIBSSH2_TRACE_SFTP */
> +
> +#if DEBUG_SSH
> +#define DPRINTF(fmt,...) \
> + do { \
> + fprintf(stderr, "ssh: %-15s " fmt "\n", __func__, ##__VA_ARGS__); \
> + } while (0)
> +#else
> +#define DPRINTF(fmt,...) /* nothing */
> +#endif
The following approach keeps syntax and format string error checking
even when DEBUG_SSH if 0:
#define DPRINTF(fmt, ...) \
do { \
if (DEBUG_SSH) { \
fprintf(stderr, "ssh: %-15s " fmt "\n", \
__func__, ##__VA_ARGS__); \
} \
} while (0)
It avoids DPRINTF() bitrot.
> +#define LOCK(s) do { \
> + DPRINTF("acquiring the lock"); \
> + qemu_co_mutex_lock(&s->lock); \
> + DPRINTF("acquired the lock"); \
> + } while (0)
> +
> +#define UNLOCK(s) do { \
> + qemu_co_mutex_unlock(&s->lock); \
> + DPRINTF("released the lock"); \
> + } while (0)
See ./trace-events:
qemu_co_mutex_lock_entry(void *mutex, void *self) "mutex %p self %p"
qemu_co_mutex_lock_return(void *mutex, void *self) "mutex %p self %p"
qemu_co_mutex_unlock_entry(void *mutex, void *self) "mutex %p self %p"
qemu_co_mutex_unlock_return(void *mutex, void *self) "mutex %p self %p"
This means you can get these printfs like this:
$ ./configure --enable-trace-backend=stderr
$ echo qemu_co_mutex_lock_entry >my-events
$ echo qemu_co_mutex_lock_return >>my-events
$ echo qemu_co_mutex_unlock_entry >>my-events
$ echo qemu_co_mutex_unlock_return >>my-events
$ x86_64-softmmu/qemu-system-x86_64 -trace events=my-events ...
If you want you can keep the macros but really we already have these
printfs.
next prev parent reply other threads:[~2013-04-08 14:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-05 13:07 [Qemu-devel] [PATCH v7 0/2] block: Add support for Secure Shell (ssh) block device Richard W.M. Jones
2013-04-05 13:07 ` [Qemu-devel] [PATCH v7 1/2] " Richard W.M. Jones
2013-04-08 14:41 ` Stefan Hajnoczi [this message]
2013-04-05 13:07 ` [Qemu-devel] [PATCH v7 2/2] iotests: Add 'check -ssh' option to test Secure Shell " Richard W.M. Jones
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=20130408144148.GI4429@stefanha-thinkpad.redhat.com \
--to=stefanha@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).