From: "Daniel P. Berrange" <berrange@redhat.com>
To: Juan Quintela <quintela@redhat.com>
Cc: qemu-devel@nongnu.org, lvivier@redhat.com, dgilbert@redhat.com,
peterx@redhat.com
Subject: Re: [Qemu-devel] [PATCH v8 12/20] migration: Start of multiple fd work
Date: Wed, 13 Sep 2017 12:44:10 +0100 [thread overview]
Message-ID: <20170913114410.GE3067@redhat.com> (raw)
In-Reply-To: <20170913105953.13760-13-quintela@redhat.com>
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 <quintela@redhat.com>
>
> --
> 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 :|
next prev parent reply other threads:[~2017-09-13 11:44 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-13 10:59 [Qemu-devel] [PATCH v8 00/20] Multifd Juan Quintela
2017-09-13 10:59 ` [Qemu-devel] [PATCH v8 01/20] migration: Create migration_ioc_process_incoming() Juan Quintela
2017-09-13 10:59 ` [Qemu-devel] [PATCH v8 02/20] migration: Teach it about G_SOURCE_REMOVE Juan Quintela
2017-09-13 10:59 ` [Qemu-devel] [PATCH v8 03/20] migration: Add comments to channel functions Juan Quintela
2017-09-13 10:59 ` [Qemu-devel] [PATCH v8 04/20] migration: Create migration_has_all_channels Juan Quintela
2017-09-13 10:59 ` [Qemu-devel] [PATCH v8 05/20] migration: Improve migration thread error handling Juan Quintela
2017-09-18 16:34 ` Dr. David Alan Gilbert
2017-09-13 10:59 ` [Qemu-devel] [PATCH v8 06/20] migration: Make migrate_fd_error() the owner of the Error Juan Quintela
2017-09-13 10:59 ` [Qemu-devel] [PATCH v8 07/20] migration: Add multifd capability Juan Quintela
2017-09-13 10:59 ` [Qemu-devel] [PATCH v8 08/20] migration: Create x-multifd-channels parameter Juan Quintela
2017-09-13 10:59 ` [Qemu-devel] [PATCH v8 09/20] migration: Create x-multifd-page-count parameter Juan Quintela
2017-09-13 10:59 ` [Qemu-devel] [PATCH v8 10/20] migration: Create multifd migration threads Juan Quintela
2017-09-13 10:59 ` [Qemu-devel] [PATCH v8 11/20] migration: Split migration_fd_process_incoming Juan Quintela
2017-09-13 10:59 ` [Qemu-devel] [PATCH v8 12/20] migration: Start of multiple fd work Juan Quintela
2017-09-13 11:35 ` Daniel P. Berrange
2017-09-13 11:44 ` Daniel P. Berrange [this message]
2017-09-13 10:59 ` [Qemu-devel] [PATCH v8 13/20] migration: Create ram_multifd_page Juan Quintela
2017-09-13 10:59 ` [Qemu-devel] [PATCH v8 14/20] migration: Really use multiple pages at a time Juan Quintela
2017-09-13 10:59 ` [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 10:59 ` [Qemu-devel] [PATCH v8 16/20] migration: Create thread infrastructure for multifd recv side Juan Quintela
2017-09-13 11:42 ` Daniel P. Berrange
2017-09-13 10:59 ` [Qemu-devel] [PATCH v8 17/20] migration: Test new fd infrastructure Juan Quintela
2017-09-13 10:59 ` [Qemu-devel] [PATCH v8 18/20] migration: Rename initial_bytes Juan Quintela
2017-09-13 10:59 ` [Qemu-devel] [PATCH v8 19/20] migration: Transfer pages over new channels Juan Quintela
2017-09-13 10:59 ` [Qemu-devel] [PATCH v8 20/20] migration: Flush receive queue Juan Quintela
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170913114410.GE3067@redhat.com \
--to=berrange@redhat.com \
--cc=dgilbert@redhat.com \
--cc=lvivier@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).