[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 09/40] migration: Create multifd channels
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PULL 09/40] migration: Create multifd channels |
Date: |
Wed, 16 May 2018 01:39:46 +0200 |
In both sides. We still don't transmit anything through them.
Signed-off-by: Juan Quintela <address@hidden>
Reviewed-by: Daniel P. Berrangé <address@hidden>
---
migration/ram.c | 52 +++++++++++++++++++++++++++++++++++++++----------
1 file changed, 42 insertions(+), 10 deletions(-)
diff --git a/migration/ram.c b/migration/ram.c
index d5335c10b6..87434d3fce 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -437,6 +437,7 @@ struct MultiFDSendParams {
uint8_t id;
char *name;
QemuThread thread;
+ QIOChannel *c;
QemuSemaphore sem;
QemuMutex mutex;
bool running;
@@ -491,6 +492,8 @@ int multifd_save_cleanup(Error **errp)
if (p->running) {
qemu_thread_join(&p->thread);
}
+ socket_send_channel_destroy(p->c);
+ p->c = NULL;
qemu_mutex_destroy(&p->mutex);
qemu_sem_destroy(&p->sem);
g_free(p->name);
@@ -524,6 +527,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;
@@ -544,11 +568,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;
}
@@ -557,6 +577,7 @@ struct MultiFDRecvParams {
uint8_t id;
char *name;
QemuThread thread;
+ QIOChannel *c;
QemuSemaphore sem;
QemuMutex mutex;
bool running;
@@ -609,6 +630,8 @@ int multifd_load_cleanup(Error **errp)
if (p->running) {
qemu_thread_join(&p->thread);
}
+ object_unref(OBJECT(p->c));
+ p->c = NULL;
qemu_mutex_destroy(&p->mutex);
qemu_sem_destroy(&p->sem);
g_free(p->name);
@@ -663,10 +686,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;
}
@@ -684,7 +703,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;
+
+ p = &multifd_recv_state->params[i];
+ i++;
+ p->c = ioc;
+ object_ref(OBJECT(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.17.0
- [Qemu-devel] [PULL 00/40] Migration PULL requset (take 2), Juan Quintela, 2018/05/15
- [Qemu-devel] [PULL 02/40] tests: Add migration precopy test, Juan Quintela, 2018/05/15
- [Qemu-devel] [PULL 01/40] migration: fix saving normal page even if it's been compressed, Juan Quintela, 2018/05/15
- [Qemu-devel] [PULL 03/40] tests: Migration ppc now inlines its program, Juan Quintela, 2018/05/15
- [Qemu-devel] [PULL 05/40] migration: Introduce multifd_recv_new_channel(), Juan Quintela, 2018/05/15
- [Qemu-devel] [PULL 04/40] migration: Set error state in case of error, Juan Quintela, 2018/05/15
- [Qemu-devel] [PULL 06/40] migration: terminate_* can be called for other threads, Juan Quintela, 2018/05/15
- [Qemu-devel] [PULL 09/40] migration: Create multifd channels,
Juan Quintela <=
- [Qemu-devel] [PULL 08/40] migration: Export functions to create send channels, Juan Quintela, 2018/05/15
- [Qemu-devel] [PULL 10/40] migration: Delay start of migration main routines, Juan Quintela, 2018/05/15
[Qemu-devel] [PULL 11/40] migration: Transmit initial package through the multifd channels, Juan Quintela, 2018/05/15
[Qemu-devel] [PULL 13/40] migration: let incoming side use thread context, Juan Quintela, 2018/05/15
[Qemu-devel] [PULL 12/40] migration: Define MultifdRecvParams sooner, Juan Quintela, 2018/05/15