All of lore.kernel.org
 help / color / mirror / Atom feed
From: "manish.mishra" <manish.mishra@nutanix.com>
To: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: qemu-devel@nongnu.org, peterx@redhat.com,
	prerna.saxena@nutanix.com, quintela@redhat.com,
	dgilbert@redhat.com, lsoaresp@redhat.com
Subject: Re: [PATCH v4 2/2] migration: check magic value for deciding the mapping of channels
Date: Wed, 23 Nov 2022 21:34:35 +0530	[thread overview]
Message-ID: <9cdace7b-7fd2-7c9a-01a2-14bef1473136@nutanix.com> (raw)
In-Reply-To: <Y35DOkfHr2+2PwSe@redhat.com>


On 23/11/22 9:28 pm, Daniel P. Berrangé wrote:
> On Wed, Nov 23, 2022 at 03:05:27PM +0000, manish.mishra wrote:
>> Current logic assumes that channel connections on the destination side are
>> always established in the same order as the source and the first one will
>> always be the main channel followed by the multifid or post-copy
>> preemption channel. This may not be always true, as even if a channel has a
>> connection established on the source side it can be in the pending state on
>> the destination side and a newer connection can be established first.
>> Basically causing out of order mapping of channels on the destination side.
>> Currently, all channels except post-copy preempt send a magic number, this
>> patch uses that magic number to decide the type of channel. This logic is
>> applicable only for precopy(multifd) live migration, as mentioned, the
>> post-copy preempt channel does not send any magic number. Also, tls live
>> migrations already does tls handshake before creating other channels, so
>> this issue is not possible with tls, hence this logic is avoided for tls
>> live migrations. This patch uses read peek to check the magic number of
>> channels so that current data/control stream management remains
>> un-effected.
>>
>> Reviewed-by: Peter Xu <peterx@redhat.com>
>> Reviewed-by: Daniel P. Berrangé <berrange@redhat.co
>> Suggested-by: Daniel P. Berrangé <berrange@redhat.com
>> Signed-off-by: manish.mishra <manish.mishra@nutanix.com>
>> ---
>>   migration/channel.c      | 46 ++++++++++++++++++++++++++++++++++++++++
>>   migration/channel.h      |  5 +++++
>>   migration/migration.c    | 45 ++++++++++++++++++++++++++++-----------
>>   migration/multifd.c      | 12 ++++-------
>>   migration/multifd.h      |  2 +-
>>   migration/postcopy-ram.c |  5 +----
>>   migration/postcopy-ram.h |  2 +-
>>   7 files changed, 91 insertions(+), 26 deletions(-)
>>
>> diff --git a/migration/channel.c b/migration/channel.c
>> index 1b0815039f..a4600f52c5 100644
>> --- a/migration/channel.c
>> +++ b/migration/channel.c
>> @@ -92,3 +92,49 @@ void migration_channel_connect(MigrationState *s,
>>       migrate_fd_connect(s, error);
>>       error_free(error);
>>   }
>> +
>> +
>> +/**
>> + * @migration_channel_read_peek - Read from the peek of migration channel,
>> + *    without actually removing it from channel buffer.
>> + *
>> + * @ioc: the channel object
>> + * @buf: the memory region to read data into
>> + * @buflen: the number of bytes to read in @buf
>> + * @errp: pointer to a NULL-initialized error object
>> + *
>> + * Returns 0 if successful, returns -1 and sets @errp if fails.
>> + */
>> +int migration_channel_read_peek(QIOChannel *ioc,
>> +                                const char *buf,
>> +                                const size_t buflen,
>> +                                Error **errp)
>> +{
>> +   ssize_t len = 0;
>> +   struct iovec iov = { .iov_base = (char *)buf, .iov_len = buflen };
>> +
>> +   while (len < buflen) {
>> +       len = qio_channel_readv_full(ioc, &iov, 1, NULL,
>> +                                    NULL, QIO_CHANNEL_READ_FLAG_MSG_PEEK, errp);
>> +
>> +       if (len == QIO_CHANNEL_ERR_BLOCK) {
>> +            if (qemu_in_coroutine()) {
>> +                /* 1ms sleep. */
>> +                qemu_co_sleep_ns(QEMU_CLOCK_REALTIME, 1000000);
>> +            } else {
>> +                qio_channel_wait(ioc, G_IO_IN);
>> +            }
>> +            continue;
>> +       }
>> +       if (len == 0) {
>> +           error_setg(errp,
>> +                      "Unexpected end-of-file on channel");
>> +           return -1;
>> +       }
>> +       if (len < 0) {
>> +           return -1;
>> +       }
>> +   }
> This busy waits when len > 0 and < buflen
>
>
> With regards,
> Daniel

Sorry,   Daniel, may be i misunderstood something from earlier discussions. I thought we discussed we may not prevent it from looping multiple times but we can  qemu_co_sleep_ns after every retry to deal with busy wait?

Thanks

Manish Mishra




  reply	other threads:[~2022-11-23 16:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23 15:05 [PATCH v4 0/2] migration: check magic value for deciding the mapping of channels manish.mishra
2022-11-23 15:05 ` [PATCH v4 1/2] io: Add support for MSG_PEEK for socket channel manish.mishra
2022-11-23 15:42   ` Daniel P. Berrangé
2022-11-23 15:05 ` [PATCH v4 2/2] migration: check magic value for deciding the mapping of channels manish.mishra
2022-11-23 15:52   ` Peter Xu
2022-11-23 15:58     ` manish.mishra
2022-11-23 16:27       ` Peter Xu
2022-11-23 16:33         ` manish.mishra
2022-11-23 15:58   ` Daniel P. Berrangé
2022-11-23 16:04     ` manish.mishra [this message]
2022-11-23 16:19       ` Daniel P. Berrangé

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=9cdace7b-7fd2-7c9a-01a2-14bef1473136@nutanix.com \
    --to=manish.mishra@nutanix.com \
    --cc=berrange@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=lsoaresp@redhat.com \
    --cc=peterx@redhat.com \
    --cc=prerna.saxena@nutanix.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 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.