mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
io: add new qio_channel_{readv, writev, read, write}_all functions
These functions wait until they are able to read / write the full requested data buffer(s). Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
50ea44f077
commit
d4622e5588
3 changed files with 193 additions and 93 deletions
|
@ -268,6 +268,58 @@ ssize_t qio_channel_writev_full(QIOChannel *ioc,
|
|||
size_t nfds,
|
||||
Error **errp);
|
||||
|
||||
/**
|
||||
* qio_channel_readv_all:
|
||||
* @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 all requested data
|
||||
* has been read, an error will be reported.
|
||||
*
|
||||
* Returns: 0 if all bytes were read, or -1 on error
|
||||
*/
|
||||
int qio_channel_readv_all(QIOChannel *ioc,
|
||||
const struct iovec *iov,
|
||||
size_t niov,
|
||||
Error **errp);
|
||||
|
||||
|
||||
/**
|
||||
* qio_channel_writev_all:
|
||||
* @ioc: the channel object
|
||||
* @iov: the array of memory regions to write data from
|
||||
* @niov: the length of the @iov array
|
||||
* @errp: pointer to a NULL-initialized error object
|
||||
*
|
||||
* Write data to the IO channel, reading it from the
|
||||
* memory regions referenced by @iov. Each element
|
||||
* in the @iov will be fully sent, 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 written, yielding from the current coroutine
|
||||
* if required.
|
||||
*
|
||||
* Returns: 0 if all bytes were written, or -1 on error
|
||||
*/
|
||||
int qio_channel_writev_all(QIOChannel *ioc,
|
||||
const struct iovec *iov,
|
||||
size_t niov,
|
||||
Error **erp);
|
||||
|
||||
/**
|
||||
* qio_channel_readv:
|
||||
* @ioc: the channel object
|
||||
|
@ -330,6 +382,44 @@ ssize_t qio_channel_write(QIOChannel *ioc,
|
|||
size_t buflen,
|
||||
Error **errp);
|
||||
|
||||
/**
|
||||
* qio_channel_read_all:
|
||||
* @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 it will return an error rather than a short-read. Otherwise
|
||||
* behaves as qio_channel_read().
|
||||
*
|
||||
* Returns: 0 if all bytes were read, or -1 on error
|
||||
*/
|
||||
int qio_channel_read_all(QIOChannel *ioc,
|
||||
char *buf,
|
||||
size_t buflen,
|
||||
Error **errp);
|
||||
/**
|
||||
* qio_channel_write_all:
|
||||
* @ioc: the channel object
|
||||
* @buf: the memory region to write data into
|
||||
* @buflen: the number of bytes to @buf
|
||||
* @errp: pointer to a NULL-initialized error object
|
||||
*
|
||||
* Writes @buflen bytes from @buf, possibly blocking or (if the
|
||||
* channel is non-blocking) yielding from the current coroutine
|
||||
* multiple times until the entire content is written. Otherwise
|
||||
* behaves as qio_channel_write().
|
||||
*
|
||||
* Returns: 0 if all bytes were written, or -1 on error
|
||||
*/
|
||||
int qio_channel_write_all(QIOChannel *ioc,
|
||||
const char *buf,
|
||||
size_t buflen,
|
||||
Error **errp);
|
||||
|
||||
/**
|
||||
* qio_channel_set_blocking:
|
||||
* @ioc: the channel object
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue