qemu-kvm/kvm-socket-Add-num-connections-to-qio_channel_socket_asy.patch
Danilo C. L. de Paula 1442ce8243 * Fri Sep 06 2019 Danilo Cesar Lemes de Paula <ddepaula@redhat.com> - 4.1.0-7.el8
- kvm-trace-Clarify-DTrace-SystemTap-help-message.patch [bz#1516220]
- kvm-socket-Add-backlog-parameter-to-socket_listen.patch [bz#1726898]
- kvm-socket-Add-num-connections-to-qio_channel_socket_syn.patch [bz#1726898]
- kvm-socket-Add-num-connections-to-qio_channel_socket_asy.patch [bz#1726898]
- kvm-socket-Add-num-connections-to-qio_net_listener_open_.patch [bz#1726898]
- kvm-multifd-Use-number-of-channels-as-listen-backlog.patch [bz#1726898]
- kvm-pseries-Fix-compat_pvr-on-reset.patch [bz#1744107]
- kvm-spapr-Set-compat-mode-in-spapr_core_plug.patch [bz#1744107]
- Resolves: bz#1516220
  (-trace help prints an incomplete list of trace events)
- Resolves: bz#1726898
  (Parallel migration fails with error "Unable to write to socket: Connection reset by peer" now and then)
- Resolves: bz#1744107
  (Migration from P8(qemu4.1) to P9(qemu4.1), after migration, qemu crash on destination with error message "qemu-kvm: error while loading state for instance 0x1 of device 'cpu'")
2019-09-06 00:33:12 +01:00

145 lines
6.0 KiB
Diff

From d2bb195f057fd21444644d3996551fe8775043e5 Mon Sep 17 00:00:00 2001
From: Juan Quintela <quintela@redhat.com>
Date: Wed, 4 Sep 2019 10:26:04 +0100
Subject: [PATCH 4/8] socket: Add num connections to qio_channel_socket_async()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
RH-Author: Juan Quintela <quintela@redhat.com>
Message-id: <20190904102606.15744-4-quintela@redhat.com>
Patchwork-id: 90271
O-Subject: [RHEL-AV-8.1 qemu-kvm PATCH 3/5] socket: Add num connections to qio_channel_socket_async()
Bugzilla: 1726898
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Peter Xu <peterx@redhat.com>
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
(cherry picked from commit 7959e29ea0d6100038367beff9a0da0c83b322a2)
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
include/io/channel-socket.h | 2 ++
io/channel-socket.c | 30 +++++++++++++++++++++++-------
io/trace-events | 2 +-
tests/test-io-channel-socket.c | 2 +-
4 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/include/io/channel-socket.h b/include/io/channel-socket.h
index ed88e5b..777ff59 100644
--- a/include/io/channel-socket.h
+++ b/include/io/channel-socket.h
@@ -140,6 +140,7 @@ int qio_channel_socket_listen_sync(QIOChannelSocket *ioc,
* qio_channel_socket_listen_async:
* @ioc: the socket channel object
* @addr: the address to listen to
+ * @num: the expected ammount of connections
* @callback: the function to invoke on completion
* @opaque: user data to pass to @callback
* @destroy: the function to free @opaque
@@ -155,6 +156,7 @@ int qio_channel_socket_listen_sync(QIOChannelSocket *ioc,
*/
void qio_channel_socket_listen_async(QIOChannelSocket *ioc,
SocketAddress *addr,
+ int num,
QIOTaskFunc callback,
gpointer opaque,
GDestroyNotify destroy,
diff --git a/io/channel-socket.c b/io/channel-socket.c
index 6258c25..b74f5b9 100644
--- a/io/channel-socket.c
+++ b/io/channel-socket.c
@@ -220,14 +220,27 @@ int qio_channel_socket_listen_sync(QIOChannelSocket *ioc,
}
+struct QIOChannelListenWorkerData {
+ SocketAddress *addr;
+ int num; /* amount of expected connections */
+};
+
+static void qio_channel_listen_worker_free(gpointer opaque)
+{
+ struct QIOChannelListenWorkerData *data = opaque;
+
+ qapi_free_SocketAddress(data->addr);
+ g_free(data);
+}
+
static void qio_channel_socket_listen_worker(QIOTask *task,
gpointer opaque)
{
QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(qio_task_get_source(task));
- SocketAddress *addr = opaque;
+ struct QIOChannelListenWorkerData *data = opaque;
Error *err = NULL;
- qio_channel_socket_listen_sync(ioc, addr, 1, &err);
+ qio_channel_socket_listen_sync(ioc, data->addr, data->num, &err);
qio_task_set_error(task, err);
}
@@ -235,6 +248,7 @@ static void qio_channel_socket_listen_worker(QIOTask *task,
void qio_channel_socket_listen_async(QIOChannelSocket *ioc,
SocketAddress *addr,
+ int num,
QIOTaskFunc callback,
gpointer opaque,
GDestroyNotify destroy,
@@ -242,16 +256,18 @@ void qio_channel_socket_listen_async(QIOChannelSocket *ioc,
{
QIOTask *task = qio_task_new(
OBJECT(ioc), callback, opaque, destroy);
- SocketAddress *addrCopy;
+ struct QIOChannelListenWorkerData *data;
- addrCopy = QAPI_CLONE(SocketAddress, addr);
+ data = g_new0(struct QIOChannelListenWorkerData, 1);
+ data->addr = QAPI_CLONE(SocketAddress, addr);
+ data->num = num;
/* socket_listen() blocks in DNS lookups, so we must use a thread */
- trace_qio_channel_socket_listen_async(ioc, addr);
+ trace_qio_channel_socket_listen_async(ioc, addr, num);
qio_task_run_in_thread(task,
qio_channel_socket_listen_worker,
- addrCopy,
- (GDestroyNotify)qapi_free_SocketAddress,
+ data,
+ qio_channel_listen_worker_free,
context);
}
diff --git a/io/trace-events b/io/trace-events
index 2e6aa1d..d7bc70b 100644
--- a/io/trace-events
+++ b/io/trace-events
@@ -18,7 +18,7 @@ qio_channel_socket_connect_async(void *ioc, void *addr) "Socket connect async io
qio_channel_socket_connect_fail(void *ioc) "Socket connect fail ioc=%p"
qio_channel_socket_connect_complete(void *ioc, int fd) "Socket connect complete ioc=%p fd=%d"
qio_channel_socket_listen_sync(void *ioc, void *addr, int num) "Socket listen sync ioc=%p addr=%p num=%d"
-qio_channel_socket_listen_async(void *ioc, void *addr) "Socket listen async ioc=%p addr=%p"
+qio_channel_socket_listen_async(void *ioc, void *addr, int num) "Socket listen async ioc=%p addr=%p num=%d"
qio_channel_socket_listen_fail(void *ioc) "Socket listen fail ioc=%p"
qio_channel_socket_listen_complete(void *ioc, int fd) "Socket listen complete ioc=%p fd=%d"
qio_channel_socket_dgram_sync(void *ioc, void *localAddr, void *remoteAddr) "Socket dgram sync ioc=%p localAddr=%p remoteAddr=%p"
diff --git a/tests/test-io-channel-socket.c b/tests/test-io-channel-socket.c
index 6eebcee..50235c1 100644
--- a/tests/test-io-channel-socket.c
+++ b/tests/test-io-channel-socket.c
@@ -113,7 +113,7 @@ static void test_io_channel_setup_async(SocketAddress *listen_addr,
lioc = qio_channel_socket_new();
qio_channel_socket_listen_async(
- lioc, listen_addr,
+ lioc, listen_addr, 1,
test_io_channel_complete, &data, NULL, NULL);
g_main_loop_run(data.loop);
--
1.8.3.1