All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Cc: jasowang@redhat.com, qemu-devel@nongnu.org, leiyang@redhat.com,
	steven.sistare@oracle.com, yc-core@yandex-team.ru,
	mst@redhat.com, farosas@suse.de, eblake@redhat.com,
	armbru@redhat.com, thuth@redhat.com, philmd@linaro.org,
	berrange@redhat.com
Subject: Re: [PATCH v3 5/9] net/tap: implement interfaces for local migration
Date: Tue, 9 Sep 2025 10:56:43 -0400	[thread overview]
Message-ID: <aMBAK58JuodeezLb@x1.local> (raw)
In-Reply-To: <fa01e354-289b-4dc7-bfc2-02913c3e488d@yandex-team.ru>

On Tue, Sep 09, 2025 at 10:44:22AM +0300, Vladimir Sementsov-Ogievskiy wrote:
> On 08.09.25 23:01, Peter Xu wrote:
> > On Mon, Sep 08, 2025 at 07:48:09PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> > > On 08.09.25 18:42, Peter Xu wrote:
> > > > On Fri, Sep 05, 2025 at 04:50:35PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> > > > > +static const VMStateDescription vmstate_tap = {
> > > > > +    .name = "virtio-net-device",
> > > > > +    .post_load = tap_post_load,
> > > > > +    .fields = (const VMStateField[]) {
> > > > > +        VMSTATE_FD(fd, TAPState),
> > > > > +        VMSTATE_BOOL(using_vnet_hdr, TAPState),
> > > > > +        VMSTATE_BOOL(has_ufo, TAPState),
> > > > > +        VMSTATE_BOOL(has_uso, TAPState),
> > > > > +        VMSTATE_BOOL(enabled, TAPState),
> > > > > +        VMSTATE_UINT32(host_vnet_hdr_len, TAPState),
> > > > > +        VMSTATE_END_OF_LIST()
> > > > > +    }
> > > > > +};
> > > > > +
> > > > > +int tap_save(NetClientState *nc, QEMUFile *f)
> > > > > +{
> > > > > +    TAPState *s = DO_UPCAST(TAPState, nc, nc);
> > > > > +
> > > > > +    return vmstate_save_state(f, &vmstate_tap, s, 0);
> > > > > +}
> > > > > +
> > > > > +int tap_load(NetClientState *nc, QEMUFile *f)
> > > > > +{
> > > > > +    TAPState *s = DO_UPCAST(TAPState, nc, nc);
> > > > > +
> > > > > +    return vmstate_load_state(f, &vmstate_tap, s, 0);
> > > > > +}
> > > > 
> > > > Instead of hard-coding vmstate_save_state() / vmstate_load_state(), could
> > > > we make tap's VMSD to be a subsection of virtio-net's?
> > > > 
> > > > Multifd already doesn't support qemufile, but only iochannels (which is the
> > > > internal impl of qemufiles).  We might at some point start to concurrently
> > > > load devices with multifd, then anything with qemufile will be a no-go and
> > > > need to be serialized as legacy code in the main channel, or rewritten.
> > > > 
> > > > IMHO it'll be great if we can avoid adding new codes operating on
> > > > qemufiles, and also avoid adding any new custom VMSD fields' put()/get() if
> > > > ever possible.
> > > > 
> > > 
> > > Subsections are loaded after fields.
> > > 
> > > And virtio-net already has fields
> > > 
> > >          VMSTATE_WITH_TMP(VirtIONet, struct VirtIONetMigTmp,
> > >                           vmstate_virtio_net_has_vnet),
> > > 
> > > and
> > > 
> > >          VMSTATE_WITH_TMP(VirtIONet, struct VirtIONetMigTmp,
> > >                           vmstate_virtio_net_has_ufo),
> > 
> > Side note: I'm actually a bit confused on why it needs to use
> > VMSTATE_WITH_TMP(), or say, the get()/put() directly.
> > 
> > Taking example of vmstate_virtio_net_has_ufo, afaiu, the only point here is
> > that virtio_net_ufo_post_load() would check peer UFO support.  I wonder if
> > that should work too to check that in virtio_net_post_load_device(), and
> > fail there if anything is wrong..  then would has_ufo be able to be
> > migrated as a VMSTATE_U8 field?

[1]

> > 
> > > 
> > > Which do check on virtio-net level some parameters, which should come from local migration of TAP.
> > > 
> > > That's why I made TAP a field, and put it before these two ones. This way these two checks works.
> > > 
> > > 
> > > Still, from your comment I understand that hard-coding save/load is worse problem. So I can just
> > > skip checking in vmstate_virtio_net_has_vnet / vmstate_virtio_net_has_ufo with enabled "local-tap"
> > > (or "fd-passing") capability (or better migration parameter). This way TAP may be a subsection.
> > 
> > That'll be nice, thanks.  Or would a VMSTATE_STRUCT() for TAP to work (so
> > that it can also be put before the two _TMPs, but avoid raw get()/put())?
> > 
> 
> I considered using VMSTATE_STRUCT, but it would mean, I should access TAPState directly from virtio-net
> code. That's not possible now, as TAPState is a static type in tap.c, and think it's better to keep
> it static. So, in this case, subsection should be better, if I understand correctly.

Ah OK.  Then I wonder if this is a good chance too to move the peer feature
checks above [1] directly over to virtio-net's post_load as a pre-requisite
change, which should also be after the subsections.  Then the hope is it'll
also help removing some _TMP users.

-- 
Peter Xu



  reply	other threads:[~2025-09-09 14:59 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-05 13:50 [PATCH v3 0/9] virtio-net: live-TAP local migration Vladimir Sementsov-Ogievskiy
2025-09-05 13:50 ` [PATCH v3 1/9] net/tap: add some trace points Vladimir Sementsov-Ogievskiy
2025-09-05 13:50 ` [PATCH v3 2/9] net/tap: keep exit notifier only when downscript set Vladimir Sementsov-Ogievskiy
2025-09-05 13:50 ` [PATCH v3 3/9] net/tap: refactor net_tap_setup_vhost() Vladimir Sementsov-Ogievskiy
2025-09-05 13:50 ` [PATCH v3 4/9] qapi: add interface for local TAP migration Vladimir Sementsov-Ogievskiy
2025-09-08 15:35   ` Peter Xu
2025-09-08 16:38     ` Vladimir Sementsov-Ogievskiy
2025-09-08 18:47       ` Peter Xu
2025-09-09  7:40         ` Vladimir Sementsov-Ogievskiy
2025-09-05 13:50 ` [PATCH v3 5/9] net/tap: implement interfaces for local migration Vladimir Sementsov-Ogievskiy
2025-09-08 15:42   ` Peter Xu
2025-09-08 16:48     ` Vladimir Sementsov-Ogievskiy
2025-09-08 20:01       ` Peter Xu
2025-09-09  7:44         ` Vladimir Sementsov-Ogievskiy
2025-09-09 14:56           ` Peter Xu [this message]
2025-09-09 15:08             ` Vladimir Sementsov-Ogievskiy
2025-09-05 13:50 ` [PATCH v3 6/9] virtio-net: support local tap migration Vladimir Sementsov-Ogievskiy
2025-09-08 15:43   ` Peter Xu
2025-09-08 16:48     ` Vladimir Sementsov-Ogievskiy
2025-09-05 13:50 ` [PATCH v3 7/9] tests/functional: exec_command_and_wait_for_pattern: add vm arg Vladimir Sementsov-Ogievskiy
2025-09-09 14:03   ` Thomas Huth
2025-09-09 14:09     ` Vladimir Sementsov-Ogievskiy
2025-09-05 13:50 ` [PATCH v3 8/9] tests/functional: add skipUnlessPasswordlessSudo() decorator Vladimir Sementsov-Ogievskiy
2025-09-08 15:49   ` Daniel P. Berrangé
2025-09-05 13:50 ` [PATCH v3 9/9] tests/functional: add test_x86_64_tap_fd_migration Vladimir Sementsov-Ogievskiy
2025-09-08 15:58   ` 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=aMBAK58JuodeezLb@x1.local \
    --to=peterx@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=eblake@redhat.com \
    --cc=farosas@suse.de \
    --cc=jasowang@redhat.com \
    --cc=leiyang@redhat.com \
    --cc=mst@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=steven.sistare@oracle.com \
    --cc=thuth@redhat.com \
    --cc=vsementsov@yandex-team.ru \
    --cc=yc-core@yandex-team.ru \
    /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.