Commit d3e3447d authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/berrange/tags/pull-qio-20170905-2' into staging



Merge QEMU I/O 2017/09/05 v2

# gpg: Signature made Tue 05 Sep 2017 13:22:36 BST
# gpg:                using RSA key 0xBE86EBB415104FDF
# gpg: Good signature from "Daniel P. Berrange <dan@berrange.com>"
# gpg:                 aka "Daniel P. Berrange <berrange@redhat.com>"
# Primary key fingerprint: DAF3 A6FD B26B 6291 2D0E  8E3F BE86 EBB4 1510 4FDF

* remotes/berrange/tags/pull-qio-20170905-2:
  io: fix check for handshake completion in TLS test
  io: add new qio_channel_{readv, writev, read, write}_all functions
  io: fix typo in docs comment for qio_channel_read
  util: remove the obsolete non-blocking connect
  io: fix temp directory used by test-io-channel-tls test

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents 53e2c48d 689ed13e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -591,7 +591,7 @@ static int connect_to_sdog(BDRVSheepdogState *s, Error **errp)
{
    int fd;

    fd = socket_connect(s->addr, NULL, NULL, errp);
    fd = socket_connect(s->addr, errp);

    if (s->addr->type == SOCKET_ADDRESS_TYPE_INET && fd >= 0) {
        int ret = socket_set_nodelay(fd);
+1 −1
Original line number Diff line number Diff line
@@ -678,7 +678,7 @@ static int connect_to_ssh(BDRVSSHState *s, QDict *options,
    }

    /* Open the socket and connect. */
    s->sock = inet_connect_saddr(s->inet, NULL, NULL, errp);
    s->sock = inet_connect_saddr(s->inet, errp);
    if (s->sock < 0) {
        ret = -EIO;
        goto err;
+91 −1
Original line number Diff line number Diff line
@@ -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
@@ -299,7 +351,7 @@ ssize_t qio_channel_writev(QIOChannel *ioc,
                           Error **errp);

/**
 * qio_channel_readv:
 * qio_channel_read:
 * @ioc: the channel object
 * @buf: the memory region to read data into
 * @buflen: the length of @buf
@@ -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
+2 −10
Original line number Diff line number Diff line
@@ -27,18 +27,11 @@ int socket_set_fast_reuse(int fd);
#define SHUT_RDWR 2
#endif

/* callback function for nonblocking connect
 * valid fd on success, negative error code on failure
 */
typedef void NonBlockingConnectHandler(int fd, Error *err, void *opaque);

int inet_ai_family_from_address(InetSocketAddress *addr,
                                Error **errp);
int inet_parse(InetSocketAddress *addr, const char *str, Error **errp);
int inet_connect(const char *str, Error **errp);
int inet_connect_saddr(InetSocketAddress *saddr,
                       NonBlockingConnectHandler *callback, void *opaque,
                       Error **errp);
int inet_connect_saddr(InetSocketAddress *saddr, Error **errp);

NetworkAddressFamily inet_netfamily(int family);

@@ -46,8 +39,7 @@ int unix_listen(const char *path, char *ostr, int olen, Error **errp);
int unix_connect(const char *path, Error **errp);

SocketAddress *socket_parse(const char *str, Error **errp);
int socket_connect(SocketAddress *addr, NonBlockingConnectHandler *callback,
                   void *opaque, Error **errp);
int socket_connect(SocketAddress *addr, Error **errp);
int socket_listen(SocketAddress *addr, Error **errp);
void socket_listen_cleanup(int fd, Error **errp);
int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp);
+1 −1
Original line number Diff line number Diff line
@@ -140,7 +140,7 @@ int qio_channel_socket_connect_sync(QIOChannelSocket *ioc,
    int fd;

    trace_qio_channel_socket_connect_sync(ioc, addr);
    fd = socket_connect(addr, NULL, NULL, errp);
    fd = socket_connect(addr, errp);
    if (fd < 0) {
        trace_qio_channel_socket_connect_fail(ioc);
        return -1;
Loading