[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v8 12/20] migration: Start of multiple fd work
From: |
Daniel P. Berrange |
Subject: |
Re: [Qemu-devel] [PATCH v8 12/20] migration: Start of multiple fd work |
Date: |
Wed, 13 Sep 2017 12:44:10 +0100 |
User-agent: |
Mutt/1.8.3 (2017-05-23) |
On Wed, Sep 13, 2017 at 12:59:45PM +0200, Juan Quintela wrote:
> We create new channels for each new thread created. We send through
> them a string containing <uuid> multifd <channel number> so we are
> sure that we connect the right channels in both sides.
>
> Signed-off-by: Juan Quintela <address@hidden>
>
> --
> Split SocketArgs into incoming and outgoing args
>
> Use UUID's on the initial message, so we are sure we are connecting to
> the right channel.
>
> Remove init semaphore. Now that we use uuids on the init message, we
> know that this is our channel.
>
> Fix recv socket destwroy, we were destroying send channels.
> This was very interesting, because we were using an unreferred object
> without problems.
>
> Move to struct of pointers
> init channel sooner.
> split recv thread creation.
> listen on main thread
> We count the number of created threads to know when we need to stop listening
> Use g_strdup_printf
> report channel id on errors
> Add name parameter
> Use local_err
> Add Error * parameter to socket_send_channel_create()
> Use qio_channel_*_all
> Use asynchronous connect
> ---
> migration/migration.c | 5 ++
> migration/ram.c | 138
> +++++++++++++++++++++++++++++++++++++++++++-------
> migration/ram.h | 3 ++
> migration/socket.c | 34 ++++++++++++-
> migration/socket.h | 10 ++++
> 5 files changed, 172 insertions(+), 18 deletions(-)
>
> @@ -531,10 +595,56 @@ static void *multifd_recv_thread(void *opaque)
> return NULL;
> }
>
> +void multifd_new_channel(QIOChannel *ioc)
> +{
> + MultiFDRecvParams *p;
> + char string[MULTIFD_UUID_MSG];
> + char string_uuid[UUID_FMT_LEN];
> + Error *local_err = NULL;
> + char *uuid;
> + size_t ret;
> + int id;
> +
> + ret = qio_channel_read_all(ioc, string, sizeof(string), &local_err);
> + if (ret != 0) {
> + terminate_multifd_recv_threads(local_err);
> + return;
> + }
> + sscanf(string, "%s multifd %03d", string_uuid, &id);
> +
> + if (qemu_uuid_set) {
> + uuid = qemu_uuid_unparse_strdup(&qemu_uuid);
> + } else {
> + uuid = g_strdup(multifd_uuid);
> + }
> + if (strcmp(string_uuid, uuid)) {
> + error_setg(&local_err, "multifd: received uuid '%s' and expected "
> + "uuid '%s' for channel %d", string_uuid, uuid, id);
> + terminate_multifd_recv_threads(local_err);
> + return;
> + }
> + g_free(uuid);
> +
> + p = &multifd_recv_state->params[id];
> + if (p->id != 0) {
> + error_setg(&local_err, "multifd: received id '%d' already setup'",
> id);
> + terminate_multifd_recv_threads(local_err);
> + return;
> + }
> + qemu_mutex_init(&p->mutex);
> + qemu_sem_init(&p->sem, 0);
> + p->quit = false;
> + p->id = id;
> + p->c = ioc;
You must acquire a reference on 'ioc', so that the thread you are
about to spawn will own a reference on it.
The function that you later call multifd_new_channel() from
expects it to acquire its own reference.
> + multifd_recv_state->count++;
> + p->name = g_strdup_printf("multifdrecv_%d", id);
> + qemu_thread_create(&p->thread, p->name, multifd_recv_thread, p,
> + QEMU_THREAD_JOINABLE);
> +}
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
- [Qemu-devel] [PATCH v8 02/20] migration: Teach it about G_SOURCE_REMOVE, (continued)
- [Qemu-devel] [PATCH v8 02/20] migration: Teach it about G_SOURCE_REMOVE, Juan Quintela, 2017/09/13
- [Qemu-devel] [PATCH v8 04/20] migration: Create migration_has_all_channels, Juan Quintela, 2017/09/13
- [Qemu-devel] [PATCH v8 05/20] migration: Improve migration thread error handling, Juan Quintela, 2017/09/13
- [Qemu-devel] [PATCH v8 06/20] migration: Make migrate_fd_error() the owner of the Error, Juan Quintela, 2017/09/13
- [Qemu-devel] [PATCH v8 07/20] migration: Add multifd capability, Juan Quintela, 2017/09/13
- [Qemu-devel] [PATCH v8 08/20] migration: Create x-multifd-channels parameter, Juan Quintela, 2017/09/13
- [Qemu-devel] [PATCH v8 11/20] migration: Split migration_fd_process_incoming, Juan Quintela, 2017/09/13
- [Qemu-devel] [PATCH v8 10/20] migration: Create multifd migration threads, Juan Quintela, 2017/09/13
- [Qemu-devel] [PATCH v8 12/20] migration: Start of multiple fd work, Juan Quintela, 2017/09/13
- [Qemu-devel] [PATCH v8 13/20] migration: Create ram_multifd_page, Juan Quintela, 2017/09/13
- [Qemu-devel] [PATCH v8 09/20] migration: Create x-multifd-page-count parameter, Juan Quintela, 2017/09/13
- [Qemu-devel] [PATCH v8 14/20] migration: Really use multiple pages at a time, Juan Quintela, 2017/09/13
- [Qemu-devel] [PATCH v8 15/20] migration: Send the fd number which we are going to use for this page, Juan Quintela, 2017/09/13
- [Qemu-devel] [PATCH v8 17/20] migration: Test new fd infrastructure, Juan Quintela, 2017/09/13
- [Qemu-devel] [PATCH v8 16/20] migration: Create thread infrastructure for multifd recv side, Juan Quintela, 2017/09/13
- [Qemu-devel] [PATCH v8 19/20] migration: Transfer pages over new channels, Juan Quintela, 2017/09/13
- [Qemu-devel] [PATCH v8 20/20] migration: Flush receive queue, Juan Quintela, 2017/09/13
- [Qemu-devel] [PATCH v8 18/20] migration: Rename initial_bytes, Juan Quintela, 2017/09/13