qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v7 1/2] block: Add support for Secure Shell (ssh


From: Stefan Hajnoczi
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
User-agent: Mutt/1.5.21 (2010-09-15)

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]