Skip to contentSkip to conversation

Merge QEMU I/O 2017/09/05 v2

GIT PULL Applied Daniel P. Berrange 2 participants 7 messages Sep 5, 2017 Block layer

lore
Share & tools
lore
#0 lore raw

The following changes since commit 32f0f68bb77289b75a82925f712bb52e16eac3ba:

Merge remote-tracking branch 'remotes/ehabkost/tags/x86-and-machine-pull-request' into staging (2017-09-01 17:28:54 +0100)

are available in the git repository at:

git://github.com/berrange/qemu tags/pull-qio-20170905-2

for you to fetch changes up to 689ed13e73bdb5a5ca3366524475e3065fae854a:

io: fix check for handshake completion in TLS test (2017-09-05 13:21:58 +0100)

----------------------------------------------------------------
Merge QEMU I/O 2017/09/05 v2

----------------------------------------------------------------

Changed in v2:

- Drop socket listen refactoring which had broken test suite

Cao jin (1):
util: remove the obsolete non-blocking connect

Daniel P. Berrange (4):
io: fix temp directory used by test-io-channel-tls test
io: fix typo in docs comment for qio_channel_read
io: add new qio_channel_{readv, writev, read, write}_all functions
io: fix check for handshake completion in TLS test

 block/sheepdog.c            |   2 +-
 block/ssh.c                 |   2 +-
 include/io/channel.h        |  92 +++++++++++++++++++-
 include/qemu/sockets.h      |  12 +--
 io/channel-socket.c         |   2 +-
 io/channel.c                |  94 ++++++++++++++++++++
 tests/io-channel-helpers.c  | 102 ++--------------------
 tests/test-io-channel-tls.c |   6 +-
 util/qemu-sockets.c         | 205 +++++---------------------------------------
 9 files changed, 225 insertions(+), 292 deletions(-)
Signature · 1 line
2.13.5
#1 lore raw

[Qemu-devel] [PULL v2 1/5] io: fix temp directory used by test-io-channel-tls test

The test-io-channel-tls test was mistakenly using two of the same directories as test-crypto-tlssession. This causes a sporadic failure when using make -j$BIGNUM.

---
 tests/test-io-channel-tls.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/test-io-channel-tls.c +2 -2
index 8eaa208e1b..ff96877323 100644
@@ -127,8 +127,8 @@ static void test_io_channel_tls(const void *opaque)
     /* We'll use this for our fake client-server connection */
     g_assert(socketpair(AF_UNIX, SOCK_STREAM, 0, channel) == 0);
 
-#define CLIENT_CERT_DIR "tests/test-crypto-tlssession-client/"
-#define SERVER_CERT_DIR "tests/test-crypto-tlssession-server/"
+#define CLIENT_CERT_DIR "tests/test-io-channel-tls-client/"
+#define SERVER_CERT_DIR "tests/test-io-channel-tls-server/"
     mkdir(CLIENT_CERT_DIR, 0700);
     mkdir(SERVER_CERT_DIR, 0700);
 
Signature · 1 line
2.13.5
#2 lore raw

[Qemu-devel] [PULL v2 3/5] io: fix typo in docs comment for qio_channel_read

In reply to Daniel P. Berrange
---
 include/io/channel.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/io/channel.h +1 -1
index db9bb022a1..54f3dc252f 100644
@@ -299,7 +299,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
Signature · 1 line
2.13.5
#3 lore raw

[Qemu-devel] [PULL v2 2/5] util: remove the obsolete non-blocking connect

In reply to Daniel P. Berrange

From: Cao jin <[email protected]>

The non-blocking connect mechanism is obsolete, and it doesn't work well in inet connection, because it will call getaddrinfo first and getaddrinfo will blocks on DNS lookups. Since commit e65c67e4 & d984464e, the non-blocking connect of migration goes through QIOChannel in a different manner(using a thread), and nobody use this old non-blocking connect anymore.

Any newly written code which needs a non-blocking connect should use the QIOChannel code, so we can drop NonBlockingConnectHandler as a concept entirely.

---
 block/sheepdog.c       |   2 +-
 block/ssh.c            |   2 +-
 include/qemu/sockets.h |  12 +--
 io/channel-socket.c    |   2 +-
 util/qemu-sockets.c    | 205 ++++++-------------------------------------------
 5 files changed, 28 insertions(+), 195 deletions(-)
block/sheepdog.c +1 -1
index abb2e79065..64ab07f3b7 100644
@@ -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);
block/ssh.c +1 -1
index e8f0404c03..b049a16eb9 100644
@@ -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;
include/qemu/sockets.h +2 -10
index ef6b5591f7..639cc079d9 100644
@@ -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);
io/channel-socket.c +1 -1
index 591d27e8c3..563e297357 100644
@@ -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;
util/qemu-sockets.c +23 -182

371 lines not on this page · raw message

Signature · 1 line
2.13.5
#4 lore raw

[Qemu-devel] [PULL v2 4/5] io: add new qio_channel_{readv, writev, read, write}_all functions

In reply to Daniel P. Berrange

These functions wait until they are able to read / write the full requested data buffer(s).

---
 include/io/channel.h       |  90 +++++++++++++++++++++++++++++++++++++++
 io/channel.c               |  94 +++++++++++++++++++++++++++++++++++++++++
 tests/io-channel-helpers.c | 102 ++++-----------------------------------------
 3 files changed, 193 insertions(+), 93 deletions(-)
include/io/channel.h +90 -0
index 54f3dc252f..8f25893c45 100644
@@ -269,6 +269,58 @@ ssize_t qio_channel_writev_full(QIOChannel *ioc,
                                 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
  * @iov: the array of memory regions to read data into
@@ -331,6 +383,44 @@ ssize_t qio_channel_write(QIOChannel *ioc,
                           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
  * @enabled: the blocking flag state
io/channel.c +94 -0

112 lines not on this page · raw message

tests/io-channel-helpers.c +9 -93

130 lines not on this page · raw message

Signature · 1 line
2.13.5
#5 lore raw

[Qemu-devel] [PULL v2 5/5] io: fix check for handshake completion in TLS test

In reply to Daniel P. Berrange

The TLS I/O channel test had mistakenly used && instead of || when checking for handshake completion. As a result it could terminate the handshake process before it had actually completed. This was harmless before but changes in GNUTLS 3.6.0 exposed this bug and caused the test suite to fail.

---
 tests/test-io-channel-tls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/test-io-channel-tls.c +1 -1
index ff96877323..a210d01ba5 100644
@@ -218,7 +218,7 @@ static void test_io_channel_tls(const void *opaque)
     mainloop = g_main_context_default();
     do {
         g_main_context_iteration(mainloop, TRUE);
-    } while (!clientHandshake.finished &&
+    } while (!clientHandshake.finished ||
              !serverHandshake.finished);
 
     g_assert(clientHandshake.failed == data->expectClientFail);
Signature · 1 line
2.13.5
#6 lore raw
In reply to Daniel P. Berrange
Quoted 21 lines · Daniel P. Berrange

The following changes since commit 32f0f68bb77289b75a82925f712bb52e16eac3ba:

Merge remote-tracking branch 'remotes/ehabkost/tags/x86-and-machine-pull-request' into staging (2017-09-01 17:28:54 +0100)

are available in the git repository at:

git://github.com/berrange/qemu tags/pull-qio-20170905-2

for you to fetch changes up to 689ed13e73bdb5a5ca3366524475e3065fae854a:

io: fix check for handshake completion in TLS test (2017-09-05 13:21:58 +0100)

----------------------------------------------------------------
Merge QEMU I/O 2017/09/05 v2

----------------------------------------------------------------

Changed in v2:

- Drop socket listen refactoring which had broken test suite

Quoted 9 lines

Cao jin (1):
util: remove the obsolete non-blocking connect

Daniel P. Berrange (4):
io: fix temp directory used by test-io-channel-tls test
io: fix typo in docs comment for qio_channel_read
io: add new qio_channel_{readv, writev, read, write}_all functions
io: fix check for handshake completion in TLS test

Applied, thanks.

-- PMM