From: Juan Quintela <quintela@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>
Cc: qemu-devel@nongnu.org, lvivier@redhat.com, dgilbert@redhat.com,
peterx@redhat.com
Subject: Re: [Qemu-devel] [PATCH v6 11/19] migration: Start of multiple fd work
Date: Mon, 14 Aug 2017 15:43:58 +0200 [thread overview]
Message-ID: <87shguxo0x.fsf@secure.laptop> (raw)
In-Reply-To: <20170811152256.GS2554@redhat.com> (Daniel P. Berrange's message of "Fri, 11 Aug 2017 16:22:56 +0100")
"Daniel P. Berrange" <berrange@redhat.com> wrote:
> On Tue, Aug 08, 2017 at 06:26:21PM +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>
>>
>> +/* Default uuid for multifd when qemu is not started with uuid */
>> +static char multifd_uuid[] = "5c49fd7e-af88-4a07-b6e8-091fd696ad40";
>
> Why is this better than just using the qemu_uuid unconditionally.
> UUIC, it'll just be 00000000-0000-0000-0000-000000000000.
>
> Either way you've got a non-unique UUID if multiple QEMUs are
> started, so I dont see a benefit in inventing a new uuid here.
I hate a message full of zeros, it is the default value. If you have
more than one qemu and you don't set uuid, you are asking for trouble.
But if people preffer the 00000 uuid, it is also ok with me.
>
>> +/* strlen(multifd) + '-' + <channel id> + '-' + UUID_FMT + '\0' */
>> +#define MULTIFD_UUID_MSG (7 + 1 + 3 + 1 + UUID_FMT_LEN + 1)
>> +
>> static void *multifd_send_thread(void *opaque)
>> {
>> MultiFDSendParams *p = opaque;
>> + char *string;
>> + char *string_uuid;
>> +
>> + if (qemu_uuid_set) {
>> + string_uuid = qemu_uuid_unparse_strdup(&qemu_uuid);
>> + } else {
>> + string_uuid = g_strdup(multifd_uuid);
>> + }
>> + string = g_strdup_printf("%s multifd %03d", string_uuid, p->id);
>> + g_free(string_uuid);
>> + qio_channel_write(p->c, string, MULTIFD_UUID_MSG, &error_abort);
>
> Must check return code here as it can do a short write, which won't
> trigger error_abort. Also you must not use error_abort at all. QEMU
> must not abort when migration hits an I/O error as that needlessly
> kills the user's VM.
>
> I also think it is not nice to be formatting a string with printf
> here, sending it and then using scanf to extract the data. If we
> need to send structured data, then we should define a proper binary
> format for it eg
>
> struct MigrateUUIDMsg {
> uint32_t chnanelid;
> QemuUUID uuid;
> } __attribute__((__packed__));
>
> and then just send the raw struct across.
Not that I believe that it still works (or that it worked ever), but
qemu migration "on stream" was supposed to be Endian safe .....
>> + g_free(string);
>>
>> while (true) {
>> qemu_mutex_lock(&p->mutex);
>> @@ -445,6 +467,12 @@ int multifd_save_setup(void)
>> qemu_sem_init(&p->sem, 0);
>> p->quit = false;
>> p->id = i;
>> + p->c = socket_send_channel_create();
>> + if (!p->c) {
>> + error_report("Error creating a send channel");
>> + multifd_save_cleanup();
>> + return -1;
>> + }
>
> We should pass an 'Error *' object into socket_send_channel_create()
> so that we can receive & report the actual error message, instead
> of a useless generic message.
Yeap, that is what I told was doing next on the Cover letter.
Just that it means changing lots of functions prototypes ....
>> + qio_channel_read(ioc, string, sizeof(string), &error_abort);
>
> Must not use error_abort which kills the whole VM ungracefully
Changing also that.
>
>> + 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_report("multifd: received uuid '%s' and expected uuid '%s'"
>> + " for channel %d", string_uuid, uuid, id);
>> + migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE,
>> + MIGRATION_STATUS_FAILED);
>> + terminate_multifd_recv_threads();
>> + return;
>> + }
>> + g_free(uuid);
>
> As mentioned above, we should receive a binary struct here instead
> of playing games with scanf.
>> @@ -534,22 +612,15 @@ int multifd_load_setup(void)
>> multifd_recv_state = g_malloc0(sizeof(*multifd_recv_state));
>> multifd_recv_state->params = g_new0(MultiFDRecvParams *, thread_count);
>> multifd_recv_state->count = 0;
>> - for (i = 0; i < thread_count; i++) {
>> - char thread_name[16];
>> - MultiFDRecvParams *p = multifd_recv_state->params[i];
>> -
>> - qemu_mutex_init(&p->mutex);
>> - qemu_sem_init(&p->sem, 0);
>> - p->quit = false;
>> - p->id = i;
>> - snprintf(thread_name, sizeof(thread_name), "multifdrecv_%d", i);
>> - qemu_thread_create(&p->thread, thread_name, multifd_recv_thread, p,
>> - QEMU_THREAD_JOINABLE);
>> - multifd_recv_state->count++;
>> - }
>
> It us a little strange to be deleting a bunch of code you just added in the
> previous patch
We create the send/recv channels on previous patch. And then we switch
to create them as we receive the connections. I will try to see if
creating first the receiving threads it gets clearer.
>> static SocketAddress *tcp_build_address(const char *host_port, Error **errp)
>> {
>> @@ -96,6 +128,9 @@ static void socket_start_outgoing_migration(MigrationState *s,
>> struct SocketConnectData *data = g_new0(struct SocketConnectData, 1);
>>
>> data->s = s;
>> + outgoing_args.saddr = saddr;
>> + outgoing_args.errp = errp;
>
> Taking a stack local 'errp' pointer and saving it for later use
> in a global variable is asking for trouble. There's no guarantee
> that stack frame will still be valid when 'outgoing_args.errp'
> is later used.
Yeap, changing to an Error * pointer by thread.
Thanks, Juan.
next prev parent reply other threads:[~2017-08-14 13:52 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-08 16:26 [Qemu-devel] [PATCH v6 00/19] Multifd Juan Quintela
2017-08-08 16:26 ` [Qemu-devel] [PATCH v6 01/19] migration: Create migration_ioc_process_incoming() Juan Quintela
2017-08-11 3:47 ` Peter Xu
2017-09-06 11:07 ` Juan Quintela
2017-09-08 4:16 ` Peter Xu
2017-09-13 9:41 ` Juan Quintela
2017-08-11 14:50 ` Daniel P. Berrange
2017-08-08 16:26 ` [Qemu-devel] [PATCH v6 02/19] migration: Teach it about G_SOURCE_REMOVE Juan Quintela
2017-08-10 14:56 ` Daniel P. Berrange
2017-08-11 3:49 ` Peter Xu
2017-08-08 16:26 ` [Qemu-devel] [PATCH v6 03/19] migration: Add comments to channel functions Juan Quintela
2017-08-10 14:57 ` Daniel P. Berrange
2017-08-08 16:26 ` [Qemu-devel] [PATCH v6 04/19] migration: Create migration_has_all_channels Juan Quintela
2017-08-10 14:58 ` Daniel P. Berrange
2017-08-10 15:17 ` Eric Blake
2017-08-08 16:26 ` [Qemu-devel] [PATCH v6 05/19] qio: Create new qio_channel_{readv, writev}_all Juan Quintela
2017-08-10 15:04 ` Daniel P. Berrange
2017-08-08 16:26 ` [Qemu-devel] [PATCH v6 06/19] migration: Add multifd capability Juan Quintela
2017-08-11 7:14 ` Peter Xu
2017-08-11 14:52 ` Daniel P. Berrange
2017-08-08 16:26 ` [Qemu-devel] [PATCH v6 07/19] migration: Create x-multifd-threads parameter Juan Quintela
2017-08-11 7:15 ` Peter Xu
2017-08-11 14:56 ` Daniel P. Berrange
2017-09-13 10:12 ` Juan Quintela
2017-09-13 10:18 ` Daniel P. Berrange
2017-08-08 16:26 ` [Qemu-devel] [PATCH v6 08/19] migration: Create x-multifd-group parameter Juan Quintela
2017-08-11 7:16 ` Peter Xu
2017-08-11 15:03 ` Daniel P. Berrange
2017-09-13 10:25 ` Juan Quintela
2017-08-08 16:26 ` [Qemu-devel] [PATCH v6 09/19] migration: Create multifd migration threads Juan Quintela
2017-08-15 6:42 ` Peter Xu
2017-08-08 16:26 ` [Qemu-devel] [PATCH v6 10/19] migration: Split migration_fd_process_incoming Juan Quintela
2017-08-11 15:10 ` Daniel P. Berrange
2017-08-15 6:43 ` Peter Xu
2017-08-08 16:26 ` [Qemu-devel] [PATCH v6 11/19] migration: Start of multiple fd work Juan Quintela
2017-08-11 15:22 ` Daniel P. Berrange
2017-08-14 13:43 ` Juan Quintela [this message]
2017-08-14 13:50 ` Daniel P. Berrange
2017-08-08 16:26 ` [Qemu-devel] [PATCH v6 12/19] migration: Create ram_multifd_page Juan Quintela
2017-08-11 15:25 ` Daniel P. Berrange
2017-08-08 16:26 ` [Qemu-devel] [PATCH v6 13/19] migration: Really use multiple pages at a time Juan Quintela
2017-08-08 16:26 ` [Qemu-devel] [PATCH v6 14/19] migration: Send the fd number which we are going to use for this page Juan Quintela
2017-08-14 15:47 ` Dr. David Alan Gilbert
2017-08-08 16:26 ` [Qemu-devel] [PATCH v6 15/19] migration: Create thread infrastructure for multifd recv side Juan Quintela
2017-08-11 4:35 ` Peter Xu
2017-08-11 15:29 ` Daniel P. Berrange
2017-09-13 9:53 ` Juan Quintela
2017-09-13 11:26 ` Juan Quintela
2017-09-13 11:45 ` Daniel P. Berrange
2017-08-08 16:26 ` [Qemu-devel] [PATCH v6 16/19] migration: Test new fd infrastructure Juan Quintela
2017-08-11 15:32 ` Daniel P. Berrange
2017-08-11 15:35 ` Daniel P. Berrange
2017-08-08 16:26 ` [Qemu-devel] [PATCH v6 17/19] migration: Rename initial_bytes Juan Quintela
2017-08-11 19:01 ` Dr. David Alan Gilbert
2017-08-08 16:26 ` [Qemu-devel] [PATCH v6 18/19] migration: Transfer pages over new channels Juan Quintela
2017-08-11 15:34 ` Daniel P. Berrange
2017-08-16 16:38 ` Dr. David Alan Gilbert
2017-08-08 16:26 ` [Qemu-devel] [PATCH v6 19/19] migration: Flush receive queue Juan Quintela
2017-08-11 4:16 ` Peter Xu
2017-08-08 23:37 ` [Qemu-devel] [PATCH v6 00/19] Multifd no-reply
-- strict thread matches above, loose matches on Subject: below --
2017-08-08 16:22 Juan Quintela
2017-08-08 16:22 ` [Qemu-devel] [PATCH v6 11/19] migration: Start of multiple fd work 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=87shguxo0x.fsf@secure.laptop \
--to=quintela@redhat.com \
--cc=berrange@redhat.com \
--cc=dgilbert@redhat.com \
--cc=lvivier@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.