diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2017-09-07 17:53:59 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2017-09-07 17:53:59 +0100 |
commit | 75be9a52b147790decd62e43d279a5f3dfc95b5c (patch) | |
tree | 066cf2dbca492a4d64fbc04169777a1486a13429 /include | |
parent | ef475b5dd12684591e6264e517eaa5b3e90f7ffa (diff) | |
parent | 030fa7f6f950f5c8963f1dee8e6bb7387ed86a99 (diff) |
Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2017-09-06' into staging
nbd patches for 2017-09-06
- Daniel P. Berrange: [0/2] Fix / skip recent iotests with LUKS driver
- Eric Blake: [0/3] nbd: Use common read/write-all qio functions
# gpg: Signature made Wed 06 Sep 2017 16:17:55 BST
# gpg: using RSA key 0xA7A16B4A2527436A
# gpg: Good signature from "Eric Blake <eblake@redhat.com>"
# gpg: aka "Eric Blake (Free Software Programmer) <ebb9@byu.net>"
# gpg: aka "[jpeg image of size 6874]"
# Primary key fingerprint: 71C2 CC22 B1C4 6029 27D2 F3AA A7A1 6B4A 2527 436A
* remotes/ericb/tags/pull-nbd-2017-09-06:
nbd: Use new qio_channel_*_all() functions
io: Add new qio_channel_read{, v}_all_eof functions
io: Yield rather than wait when already in coroutine
iotests: blacklist 194 with the luks driver
iotests: rewrite 192 to use _launch_qemu to fix LUKS support
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/block/nbd.h | 2 | ||||
-rw-r--r-- | include/io/channel.h | 53 |
2 files changed, 53 insertions, 2 deletions
diff --git a/include/block/nbd.h b/include/block/nbd.h index 040cdd2e60..707fd37575 100644 --- a/include/block/nbd.h +++ b/include/block/nbd.h @@ -155,8 +155,6 @@ struct NBDExportInfo { }; typedef struct NBDExportInfo NBDExportInfo; -ssize_t nbd_rwv(QIOChannel *ioc, struct iovec *iov, size_t niov, size_t length, - bool do_read, Error **errp); int nbd_receive_negotiate(QIOChannel *ioc, const char *name, QCryptoTLSCreds *tlscreds, const char *hostname, QIOChannel **outioc, NBDExportInfo *info, diff --git a/include/io/channel.h b/include/io/channel.h index 8f25893c45..3995e243a3 100644 --- a/include/io/channel.h +++ b/include/io/channel.h @@ -269,6 +269,36 @@ ssize_t qio_channel_writev_full(QIOChannel *ioc, Error **errp); /** + * qio_channel_readv_all_eof: + * @ioc: the channel object + * @iov: the array of memory regions to read data into + * @niov: the length of the @iov array + * @errp: pointer to a NULL-initialized error object + * + * Read data from the IO channel, storing it in the + * memory regions referenced by @iov. Each element + * in the @iov will be fully populated with data + * before the next one is used. The @niov parameter + * specifies the total number of elements in @iov. + * + * The function will wait for all requested data + * to be read, yielding from the current coroutine + * if required. + * + * If end-of-file occurs before any data is read, + * no error is reported; otherwise, if it occurs + * before all requested data has been read, an error + * will be reported. + * + * Returns: 1 if all bytes were read, 0 if end-of-file + * occurs without data, or -1 on error + */ +int qio_channel_readv_all_eof(QIOChannel *ioc, + const struct iovec *iov, + size_t niov, + Error **errp); + +/** * qio_channel_readv_all: * @ioc: the channel object * @iov: the array of memory regions to read data into @@ -383,6 +413,28 @@ ssize_t qio_channel_write(QIOChannel *ioc, Error **errp); /** + * qio_channel_read_all_eof: + * @ioc: the channel object + * @buf: the memory region to read data into + * @buflen: the number of bytes to @buf + * @errp: pointer to a NULL-initialized error object + * + * Reads @buflen bytes into @buf, possibly blocking or (if the + * channel is non-blocking) yielding from the current coroutine + * multiple times until the entire content is read. If end-of-file + * occurs immediately it is not an error, but if it occurs after + * data has been read it will return an error rather than a + * short-read. Otherwise behaves as qio_channel_read(). + * + * Returns: 1 if all bytes were read, 0 if end-of-file occurs + * without data, or -1 on error + */ +int qio_channel_read_all_eof(QIOChannel *ioc, + char *buf, + size_t buflen, + Error **errp); + +/** * qio_channel_read_all: * @ioc: the channel object * @buf: the memory region to read data into @@ -401,6 +453,7 @@ int qio_channel_read_all(QIOChannel *ioc, char *buf, size_t buflen, Error **errp); + /** * qio_channel_write_all: * @ioc: the channel object |