diff options
author | Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 2017-05-16 12:45:32 +0300 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2017-06-06 20:18:36 +0200 |
commit | e44ed99d1949315755bffb12a5a483ac66d4a976 (patch) | |
tree | 52ee8fec56a270ed7893e63da4d18e02e53357ea /nbd/nbd-internal.h | |
parent | f2609565369429bc1619d106b200106dba29290e (diff) |
nbd: add errp to read_sync, write_sync and drop_sync
There a lot of calls of these functions, which already have errp, which
they are filling themselves. On the other hand, nbd_wr_syncv has errp
parameter too, so it would be great to connect them.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20170516094533.6160-5-vsementsov@virtuozzo.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'nbd/nbd-internal.h')
-rw-r--r-- | nbd/nbd-internal.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/nbd/nbd-internal.h b/nbd/nbd-internal.h index 1d479fe135..d6071640a0 100644 --- a/nbd/nbd-internal.h +++ b/nbd/nbd-internal.h @@ -100,7 +100,8 @@ * qio_channel_readv() returns 0. So, there are no needs to call read_sync_eof * iteratively. */ -static inline ssize_t read_sync_eof(QIOChannel *ioc, void *buffer, size_t size) +static inline ssize_t read_sync_eof(QIOChannel *ioc, void *buffer, size_t size, + Error **errp) { struct iovec iov = { .iov_base = buffer, .iov_len = size }; /* Sockets are kept in blocking mode in the negotiation phase. After @@ -108,18 +109,20 @@ static inline ssize_t read_sync_eof(QIOChannel *ioc, void *buffer, size_t size) * our request/reply. Synchronization is done with recv_coroutine, so * that this is coroutine-safe. */ - return nbd_wr_syncv(ioc, &iov, 1, size, true, NULL); + return nbd_wr_syncv(ioc, &iov, 1, size, true, errp); } /* read_sync * Reads @size bytes from @ioc. Returns 0 on success. */ -static inline int read_sync(QIOChannel *ioc, void *buffer, size_t size) +static inline int read_sync(QIOChannel *ioc, void *buffer, size_t size, + Error **errp) { - ssize_t ret = read_sync_eof(ioc, buffer, size); + ssize_t ret = read_sync_eof(ioc, buffer, size, errp); if (ret >= 0 && ret != size) { ret = -EINVAL; + error_setg(errp, "End of file"); } return ret < 0 ? ret : 0; @@ -128,11 +131,12 @@ static inline int read_sync(QIOChannel *ioc, void *buffer, size_t size) /* write_sync * Writes @size bytes to @ioc. Returns 0 on success. */ -static inline int write_sync(QIOChannel *ioc, const void *buffer, size_t size) +static inline int write_sync(QIOChannel *ioc, const void *buffer, size_t size, + Error **errp) { struct iovec iov = { .iov_base = (void *) buffer, .iov_len = size }; - ssize_t ret = nbd_wr_syncv(ioc, &iov, 1, size, false, NULL); + ssize_t ret = nbd_wr_syncv(ioc, &iov, 1, size, false, errp); assert(ret < 0 || ret == size); |