nbd: use generic trace subsystem instead of TRACE macro

Let NBD use the trace mechanisms already present in qemu. Now you can
use the -trace optino of qemu, or the -T/--trace option of qemu-img,
qemu-io, and qemu-nbd, to select nbd traces. For qemu, the QMP commands
trace-event-{get,set}-state can also toggle tracing on the fly.

Example:
   qemu-nbd --trace 'nbd_*' <image file> # enables all nbd traces

Recompilation with CFLAGS=-DDEBUG_NBD is no more needed, furthermore,
DEBUG_NBD macro is removed from the code.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20170707152918.23086-11-vsementsov@virtuozzo.com>
[eblake: minor tweaks to a couple of traces]
Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Vladimir Sementsov-Ogievskiy
2017-07-07 18:29:18 +03:00
committed by Eric Blake
parent 6fb2b9726c
commit 9588463e74
5 changed files with 120 additions and 95 deletions

View File

@ -31,25 +31,6 @@
#include "qemu/queue.h"
#include "qemu/main-loop.h"
/* #define DEBUG_NBD */
#ifdef DEBUG_NBD
#define DEBUG_NBD_PRINT 1
#else
#define DEBUG_NBD_PRINT 0
#endif
#define TRACE(msg, ...) do { \
if (DEBUG_NBD_PRINT) { \
LOG(msg, ## __VA_ARGS__); \
} \
} while (0)
#define LOG(msg, ...) do { \
fprintf(stderr, "%s:%s():L%d: " msg "\n", \
__FILE__, __FUNCTION__, __LINE__, ## __VA_ARGS__); \
} while (0)
/* This is all part of the "official" NBD API.
*
* The most up-to-date documentation is available at: