diff options
author | Thanos Makatos <thanos.makatos@nutanix.com> | 2019-09-20 09:17:11 -0400 |
---|---|---|
committer | Thanos <tmakatos@gmail.com> | 2019-09-27 15:59:11 +0100 |
commit | d86309dfe93e10ddd3de14aaf8b4d0700aecc271 (patch) | |
tree | a9432e783089ac0954758fdce239d37364291840 /kmod | |
parent | b6cdbea1431996d9ec67a5a4471b387440cdfebc (diff) | |
download | libvfio-user-d86309dfe93e10ddd3de14aaf8b4d0700aecc271.zip libvfio-user-d86309dfe93e10ddd3de14aaf8b4d0700aecc271.tar.gz libvfio-user-d86309dfe93e10ddd3de14aaf8b4d0700aecc271.tar.bz2 |
return number of bytes actually provided by libmuser
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'kmod')
-rw-r--r-- | kmod/muser.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/kmod/muser.c b/kmod/muser.c index 2d9d20d..cdcb594 100644 --- a/kmod/muser.c +++ b/kmod/muser.c @@ -1001,16 +1001,28 @@ static ssize_t muser_read(struct mdev_device *mdev, char __user *buf, muser_dbg("R %lx@%llx", mucmd.muser_cmd.rw.count, mucmd.muser_cmd.rw.pos); - /* Process mudev_cmd in libmuser context. */ + /* Process mudev_cmd in libmuser context. TODO move into function */ err = muser_process_cmd(mudev, &mucmd); - if (err != 0) - count = -1; + if (unlikely(err != 0)) + _count = err; + else + _count = mucmd.muser_cmd.err; + + if (_count < 0) + muser_dbg("failed to process read: %d, %d\n", err, + mucmd.muser_cmd.err); + *ppos = mucmd.muser_cmd.rw.pos; + if (_count > 0) { + muser_dbg("received 0x%lx bytes from user space (0x%lx)", + _count, mucmd.muser_cmd.rw.count); + dump_buffer(buf, _count); + } + unpin_pages(&mucmd.pg_map); - dump_buffer(buf, count); - return count; + return _count; } ssize_t muser_write(struct mdev_device *mdev, const char __user *buf, |