All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@suse.de>
To: Prasad Pandit <ppandit@redhat.com>
Cc: qemu-devel@nongnu.org, peterx@redhat.com, berrange@redhat.com,
	Prasad Pandit <pjp@fedoraproject.org>
Subject: Re: [PATCH v8 2/7] migration: Refactor channel discovery mechanism
Date: Thu, 03 Apr 2025 09:59:34 -0300	[thread overview]
Message-ID: <878qohl7t5.fsf@suse.de> (raw)
In-Reply-To: <CAE8KmOzASSXE9FRmiFQ6Q4fxaGFh_8VWKXgnugjEs+egFuQPpA@mail.gmail.com>

Prasad Pandit <ppandit@redhat.com> writes:

> Hello Fabiano,
>
> On Mon, 31 Mar 2025 at 20:31, Fabiano Rosas <farosas@suse.de> wrote:
>> > +    } else if (mis->from_src_file) {
>> This is redundant.
>
> * This was to ensure (double check) that when the Postcopy connection
> comes in, the main channel is established. Also a couple of versions
> back migration qtest was failing without this check. Nonetheless,
> qtests do work now without this check. I'll remove it if we must.
>

Yes, there's no point. if we already have main and multifd channels,
what's left must be postcopy.

>> > +        channel = CH_POSTCOPY;
>> >      } else {
>> > -        default_channel = !mis->from_src_file;
>> > +        channel = CH_MAIN;
>>
>> And this is impossible.
>
>     -> https://lore.kernel.org/qemu-devel/20250215123119.814345-1-ppandit@redhat.com/T/#m18b6bf30e877f9eafaa67bba6a209b47782f6eac
>
> * Yes, but a couple of revisions back you suggested adding it saying
> CH_MAIN assignment at the top was doing some heavy lifting and it's
> more clear this way.
>

Well, but don't add it blindly if it doesn't make sense. The point was
to not end the conditional at 'else if' because that makes the reader
have to go look around the code to see what was already assigned. Here
we want just a plain:

else {
    channel = CH_POSTCOPY; 
}

>> We should probably expand migration_incoming_setup() to make it clear
>> that mis->from_src_file is set at this point. And
>> assert(!mis->from_src_file). I can send a patch on top later.
>
> * migration_incoming_setup uses the QEMUFile object only when
> mis->from_src_file is not set. I'm wondering if we really need an
> assert(!mis->from_src_file) check? Because it'll reach here only when
> channel == CH_MAIN and channel is set to CH_MAIN only when
> mis->from_src_file is NULL.
>
>

Given the:

if (!mis->from_src_file) {

I think someone (back in 2017) thought it was possible to reach there
with from_src_file already set. I don't know whether that applied to
this path. In any case, for this function I believe the correct is
assert because we shouldn't have two channels arriving as main.

>> > -    } else {
>> > +    } else if (channel == CH_MULTIFD) {
>> >          /* Multiple connections */
>> > -        assert(migration_needs_multiple_sockets());
>> >          if (migrate_multifd()) {
>>
>> This should be an assert.
>
> Same, 'channel' is set to CH_MULTIFD,  only when migrate_multifd() is
> enabled. Do we need another assert(migrate_multifd()) check?
>

Maybe not, but we definitely cannot just ignore if it happens and we
also should not have an empty check that is always known to be true. So
either assert or remove the if entirely.

>> > +    } else if (channel == CH_POSTCOPY) {
>> > +        assert(migrate_postcopy_preempt());
>> > +        assert(!mis->postcopy_qemufile_dst);
>> > +        f = qemu_file_new_input(ioc);
>> > +        postcopy_preempt_new_channel(mis, f);
>> > +        return;
>> >      }
>> >
>> > -    if (migration_should_start_incoming(default_channel)) {
>> > +    if (migration_has_main_and_multifd_channels()) {
>>
>> I think there's a bug here. Excluding multifd from the picture, if only
>> the main channel needs to be setup, then it's possible to start postcopy
>> recovery twice, once when the main channel appears and another time when
>> the preempt channel appears.
>
> * When the preempt channel appears 'channel' is set to CH_POSTCOPY, so
> it shall 'return' before reaching here, right?
>

You're right, I missed the return statement.

> ===
>         } else if (!mis->from_src_file &&
>                         mis->state == MIGRATION_STATUS_POSTCOPY_PAUSED) {
>                 /* reconnect main channel for postcopy recovery */
>                 channel = CH_MAIN;
>         } else {
> ===
> * When 'main' channel connection arrives for postcopy recovery,
> 'channel' shall be set to CH_MAIN.
>
>> The previous code worked differently because it did:
>>
>> if (migrate_postcopy_preempt()) {
>>     return main_channel;
>>
>> which would return false when preempt arrived after main.
>
> * Yes.
>
>> We could use migration_has_all_channels() instead, that would look more
>> logically correct, but it would also change the current behavior that
>> postcopy recovery can start before the preempt channel is in place. I'm
>> not even sure if that's actually part of the design of the feature.
>
> * Not sure if we need this.
>
> Thank you.
> ---
>   - Prasad


  reply	other threads:[~2025-04-03 13:00 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-18 12:38 [PATCH v8 0/7] Allow to enable multifd and postcopy migration together Prasad Pandit
2025-03-18 12:38 ` [PATCH v8 1/7] migration/multifd: move macros to multifd header Prasad Pandit
2025-03-18 12:38 ` [PATCH v8 2/7] migration: Refactor channel discovery mechanism Prasad Pandit
2025-03-31 15:01   ` Fabiano Rosas
2025-04-03  7:01     ` Prasad Pandit
2025-04-03 12:59       ` Fabiano Rosas [this message]
2025-04-04  9:48         ` Prasad Pandit
2025-03-18 12:38 ` [PATCH v8 3/7] migration: enable multifd and postcopy together Prasad Pandit
2025-03-31 15:27   ` Fabiano Rosas
2025-04-03 10:57     ` Prasad Pandit
2025-04-03 13:03       ` Fabiano Rosas
2025-03-18 12:38 ` [PATCH v8 4/7] tests/qtest/migration: consolidate set capabilities Prasad Pandit
2025-03-18 12:38 ` [PATCH v8 5/7] tests/qtest/migration: add postcopy tests with multifd Prasad Pandit
2025-03-18 12:38 ` [PATCH v8 6/7] migration: Add save_postcopy_prepare() savevm handler Prasad Pandit
2025-03-31 15:08   ` Fabiano Rosas
2025-04-03  7:03     ` Prasad Pandit
2025-03-18 12:38 ` [PATCH v8 7/7] migration/ram: Implement save_postcopy_prepare() Prasad Pandit
2025-03-31 15:18   ` Fabiano Rosas
2025-04-03  7:21     ` Prasad Pandit
2025-04-03 13:07       ` Fabiano Rosas
2025-04-04  9:50         ` Prasad Pandit
2025-03-25  9:53 ` [PATCH v8 0/7] Allow to enable multifd and postcopy migration together Prasad Pandit
2025-03-27 14:35   ` Fabiano Rosas
2025-03-27 16:01     ` Prasad Pandit
2025-03-31 20:54 ` Fabiano Rosas
2025-04-03  7:24   ` Prasad Pandit
2025-04-03 13:11     ` Fabiano Rosas
2025-04-10 12:22       ` Prasad Pandit
2025-04-10 20:18         ` Fabiano Rosas
2025-04-11  7:25           ` Prasad Pandit

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=878qohl7t5.fsf@suse.de \
    --to=farosas@suse.de \
    --cc=berrange@redhat.com \
    --cc=peterx@redhat.com \
    --cc=pjp@fedoraproject.org \
    --cc=ppandit@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.