diff options
Diffstat (limited to 'vchan/io.c')
-rw-r--r-- | vchan/io.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -25,6 +25,10 @@ #include <sys/ioctl.h> #include <unistd.h> +// allow vchan data to be easily observed in strace() by doing a +// writev() to FD -1 with the data being read/written. +#define VCHAN_DEBUG 1 + static uint32_t rd_prod(struct libvchan *ctrl) { return ctrl->read.shr->prod; @@ -102,6 +106,15 @@ static int do_send(struct libvchan *ctrl, const void *data, size_t size) { int real_idx = wr_prod(ctrl) & (wr_ring_size(ctrl) - 1); int avail_contig = wr_ring_size(ctrl) - real_idx; + if (VCHAN_DEBUG) { + char metainfo[32]; + struct iovec iov[2]; + iov[0].iov_base = metainfo; + iov[0].iov_len = snprintf(metainfo, 32, "vchan wr %d/%d", ctrl->other_domain_id, ctrl->device_number); + iov[1].iov_base = data; + iov[1].iov_len = size; + writev(-1, iov, 2); + } if (avail_contig > size) avail_contig = size; memcpy(wr_ring(ctrl) + real_idx, data, avail_contig); @@ -148,6 +161,15 @@ static int do_recv(struct libvchan *ctrl, void *data, size_t size) memcpy(data + avail_contig, rd_ring(ctrl), size - avail_contig); } rd_cons(ctrl) += size; + if (VCHAN_DEBUG) { + char metainfo[32]; + struct iovec iov[2]; + iov[0].iov_base = metainfo; + iov[0].iov_len = snprintf(metainfo, 32, "vchan rd %d/%d", ctrl->other_domain_id, ctrl->device_number); + iov[1].iov_base = data; + iov[1].iov_len = size; + writev(-1, iov, 2); + } if (do_notify(ctrl) < 0) return -1; return size; |