[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v10 19/24] migration: Create multifd channels
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PATCH v10 19/24] migration: Create multifd channels |
Date: |
Wed, 7 Mar 2018 12:00:05 +0100 |
In both sides. We still don't transmit anything through them.
Signed-off-by: Juan Quintela <address@hidden>
---
migration/ram.c | 52 ++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 42 insertions(+), 10 deletions(-)
diff --git a/migration/ram.c b/migration/ram.c
index b57d9fd667..7ef0c2b7e2 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -399,6 +399,7 @@ struct MultiFDSendParams {
uint8_t id;
char *name;
QemuThread thread;
+ QIOChannel *c;
QemuSemaphore sem;
QemuMutex mutex;
bool running;
@@ -455,6 +456,8 @@ int multifd_save_cleanup(Error **errp)
qemu_thread_join(&p->thread);
p->running = false;
}
+ socket_send_channel_destroy(p->c);
+ p->c = NULL;
qemu_mutex_destroy(&p->mutex);
qemu_sem_destroy(&p->sem);
g_free(p->name);
@@ -514,6 +517,27 @@ static void *multifd_send_thread(void *opaque)
return NULL;
}
+static void multifd_new_send_channel_async(QIOTask *task, gpointer opaque)
+{
+ MultiFDSendParams *p = opaque;
+ QIOChannel *sioc = QIO_CHANNEL(qio_task_get_source(task));
+ Error *local_err = NULL;
+
+ if (qio_task_propagate_error(task, &local_err)) {
+ if (multifd_save_cleanup(&local_err) != 0) {
+ migrate_set_error(migrate_get_current(), local_err);
+ }
+ } else {
+ p->c = QIO_CHANNEL(sioc);
+ qio_channel_set_delay(p->c, false);
+ p->running = true;
+ qemu_thread_create(&p->thread, p->name, multifd_send_thread, p,
+ QEMU_THREAD_JOINABLE);
+
+ atomic_inc(&multifd_send_state->count);
+ }
+}
+
int multifd_save_setup(void)
{
int thread_count;
@@ -536,11 +560,7 @@ int multifd_save_setup(void)
p->quit = false;
p->id = i;
p->name = g_strdup_printf("multifdsend_%d", i);
- p->running = true;
- qemu_thread_create(&p->thread, p->name, multifd_send_thread, p,
- QEMU_THREAD_JOINABLE);
-
- atomic_inc(&multifd_send_state->count);
+ socket_send_channel_create(multifd_new_send_channel_async, p);
}
return 0;
@@ -550,6 +570,7 @@ struct MultiFDRecvParams {
uint8_t id;
char *name;
QemuThread thread;
+ QIOChannel *c;
QemuSemaphore sem;
QemuMutex mutex;
bool running;
@@ -606,6 +627,8 @@ int multifd_load_cleanup(Error **errp)
qemu_thread_join(&p->thread);
p->running = false;
}
+ socket_recv_channel_unref(p->c);
+ p->c = NULL;
qemu_mutex_destroy(&p->mutex);
qemu_sem_destroy(&p->sem);
g_free(p->name);
@@ -688,10 +711,6 @@ int multifd_load_setup(void)
p->quit = false;
p->id = i;
p->name = g_strdup_printf("multifdrecv_%d", i);
- p->running = true;
- qemu_thread_create(&p->thread, p->name, multifd_recv_thread, p,
- QEMU_THREAD_JOINABLE);
- atomic_inc(&multifd_recv_state->count);
}
return 0;
@@ -710,7 +729,20 @@ bool multifd_recv_all_channels_created(void)
void multifd_recv_new_channel(QIOChannel *ioc)
{
- /* nothing to do yet */
+ MultiFDRecvParams *p;
+ /* we need to invent channels id's until we transmit */
+ /* we will remove this on a later patch */
+ static int i = 0;
+
+ p = &multifd_recv_state->params[i];
+ i++;
+ p->c = ioc;
+ socket_recv_channel_ref(ioc);
+
+ p->running = true;
+ qemu_thread_create(&p->thread, p->name, multifd_recv_thread, p,
+ QEMU_THREAD_JOINABLE);
+ atomic_inc(&multifd_recv_state->count);
}
/**
--
2.14.3
- Re: [Qemu-devel] [PATCH v10 10/24] migration: In case of error just end the migration, (continued)
- [Qemu-devel] [PATCH v10 02/24] tests: Add migration xbzrle test, Juan Quintela, 2018/03/07
- [Qemu-devel] [PATCH v10 13/24] migration: Introduce multifd_recv_new_channel(), Juan Quintela, 2018/03/07
- [Qemu-devel] [PATCH v10 18/24] migration: Add multifd traces for start/end thread, Juan Quintela, 2018/03/07
- [Qemu-devel] [PATCH v10 16/24] migration: Synchronize recv threads, Juan Quintela, 2018/03/07
- [Qemu-devel] [PATCH v10 15/24] migration: Synchronize send threads, Juan Quintela, 2018/03/07
- [Qemu-devel] [PATCH v10 19/24] migration: Create multifd channels,
Juan Quintela <=
[Qemu-devel] [PATCH v10 23/24] migration: Create pages structure for reception, Juan Quintela, 2018/03/07
[Qemu-devel] [PATCH v10 21/24] migration: Transmit initial package through the multifd channels, Juan Quintela, 2018/03/07
[Qemu-devel] [PATCH v10 20/24] migration: Delay start of migration main routines, Juan Quintela, 2018/03/07
[Qemu-devel] [PATCH v10 22/24] migration: Create ram_multifd_page, Juan Quintela, 2018/03/07