diff options
author | Thanos Makatos <thanos.makatos@nutanix.com> | 2019-09-20 09:08:17 -0400 |
---|---|---|
committer | Thanos <tmakatos@gmail.com> | 2019-09-27 15:59:11 +0100 |
commit | ea44111861ac603438990eef73c74b3f80aeface (patch) | |
tree | f089f4f8dc5cb1b2088e7cf846b25c6c37b8083e /lib | |
parent | 57efe9362daa223ecc9e02a02ce5349b5be9317a (diff) | |
download | libvfio-user-ea44111861ac603438990eef73c74b3f80aeface.zip libvfio-user-ea44111861ac603438990eef73c74b3f80aeface.tar.gz libvfio-user-ea44111861ac603438990eef73c74b3f80aeface.tar.bz2 |
make debug logging more configurable
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libmuser.c | 7 | ||||
-rw-r--r-- | lib/libmuser_pci.c | 2 | ||||
-rw-r--r-- | lib/muser.h | 11 |
3 files changed, 20 insertions, 0 deletions
diff --git a/lib/libmuser.c b/lib/libmuser.c index 6801067..800c0d3 100644 --- a/lib/libmuser.c +++ b/lib/libmuser.c @@ -793,8 +793,10 @@ muser_access(lm_ctx_t * const lm_ctx, struct muser_cmd *const cmd, return -1; } +#ifndef LM_TERSE_LOGGING lm_log(lm_ctx, LM_DBG, "%s %x@%lx\n", is_write ? "W" : "R", cmd->rw.count, cmd->rw.pos); +#endif /* copy data to be written from kernel to user space */ if (is_write) { @@ -809,7 +811,9 @@ muser_access(lm_ctx_t * const lm_ctx, struct muser_cmd *const cmd, goto out; } err = 0; +#ifndef LM_TERSE_LOGGING dump_buffer(lm_ctx, "buffer write", data, cmd->rw.count); +#endif } count = cmd->rw.count; @@ -817,6 +821,9 @@ muser_access(lm_ctx_t * const lm_ctx, struct muser_cmd *const cmd, is_write, data); if (cmd->err) { lm_log(lm_ctx, LM_ERR, "failed to access PCI header: %d\n", cmd->err); +#ifndef LM_TERSE_LOGGING + dump_buffer(lm_ctx, "buffer write", data, cmd->rw.count); +#endif } count -= cmd->rw.count; ret = lm_access(lm_ctx, data + count, cmd->rw.count, &cmd->rw.pos, diff --git a/lib/libmuser_pci.c b/lib/libmuser_pci.c index 488167d..4260dad 100644 --- a/lib/libmuser_pci.c +++ b/lib/libmuser_pci.c @@ -249,7 +249,9 @@ muser_pci_hdr_write(lm_ctx_t * const lm_ctx, const uint16_t offset, ret = -EINVAL; } +#ifndef LM_TERSE_LOGGING dump_buffer(lm_ctx, "PCI header", pci->hdr.raw, 0xff); +#endif return ret; } diff --git a/lib/muser.h b/lib/muser.h index 4b453f0..a62bc08 100644 --- a/lib/muser.h +++ b/lib/muser.h @@ -39,6 +39,17 @@ #include "pci.h" +/* + * Influential enviroment variables: + * + * LM_TERSE_LOGGING: define to make libmuser log only erroneous PCI accesses. + * (this should really be done with a more fine grained debug + * level) + */ +#ifndef LM_TERSE_LOGGING +#define LM_TERSE_LOGGING 0 +#endif + typedef uint64_t dma_addr_t; typedef struct { |